Class ServiceType


  • public class ServiceType
    extends Object
    The class ServiceType provides 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 and ResourceName used to compare the resources
    • Constructor Detail

      • ServiceType

        protected ServiceType​(String serviceName,
                              ServiceSchemaManager ssm,
                              ServiceSchema pschema)
        Constructor used by ServiceTypeManager to construct an instance of ServiceType,
        Parameters:
        serviceName - name of the service for which to construct ServiceType
        ssm - ServiceTypeManager to initialize the the ServiceType with
    • Method Detail

      • getResourceNameComparator

        public ResourceName getResourceNameComparator()
        Returns ResourceName used by this object
        Returns:
        ResourceName used 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 returns null. 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 returns null. 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 returned Set has 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 an InvalidActioNameException is 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 returned Map has 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
        Returns true if the action names and its values in the given Map are valid and satisfy the schema for the respective action names.
        Parameters:
        actionValues - a Map that contains action names as its "key" and a Set of action values as its "value" for the action name
        Returns:
        true if 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)
        Returns true is the service has the specified action name.
        Returns:
        true if the service has the action name false otherwise
      • compare

        protected ResourceMatch compare​(String resource1,
                                        String resource2)
        Compares two resources of this service type to determine their equality. The method returns a ResourceMatch object 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 1
        resource2 - resource name 2
        Returns:
        returns ResourceMatch that 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 a ResourceMatch object 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 1
        resource2 - resource name 2
        interpretWildCard - if true, wild cards in resource2 are interpreted. Else, the wildcards are escaped.
        Returns:
        returns ResourceMatch that 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 with
        subRes - 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 value
        superRes - 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()
        Returns true if the service has resource names.
        Returns:
        true if the service has resource names; false otherwise