Package com.sun.identity.policy
Class ServiceType
- java.lang.Object
-
- com.sun.identity.policy.ServiceType
-
public class ServiceType extends Object
The classServiceTypeprovides interfaces to obtain information about a service, for which a policy could be created. The information that can be obtained are actions names (privileges) of service and its schema, whether the service requires resource names andResourceNameused to compare the resources
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServiceType(String serviceName, ServiceSchemaManager ssm, ServiceSchema pschema)Constructor used byServiceTypeManagerto construct an instance ofServiceType,
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringappend(String superRes, String subRes)Combine super-resource and sub-resource of this service type.protected ResourceMatchcompare(String resource1, String resource2)Compares two resources of this service type to determine their equality.protected ResourceMatchcompare(String resource1, String resource2, boolean interpretWildCard)Compares two resources of this service type to determine their equality.booleancontainsActionName(String actionName)Returnstrueis the service has the specified action name.SetgetActionNames()Returns the actions supported by the service.ActionSchemagetActionSchema(String actionName)Returns the schema associated with the action name.MapgetActionSchemas()Returns the action schemas for all the actions supported by the service.StringgetI18NKey()Returns the I18N key for the service name.StringgetI18NPropertiesFileName()Returns the I18N properties file name for the service.StringgetName()Returns the name of this objectprotected SetgetPoliciesForExactResourceMatch(String resoruceName)Method to identify policies that have the specified resource.protected SetgetPolicyForResource(String resourceName)Method to identify polcies that has the specified resource and its superior resources.ResourceNamegetResourceNameComparator()ReturnsResourceNameused by this objectStringgetSubResource(String res, String superRes)Method to get sub-resource from an original resource minus a super resource.booleanhasResourceNames()Returnstrueif the service has resource names.String[]split(String res)Method to split a resource into the smallest possible subresource unitsbooleanvalidateActionValues(Map actionValues)Returnstrueif the action names and its values in the givenMapare valid and satisfy the schema for the respective action names.
-
-
-
Constructor Detail
-
ServiceType
protected ServiceType(String serviceName, ServiceSchemaManager ssm, ServiceSchema pschema)
Constructor used byServiceTypeManagerto construct an instance ofServiceType,- Parameters:
serviceName- name of the service for which to constructServiceTypessm-ServiceTypeManagerto initialize the theServiceTypewith
-
-
Method Detail
-
getResourceNameComparator
public ResourceName getResourceNameComparator()
ReturnsResourceNameused by this object- Returns:
ResourceNameused by this object
-
getName
public String getName()
Returns the name of this object- Returns:
- the name of this object
-
getI18NPropertiesFileName
public String getI18NPropertiesFileName()
Returns the I18N properties file name for the service. If the I18N properties file is not defined by the service XML (via SMS) the method returnsnull. Used by GUI and CLI to display the service information- Returns:
- name of the service type
-
getI18NKey
public String getI18NKey()
Returns the I18N key for the service name. If the I18N key is not defined by the service XML (via SMS), or if it is not accessable the method returnsnull. Used by GUI and CLI to display the service name.- Returns:
- name of the service type
-
getActionNames
public Set getActionNames()
Returns the actions supported by the service. The returnedSethas the actions names sorted alphabetically in the ascending order.- Returns:
- sorted set of all action names
-
getActionSchema
public ActionSchema getActionSchema(String actionName) throws InvalidNameException
Returns the schema associated with the action name. The schema provides information such as its type (single, multiple, choice) and its syntax (boolean, string, number, etc.). This information will be useful for GUI/CLI to prompt users to input action values and to validate the action values.- Parameters:
actionName- name of the action for which schema will be returned; if action name is invalid anInvalidActioNameExceptionis thrown- Returns:
- schema for the action values
- Throws:
InvalidNameException- if the action name is not a valid action for the service
-
getActionSchemas
public Map getActionSchemas()
Returns the action schemas for all the actions supported by the service. The returnedMaphas the action names sorted in alphabetic ascending order.- Returns:
- schemas for all the actions suppored by the service
-
validateActionValues
public boolean validateActionValues(Map actionValues) throws InvalidNameException
Returnstrueif the action names and its values in the givenMapare valid and satisfy the schema for the respective action names.- Parameters:
actionValues- aMapthat contains action names as its "key" and aSetof action values as its "value" for the action name- Returns:
trueif the action names and its values satisfy the action schemas for the service- Throws:
InvalidNameException- if either the action names or action values do not match the schema defined by the service
-
containsActionName
public boolean containsActionName(String actionName)
Returnstrueis the service has the specified action name.- Returns:
trueif the service has the action namefalseotherwise
-
compare
protected ResourceMatch compare(String resource1, String resource2)
Compares two resources of this service type to determine their equality. The method returns aResourceMatchobject which specifies if the resources match exactly, do not match, or one of them is a subordinate resource of the other. Wildcards in resource1 are escaped. Wildcards in resource2 are interpreted.- Parameters:
resource1- resource name 1resource2- resource name 2- Returns:
- returns
ResourceMatchthat specifies if the resources are exact match, or otherwise. Return value describes resource2 For example, if the return value is ResourceMatch.SUPER_RESOURCE, resource2 is super resource of resource1.
-
compare
protected ResourceMatch compare(String resource1, String resource2, boolean interpretWildCard)
Compares two resources of this service type to determine their equality. The method returns aResourceMatchobject which specifies if the resources match exactly, do not match, or one of them is a subordinate resource of the other. Wildcards in resource1 are escaped. Wildcards in resource2 are interpreted.- Parameters:
resource1- resource name 1resource2- resource name 2interpretWildCard- iftrue, wild cards in resource2 are interpreted. Else, the wildcards are escaped.- Returns:
- returns
ResourceMatchthat specifies if the resources are exact match, or otherwise. Return value describes resource2 For example, if the return value is ResourceMatch.SUPER_RESOURCE, resource2 is super resource of resource1.
-
append
public String append(String superRes, String subRes)
Combine super-resource and sub-resource of this service type.- Parameters:
superRes- name of the resoruce which will be combined withsubRes- name of the resource which will be combined- Returns:
- returns a combined resource string
-
getSubResource
public String getSubResource(String res, String superRes)
Method to get sub-resource from an original resource minus a super resource. This is the complementary method of append().- Parameters:
res- name of the original resource consisting of the second parameter superRes and the returned valuesuperRes- name of the super-resource which the first parameter begins with.- Returns:
- the sub-resource which the first parameter 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)
Method to split a resource into the smallest possible subresource units- 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
-
getPoliciesForExactResourceMatch
protected Set getPoliciesForExactResourceMatch(String resoruceName)
Method to identify policies that have the specified resource.- Returns:
- policy names that have the resource name
-
getPolicyForResource
protected Set getPolicyForResource(String resourceName)
Method to identify polcies that has the specified resource and its superior resources.
-
hasResourceNames
public boolean hasResourceNames()
Returnstrueif the service has resource names.- Returns:
trueif the service has resource names;falseotherwise
-
-