Class BaseURLResourceName<T,E extends Exception>
- java.lang.Object
-
- org.forgerock.openam.shared.resourcename.BasePrefixResourceName<T,E>
-
- org.forgerock.openam.shared.resourcename.BaseURLResourceName<T,E>
-
- Type Parameters:
T- The type that the compare method is going to return instances of.E- The exception type thrown by the canonicalize method.
- All Implemented Interfaces:
BaseResourceName<T,E>
- Direct Known Subclasses:
URLResourceName,URLResourceName,URLResourceName
public abstract class BaseURLResourceName<T,E extends Exception> extends BasePrefixResourceName<T,E>
This is a base implementation of a URLResourceName, extending the functionality found inBasePrefixResourceNameto provide special handling to URL type prefix resource names incanonicalizemethod like validating port, assigning default port of 80, if port absent etc.- See Also:
BaseResourceName,BasePrefixResourceName
-
-
Field Summary
Fields Modifier and Type Field Description protected static Comparator<String>comparatorQuery parameter comparator.-
Fields inherited from class org.forgerock.openam.shared.resourcename.BasePrefixResourceName
caseSensitive, debug, delimiter, exactMatch, noMatch, oneLevelWildcard, oneLevelWildcardEmbedded, oneLevelWildcardLength, subResourceMatch, superResourceMatch, wildcard, wildcardEmbedded, wildcardLength, wildcardMatch
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcanonicalize(String urlStr)This method is used to canonicalize a url string.Tcompare(String requestResource, String targetResource, boolean wildcardCompare)Specific comparison for URLs, where a wildcard in the host/port should not match any of the path.-
Methods inherited from class org.forgerock.openam.shared.resourcename.BasePrefixResourceName
append, constructResourceInvalidException, getServiceTypeNames, getSubResource, initialize, normalizeRequestResource, normalizeTargetResource, oneLevelWildcardCompare, split
-
-
-
-
Field Detail
-
comparator
protected static Comparator<String> comparator
Query parameter comparator.
-
-
Constructor Detail
-
BaseURLResourceName
protected BaseURLResourceName(Debug debug, T exactMatch, T noMatch, T subResourceMatch, T superResourceMatch, T wildcardMatch)
Constructs a new BaseURLResourceName instance.- Parameters:
debug- The debug instance.exactMatch- The object to return on an exact match.noMatch- The object to return on no match.subResourceMatch- The object to return on a sub-resource match.superResourceMatch- The object to return on a super-resource match.wildcardMatch- The object to return on a wildcard match.
-
-
Method Detail
-
compare
public T compare(String requestResource, String targetResource, boolean wildcardCompare)
Specific comparison for URLs, where a wildcard in the host/port should not match any of the path. Strings should be canonicalized prior to entering this comparison, else they will be compared by the super class' comparison function.- Specified by:
comparein interfaceBaseResourceName<T,E extends Exception>- Overrides:
comparein classBasePrefixResourceName<T,E extends Exception>- Parameters:
requestResource- name of the resource which will be comparedtargetResource- name of the resource which will be compared withwildcardCompare- flag for wildcard comparison- Returns:
- If a wildcard is in the host/port, separately compares the path/query and scheme/host/port, returning NO_MATCH if any don't match. Otherwise returns the match of the port/path/query.
-
canonicalize
public String canonicalize(String urlStr) throws E extends Exception
This method is used to canonicalize a url string. It removes 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.- Specified by:
canonicalizein interfaceBaseResourceName<T,E extends Exception>- Overrides:
canonicalizein classBasePrefixResourceName<T,E extends Exception>- Parameters:
urlStr- the url string to be canonicalized- Returns:
- the url string in its canonicalized form.
- Throws:
E- if the url string is invalidE extends Exception
-
-