URLResourceName.java revision 3e9a58c7ab182327c2fdd169ed1d70dcba846fe4
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: URLResourceName.java,v 1.1 2009/11/24 21:42:35 madan_ranganath Exp $
*
* Portions Copyrighted 2013 ForgeRock AS
*/
/**
* This plugin extends the functionality provided in
* <code>PrefixResourceName</code> to provide special handling to
* URL type prefix resource names in <code>canonicalize</code> method
* like validating port, assigning default port of 80, if port absent etc.
*/
public class URLResourceName
extends PrefixResourceName implements Comparator {
private static final Pattern ACCEPTABLE_URLS;
static {
// This resource name implementation only concerns
// itself with URLs that start with http(*) or https(*).
}
/**
* This method is used to canonicalize a url string.
* it removed leading delimiters after the protocol
* http:////abc becomes http://abc
* if port number is provided validates it to be either wildcard
* a valid integer, if not provided, adds default port 80
* Makes sure URL is not malformed, also if query parameters
* are present sorts them based on the comparator's sort method.
*
* @param urlStr the url string to be canonicalized
* @return the url string in its canonicalized form.
* @throws MalformedURLException if the url string is invalid
*/
throws MalformedURLException {
/* if no http or https protocol resources
* only call super.canonicalize()
* to validate the wildcard usage and
* remove extra delimiters.
*/
return super.canonicalize(urlStr);
}
int j = 0;
// charAt(0) assuming delimiter is only one character.
j++; // skip leading '/'
}
int i = 0;
while (j < len) {
}
}
if (index == -1) {
}
if (index != -1) {
}
if (index != -1) {
}
if (index != -1) {
}
// If no port has been specified set a default port value based on the protocol.
// Should the protocol contain a wildcard, set the port to be a wildcard also.
port = DEFAULT_PORT;
port = SECURE_PORT;
} else {
}
}
}
}
if (debug.messageEnabled()) {
}
// check if there are more than one query parameters
if (indexAmp != -1) {
// there are more than query parameters in the url
while (st.hasMoreTokens()) {
}
// sort the query parameters based on rules of
// the comparator
// reconstruct the url in canonicalized form
for (int i = 0; i < size; i++) {
if (i < (size-1)) {
} else {
}
}
} else {
// there is only one query parameter in the url
}
} else {
// there is no query string in the url
}
}
/**
* This method is used to compare two url query parameter
* strings. A query parameter string is in the form of
* variablename=value.
*
* @param o1 a url query parameter to be compared
* @param o2 a url query parameter to be compared
* @return -1 if o1 < o2; 0 if o1 = o2; 1 if o1 > o2
*/
{
return -1;
} else {
return 0;
}
} else {
return 1;
}
}
// neither s1 nor s2 is null
if (index1 != -1) {
}
if (index2 != -1) {
}
if (result == 0) {
// variable names are the same, we need to further
// compare the values
result = -1;
} else {
result = 0;
}
} else {
result = 1;
} else {
}
}
}
return result;
}
/* Validate the port number to make sure there is no invalid
* character in the port part.
* Valid characters are digits and wildcard.
*/
throws MalformedURLException
{
if (idx != -1) {
int begin = 0;
while (idx != -1) {
}
}
/* wildcards have been extracted, the remainder should
* be an integer or an empty string.
*/
try {
} catch (Exception e) {
throw (new MalformedURLException(
"Invalid Port number specified"));
}
}
if (debug.messageEnabled()) {
}
}
}