Package com.sun.identity.policy
Class Conditions
- java.lang.Object
-
- com.sun.identity.policy.Conditions
-
public class Conditions extends Object
The classConditionsprovides methods to maintain a collection ofConditionobjects that apply to aPolicy. This class provides methods to add, replace and removeConditionobjects from this condition collection. ThePolicyobject provides methods to setConditions, which identifies conditions that apply to the policy
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConditions(ConditionTypeManager ctm, Node conditionsNode)Constructor used byPolicyto obtain an instance ofConditionsfrom W3C DOM representation of the object.Conditions(String name, String description)Constructor to obtain an instance ofConditionsto hold collection of conditions represented asCondition
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCondition(Condition condition)Adds aConditionobject to the this instance of condition collection.voidaddCondition(String conditionName, Condition condition)Adds aConditionobject to the this instance of conditions collection.Objectclone()Returns a new copy of this object with the identical set of conditions collections (conditions).booleanequals(Object o)Checks if twoConditionsare identical.ConditiongetCondition(String conditionName)Returns theConditionobject associated with the given condition name.StringgetConditionName(Condition condition)Returns the name associated with the given condition object.SetgetConditionNames()Returns the names ofConditionobjects contained in this object.StringgetDescription()Returns the description for the collection of conditions represented asConditionStringgetName()Returns the name for the collection of conditions represented asConditionbooleanisAllowed(SSOToken token, Map env)Checks whether the effective result of conditions is an allow or deny.ConditionremoveCondition(Condition condition)Removes theConditionobject identified by object'sequalsmethod.ConditionremoveCondition(String conditionName)Removes theConditionobject identified by the condition name.voidreplaceCondition(String conditionName, Condition condition)Replaces an existing condition object having the same name with the new one.voidsetDescription(String description)Sets the description for this instance of theConditionswhich contains a collection of conditions respresented asCondition.voidsetName(String name)Sets the name for this instance of theConditionswhich contains a collection of conditions respresented asCondition.StringtoString()Returns XML string representation of the condition (conditions collection) object.protected StringtoXML()Returns XML string representation of the condition (conditions collection) object.
-
-
-
Constructor Detail
-
Conditions
protected Conditions(ConditionTypeManager ctm, Node conditionsNode) throws InvalidFormatException, InvalidNameException, NameNotFoundException, PolicyException
Constructor used byPolicyto obtain an instance ofConditionsfrom W3C DOM representation of the object.- Parameters:
ctm-ConditionTypeManagerproviding methods to handle theConditions.conditionsNode- node that represents the Conditions- Throws:
InvalidFormatExceptionInvalidNameExceptionNameNotFoundExceptionPolicyException
-
-
Method Detail
-
getName
public String getName()
Returns the name for the collection of conditions represented asCondition- Returns:
- name of the collection of conditions
-
getDescription
public String getDescription()
Returns the description for the collection of conditions represented asCondition- Returns:
- description for the collection of conditions
-
setName
public void setName(String name)
Sets the name for this instance of theConditionswhich contains a collection of conditions respresented asCondition.- Parameters:
name- for the collection of conditions
-
setDescription
public void setDescription(String description)
Sets the description for this instance of theConditionswhich contains a collection of conditions respresented asCondition.- Parameters:
description- description for the collection conditions
-
getConditionNames
public Set getConditionNames()
Returns the names ofConditionobjects contained in this object.- Returns:
- names of
Conditioncontained in this object
-
getCondition
public Condition getCondition(String conditionName) throws NameNotFoundException
Returns theConditionobject 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 aConditionobject 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 collectionNameAlreadyExistsExceptionwill 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 aConditionobject to the this instance of conditions collection. If another condition with the same name already exists in the conditions collectionNameAlreadyExistsExceptionwill be thrown.- Parameters:
conditionName- name for the condition instancecondition- 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 aConditionwith the given name does not exist,NameNotFoundExceptionwill be thrown.- Parameters:
conditionName- name for the condition instancecondition- 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 theConditionobject 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 theConditionobject identified by object'sequalsmethod. 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 theequalsmethod on the condition to determine equality. If a condition instance that matches the given condition object is not present, the method returnsnull.- Parameters:
condition- condition object for which this method will return its associated name- Returns:
- user friendly name given to the condition object;
nullif not present
-
equals
public boolean equals(Object o)
Checks if twoConditionsare identical. Two conditions (or conditions collections) are identical only if both have the same set ofConditionobjects.
-
clone
public Object clone()
Returns a new copy of this object with the identical set of conditions collections (conditions).
-
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 userenv- a map of key/value pairs containing any information that could be used by each contraint to evaluate the allow/deny result- Returns:
trueif the effective result is an allow. Otherwisefalse.- Throws:
PolicyException- if an error occuredSSOException- if the token is invalid
-
toString
public String toString()
Returns XML string representation of the condition (conditions collection) object.
-
toXML
protected String toXML()
Returns XML string representation of the condition (conditions collection) object.- Returns:
- xml string representation of this object
-
-