Class Conditions


  • public class Conditions
    extends Object
    The class Conditions provides methods to maintain a collection of Condition objects that apply to a Policy. This class provides methods to add, replace and remove Condition objects from this condition collection. The Policy object provides methods to set Conditions, which identifies conditions that apply to the policy
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Conditions​(ConditionTypeManager ctm, Node conditionsNode)
      Constructor used by Policy to obtain an instance of Conditions from W3C DOM representation of the object.
        Conditions​(String name, String description)
      Constructor to obtain an instance of Conditions to hold collection of conditions represented as Condition
    • Method Detail

      • getName

        public String getName()
        Returns the name for the collection of conditions represented as Condition
        Returns:
        name of the collection of conditions
      • getDescription

        public String getDescription()
        Returns the description for the collection of conditions represented as Condition
        Returns:
        description for the collection of conditions
      • setName

        public void setName​(String name)
        Sets the name for this instance of the Conditions which contains a collection of conditions respresented as Condition.
        Parameters:
        name - for the collection of conditions
      • setDescription

        public void setDescription​(String description)
        Sets the description for this instance of the Conditions which contains a collection of conditions respresented as Condition.
        Parameters:
        description - description for the collection conditions
      • getConditionNames

        public Set getConditionNames()
        Returns the names of Condition objects contained in this object.
        Returns:
        names of Condition contained in this object
      • getCondition

        public Condition getCondition​(String conditionName)
                               throws NameNotFoundException
        Returns the Condition object associated with the given condition name.
        Parameters:
        conditionName - name of the condition object
        Returns:
        condition object corresponding to condition name
        Throws:
        NameNotFoundException - if a condition with the given name is not present
      • addCondition

        public void addCondition​(Condition condition)
                          throws NameAlreadyExistsException
        Adds a Condition object to the this instance of condition collection. Since the name is not provided it will be dynamically assigned such that it is unique within this instance of the condition collection. However if a condition entry with the same name already exists in the condition collection NameAlreadyExistsException will be thrown.
        Parameters:
        condition - instance of the condition object added to this collection
        Throws:
        NameAlreadyExistsException - throw if a condition object is present with the same name
      • addCondition

        public void addCondition​(String conditionName,
                                 Condition condition)
                          throws NameAlreadyExistsException
        Adds a Condition object to the this instance of conditions collection. If another condition with the same name already exists in the conditions collection NameAlreadyExistsException will be thrown.
        Parameters:
        conditionName - name for the condition instance
        condition - instance of the condition object added to this collection
        Throws:
        NameAlreadyExistsException - if a condition object is present with the same name
      • replaceCondition

        public void replaceCondition​(String conditionName,
                                     Condition condition)
                              throws NameNotFoundException
        Replaces an existing condition object having the same name with the new one. If a Condition with the given name does not exist, NameNotFoundException will be thrown.
        Parameters:
        conditionName - name for the condition instance
        condition - instance of the condition object that will replace another condition object having the given name
        Throws:
        NameNotFoundException - if a condition instance with the given name is not present
      • removeCondition

        public Condition removeCondition​(String conditionName)
        Removes the Condition object identified by the condition name. If a condition instance with the given name does not exist, the method will return silently.
        Parameters:
        conditionName - name of the condition instance that will be removed from the conditions collection
        Returns:
        the condition that was just removed
      • removeCondition

        public Condition removeCondition​(Condition condition)
        Removes the Condition object identified by object's equals method. If a condition instance does not exist, the method will return silently.
        Parameters:
        condition - condition object that will be removed from the conditions collection
        Returns:
        the condition that was just removed
      • getConditionName

        public String getConditionName​(Condition condition)
        Returns the name associated with the given condition object. It uses the equals method on the condition to determine equality. If a condition instance that matches the given condition object is not present, the method returns null.
        Parameters:
        condition - condition object for which this method will return its associated name
        Returns:
        user friendly name given to the condition object; null if not present
      • equals

        public boolean equals​(Object o)
        Checks if two Conditions are identical. Two conditions (or conditions collections) are identical only if both have the same set of Condition objects.
        Overrides:
        equals in class Object
        Parameters:
        o - object againt which this conditions object will be checked for equality
        Returns:
        true if all the conditions match; false otherwise
      • clone

        public Object clone()
        Returns a new copy of this object with the identical set of conditions collections (conditions).
        Overrides:
        clone in class Object
        Returns:
        a copy of this object with identical values
      • isAllowed

        public boolean isAllowed​(SSOToken token,
                                 Map env)
                          throws PolicyException,
                                 SSOException
        Checks whether the effective result of conditions is an allow or deny. The effective result is an allow only if each condition type of this contraint collection evaluates to allow, for the environment parameters passed in env. When there are multiple condition elements in the conditions collection, the condition evaluation logic does a logical or for the condition elements of the same type and does a logical and between sets of condition elements of different condition types
        Parameters:
        token - single sign on token of the user
        env - a map of key/value pairs containing any information that could be used by each contraint to evaluate the allow/deny result
        Returns:
        true if the effective result is an allow. Otherwise false.
        Throws:
        PolicyException - if an error occured
        SSOException - if the token is invalid
      • toString

        public String toString()
        Returns XML string representation of the condition (conditions collection) object.
        Overrides:
        toString in class Object
        Returns:
        xml string representation of this object
      • toXML

        protected String toXML()
        Returns XML string representation of the condition (conditions collection) object.
        Returns:
        xml string representation of this object