Package com.sun.identity.policy.plugins
Class SuffixResourceName
- java.lang.Object
-
- com.sun.identity.policy.plugins.SuffixResourceName
-
- All Implemented Interfaces:
ResourceName,BaseResourceName<ResourceMatch,PolicyException>
public class SuffixResourceName extends Object implements ResourceName
This is a plugin impelmentation of theResourceNameinterface it provides methods to do resource comparisons and resource handling based on suffix based string match going right to left.
-
-
Constructor Summary
Constructors Constructor Description SuffixResourceName()empty no argument constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringappend(String superResource, String subResource)Appends sub-resource to super-resource.Stringcanonicalize(String res)This method is used to canonicalize a suffix resource It returns the string back as is.ResourceMatchcompare(String requestResource, String targetResource, boolean wildcardCompare)Compares two resources.Set<String>getServiceTypeNames()Returns the service type names for which the resource name object can be used.StringgetSubResource(String resource, String superResource)Gets sub-resource from an original resource minus a super resource.voidinitialize(Map configParams)Initializes the resource name with configuration information, usally set by the administrators.String[]split(String res)Method to split a resource into the smallest necessary sub resource units.
-
-
-
Field Detail
-
wildcard
protected String wildcard
-
-
Method Detail
-
initialize
public void initialize(Map configParams)
Initializes the resource name with configuration information, usally set by the administrators. The main configration information retrived is mainly like wild card pattern used, delimiter, case sensitivity etc.- Specified by:
initializein interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
configParams- configuration parameters as a map. The keys of the map are the configuration paramaters. Each key is corresponding to oneStringvalue which specifies the configuration paramater value.
-
getServiceTypeNames
public Set<String> getServiceTypeNames()
Description copied from interface:BaseResourceNameReturns the service type names for which the resource name object can be used.- Specified by:
getServiceTypeNamesin interfaceBaseResourceName<ResourceMatch,PolicyException>- Returns:
- service type names for which the resource comparator can be used
-
compare
public ResourceMatch compare(String requestResource, String targetResource, boolean wildcardCompare)
Compares two resources. Description: The targetResource may contain wildcard '*' which matches zero or more characters. The wildcard character can show up anywhere within the string. The targetResource can contain any number of wildcard characters. One of the five possible match types is returned based on how the two resource strings are related. The comparison starts from the end of the reource strings. ResourceMatch.NO_MATCH means two resources don't match. ResourceMatch.EXACT_MATCH means two resources match. ResourceMatch.SUB_RESOURCE_MATCH means targetResource is the sub resource of the requestResource. ResourceMatch.SUPER_RESOURCE_MATCH means targetResource is the super resource of the requestResource. ResourceMatch.WILDCARD_MATCH means two resources match with respect to the wildcard.- Specified by:
comparein interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
requestResource- name of the resource which will be comparedtargetResource- name of the resource which will be compared withwildcardCompare- flag for wildcard comparison- Returns:
- returns
ResourceMatchthat specifies if the resources are exact match, or otherwise.
-
append
public String append(String superResource, String subResource)
Appends sub-resource to super-resource.- Specified by:
appendin interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
superResource- name of the super-resource to be appended tosubResource- name of the sub-resource to be appended- Returns:
- returns the combination resource.
-
getSubResource
public String getSubResource(String resource, String superResource)
Gets sub-resource from an original resource minus a super resource. This is the complementary method of append().- Specified by:
getSubResourcein interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
resource- name of the original resource consisting of the second parameter superResource and the returned valuesuperResource- name of the super-resource which the first parameter begins with.- Returns:
- returns the sub-resource which the first paramter ends with. If the first parameter doesn't begin with the the first parameter, then the return value is null.
-
split
public String[] split(String res)
Description copied from interface:BaseResourceNameMethod to split a resource into the smallest necessary sub resource units.- Specified by:
splitin interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
res- name of the resource to be split- Returns:
- returns the array of sub-resources, with the first element being what the original resource begins with, and the last one being what it ends with
-
canonicalize
public String canonicalize(String res) throws PolicyException
This method is used to canonicalize a suffix resource It returns the string back as is.- Specified by:
canonicalizein interfaceBaseResourceName<ResourceMatch,PolicyException>- Parameters:
res- the suffix resource string to be canonicalized- Returns:
- the suffix resource string in its canonicalized form.
- Throws:
PolicyException- if resource is invalid
-
-