Class Rule

  • All Implemented Interfaces:
    Cloneable

    @Deprecated
    public class Rule
    extends Object
    implements Cloneable
    Deprecated.
    since 12.0.0
    The class Rule provides interfaces to manage a rule that can be added to a policy. A rule constains the rule name, service type, a resource and a map containing action names and action values.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Rule()
      Deprecated.
      Contruct a Rule.
        Rule​(String ruleName, String serviceName, String resourceName, Map actions)
      Deprecated.
      Constructor to create a rule object with rule name, service name, resource name and actions.
        Rule​(String serviceName, String resourceName, Map actions)
      Deprecated.
      Constructor to create a rule object with the service name, resource name and actions.
        Rule​(String serviceName, Map actions)
      Deprecated.
      Constructor to create a rule object with the service name and actions.
      protected Rule​(Node ruleNode)
      Deprecated.
      Constructor to create a Rule object from a XML Node.
    • Field Detail

    • Constructor Detail

      • Rule

        protected Rule()
        Deprecated.
        Contruct a Rule.
      • Rule

        public Rule​(String serviceName,
                    String resourceName,
                    Map actions)
             throws NameNotFoundException,
                    InvalidNameException
        Deprecated.
        Constructor to create a rule object with the service name, resource name and actions. The actions provided as a Map must have the action name as key and a Set of Strings as its value. The action names and action values must conform to the schema specified for the service. Otherwise, InvalidNameException is thrown. The parameters ruleName and resourceName can be null.
        Parameters:
        serviceName - name of the service type as defined by the service schema
        resourceName - name of the resource for the service type
        actions - map of action and action values for the resource
        Throws:
        NameNotFoundException - the service name provided does not exist
        InvalidNameException - the resource name, action name, or values is not valid
      • Rule

        public Rule​(String serviceName,
                    Map actions)
             throws NameNotFoundException,
                    InvalidNameException
        Deprecated.
        Constructor to create a rule object with the service name and actions. This is useful for services (and possibly action names) that do not have resource names. The actions provided as a Map must have the action name as it key and a Set of Strings as its value. The action names and action values must conform to the schema specified for the service. Otherwise, InvalidNameException is thrown. The parameters ruleName and resourceName can be null.
        Parameters:
        serviceName - name of the service type as defined by the service schema
        actions - map of action and action values for the resource
        Throws:
        NameNotFoundException - the service name provided does not exist
        InvalidNameException - the resource name, action name, or values is not valid
      • Rule

        public Rule​(String ruleName,
                    String serviceName,
                    String resourceName,
                    Map actions)
             throws NameNotFoundException,
                    InvalidNameException
        Deprecated.
        Constructor to create a rule object with rule name, service name, resource name and actions. The actions provided as a Map must have the action name as it key and a Set of Strings as its value. The action names and action values must conform to the service schema. Otherwise, InvalidNameException is thrown. The parameters ruleName and resourceName can be null.
        Parameters:
        ruleName - name of the rule
        serviceName - name of the service type as defined by the service schema
        resourceName - name of the resource for the service type
        actions - map of action and action values for the resource
        Throws:
        NameNotFoundException - the service name provided does not exist
        InvalidNameException - the resource name, action name, or values is not valid
    • Method Detail

      • setApplicationName

        public void setApplicationName​(String applicationName)
        Deprecated.
        Sets application Name.
        Parameters:
        applicationName - Application name.
      • getApplicationName

        public String getApplicationName()
        Deprecated.
        Returns application name.
        Returns:
        application name.
      • getName

        public String getName()
        Deprecated.
        Returns the name assigned to the rule. It could be null if it was not constructed with a name.
        Returns:
        rule name
      • setName

        public void setName​(String ruleName)
                     throws InvalidNameException
        Deprecated.
        Sets the name for the rule. If a name has already been assigned, it will be replaced with the given name.
        Parameters:
        ruleName - rule name.
        Throws:
        InvalidNameException - if rule name is invalid.
      • getServiceTypeName

        public String getServiceTypeName()
        Deprecated.
        Returns the service name for which the rule has been created. The service name of the rule cannot be changed once the rule is created.
        Returns:
        service name
      • getResourceName

        public String getResourceName()
        Deprecated.
        Returns the resource name for which the rule has been created. If the service does not support resource names, the method will return null. The resource name of the rule cannot be changed once the rule is created.
        Returns:
        resource name
      • getResourceNames

        public Set<String> getResourceNames()
        Deprecated.
        Returns the resource names for which the rule has been created. If the service does not support resource names, the method will return null. The resource name of the rule cannot be changed once the rule is created.
        Returns:
        resource name
      • setResourceNames

        public void setResourceNames​(Set<String> resourceNames)
        Deprecated.
        Sets the resource names for which the rule has been created. If the service does not support resource names, the method will return null. The resource name of the rule cannot be changed once the rule is created.
        Parameters:
        resourceNames - resource name
      • getActionNames

        public Set getActionNames()
        Deprecated.
        Returns the action names that have been set for the rule. The action names returned could be the same as the service's action names or a subset of it.
        Returns:
        action names defined in this rule for the service
      • getActionValues

        public Set getActionValues​(String actionName)
                            throws NameNotFoundException
        Deprecated.
        Returns a set of action values that have been set for the specified action name.
        Parameters:
        actionName - action name for which to compute values.
        Returns:
        action names defined in this rule for the service
        Throws:
        NameNotFoundException - if actions name is not found in the rule
      • getActionValues

        public Map getActionValues()
        Deprecated.
        Returns a Map of all action names and their corresponding action values that have been set in the rule. The "key" of the Map will be the action name as a string, and its "value" will be a Set which contains the action values as strings.
        Returns:
        all action names and corresponding action values
      • setActionValues

        public void setActionValues​(Map actionValues)
                             throws InvalidNameException
        Deprecated.
        Sets the action names and their corresponding actions values (or permissions) for the resource or the service.
        Parameters:
        actionValues - action names and their corresponding values
        Throws:
        InvalidNameException - if action name is invalid.
      • equals

        public boolean equals​(Object obj)
        Deprecated.
        Checks if two rule objects are identical. Two rules are identical only if the service name, resource name, action name and values match.
        Overrides:
        equals in class Object
        Parameters:
        obj - object against which this rule object will be checked for equality
        Returns:
        true if the service type, resource, actions and action values match, false otherwise.
      • hashCode

        public int hashCode()
        Deprecated.
        This added by when CheckStyle noticed there was an implementation of equals without an implementation of hashCode - usually a recipe for disaster.
        Overrides:
        hashCode in class Object
        Returns:
        the hashCode for this object
      • isResourceMatch

        public ResourceMatch isResourceMatch​(String serviceName,
                                             String resourceName)
        Deprecated.
        Compares the given service and resource names with the service and resource name specified in this rule. 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. If the service name does not match, the method returns NO_MATCH.
        Parameters:
        serviceName - name of the service
        resourceName - name of the resource
        Returns:
        returns ResourceMatch that specifies if the service name and resource name are exact match, or otherwise.
      • toXML

        public String toXML()
        Deprecated.
        Returns an XML string representing the rule.
        Returns:
        an XML string representing the rule.
      • getServiceType

        protected ServiceType getServiceType()
        Deprecated.
        Returns service type of this rules.
        Returns:
        service type of this rule
      • toResourcesXml

        protected String toResourcesXml​(String policyName)
        Deprecated.
        Returns an XML respresentation of the rule with policy name to use in resource index tree.
        Parameters:
        policyName - policy name to use while creating xml representation
        Returns:
        an XML respresentation of the rule with policy name to use in resource index tree
      • toString

        public String toString()
        Deprecated.
        Returns xml string representation of the rule.
        Overrides:
        toString in class Object
        Returns:
        xml string representation of the rule
      • clone

        public Object clone()
        Deprecated.
        Creates and returns a copy of this object. The returned Rule object will have the same rule name, resource, service name, and actions such that x.clone().equals(x) will be true. However x.clone() will not be the same as x, i.e., x.clone() != x.
        Overrides:
        clone in class Object
        Returns:
        a copy of this object