8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: Conditions.java,v 1.4 2008/06/25 05:43:43 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted [2011] [ForgeRock AS]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.policy.interfaces.Condition;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>Conditions</code> provides methods to maintain
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a collection of <code>Condition</code> objects that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * apply to a <code>Policy</code>. This class provides methods to add, replace
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and remove <code>Condition</code> objects from this condition collection.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>Policy</code> object provides methods to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>Conditions</code>, which identifies conditions that apply
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to the policy
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster = Debug.getInstance(PolicyManager.POLICY_DEBUG_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * No argument constructor
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor used by <code>Policy</code> to obtain
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * an instance of <code>Conditions</code> from W3C DOM
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * representation of the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ctm <code>ConditionTypeManager</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * providing methods to handle the <code>Conditions</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param conditionsNode node that represents the Conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Conditions(ConditionTypeManager ctm, Node conditionsNode)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws InvalidFormatException, InvalidNameException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if the node name is PolicyManager.POLICY_CONDITIONS_NODE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (!conditionsNode.getNodeName().equalsIgnoreCase(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "invalid conditions xml blob given to construct conditions");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new InvalidFormatException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the conditions name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((name = XMLUtils.getNodeAttributeValue(conditionsNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster name = "Conditions:" + ServiceTypeManager.generateRandomName();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the description
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((description = XMLUtils.getNodeAttributeValue(conditionsNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PolicyManager.DESCRIPTION_ATTRIBUTE)) == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get individual conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator conditionNodes = XMLUtils.getChildNodes(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster conditionsNode, PolicyManager.CONDITION_POLICY).iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node conditionNode = (Node) conditionNodes.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String conditionType = XMLUtils.getNodeAttributeValue(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PolicyManager.debug.warning("condition type is null");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct the condition object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Condition condition = ctm.getCondition(conditionType);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get and set the properties
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster NodeList attrValuePairNodes = conditionNode.getChildNodes();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numAttrValuePairNodes = attrValuePairNodes.getLength();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int j = 0; j < numAttrValuePairNodes; j++) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node attrValuePairNode = attrValuePairNodes.item(j);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String name = XMLUtils.getNodeAttributeValue(attributeNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ( ( name != null ) && ( values != null ) ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the friendly name given to condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String conditionName = XMLUtils.getNodeAttributeValue(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Add the condition to conditions collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor to obtain an instance of <code>Conditions</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to hold collection of conditions represented as
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>Condition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name name for the collection of <code>Condition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param description user friendly description for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the collection of <code>Condition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Conditions(String name, String description) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ("Conditions:" + ServiceTypeManager.generateRandomName()) : name;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name for the collection of conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * represented as <code>Condition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return name of the collection of conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the description for the collection of conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * represented as <code>Condition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return description for the collection of conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the name for this instance of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>Conditions<code> which contains a collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of conditions respresented as <code>Condition</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name for the collection of conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ("Conditions:" + ServiceTypeManager.generateRandomName()) : name;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the description for this instance of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>Conditions</code> which contains a collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of conditions respresented as <code>Condition</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param description description for the collection conditions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setDescription(String description) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the names of <code>Condition</code> objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * contained in this object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return names of <code>Condition</code> contained in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * this object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the <code>Condition</code> object associated
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the given condition name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param conditionName name of the condition object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return condition object corresponding to condition name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @exception NameNotFoundException if a condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the given name is not present
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Condition getCondition(String conditionName)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Condition answer = (Condition) conditions.get(conditionName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new NameNotFoundException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster conditionName, PolicyException.CONDITION_COLLECTION));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds a <code>Condition</code> object to the this instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of condition collection. Since the name is not provided it
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be dynamically assigned such that it is unique within
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * this instance of the condition collection. However if a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * condition entry with the same name already exists in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * condition collection <code>NameAlreadyExistsException</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be thrown.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param condition instance of the condition object added to this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @exception NameAlreadyExistsException throw if a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * condition object is present with the same name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds a <code>Condition</code> object to the this instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of conditions collection. If another condition with the same
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * name already exists in the conditions collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>NameAlreadyExistsException</code> will be thrown.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param conditionName name for the condition instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param condition instance of the condition object added to this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @exception NameAlreadyExistsException if a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * condition object is present with the same name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addCondition(String conditionName, Condition condition)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new NameAlreadyExistsException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster conditionName, PolicyException.CONDITION_COLLECTION));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Replaces an existing condition object having the same name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the new one. If a <code>Condition</code> with the given
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * name does not exist, <code>NameNotFoundException</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be thrown.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param conditionName name for the condition instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param condition instance of the condition object that will
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * replace another condition object having the given name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @exception NameNotFoundException if a condition instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the given name is not present
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void replaceCondition(String conditionName, Condition condition)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new NameNotFoundException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster conditionName, PolicyException.CONDITION_COLLECTION));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the <code>Condition</code> object identified by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the condition name. If a condition instance with the given
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * name does not exist, the method will return silently.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param conditionName name of the condition instance that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be removed from the conditions collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the condition that was just removed
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Condition removeCondition(String conditionName) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (Condition)conditions.remove(conditionName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the <code>Condition</code> object identified by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * object's <code>equals</code> method. If a condition instance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * does not exist, the method will return silently.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param condition condition object that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be removed from the conditions collection
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the condition that was just removed
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Condition removeCondition(Condition condition) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String conditionName = getConditionName(condition);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (Condition) removeCondition(conditionName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name associated with the given condition object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * It uses the <code>equals</code> method on the condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to determine equality. If a condition instance that matches
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the given condition object is not present, the method
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * returns <code>null</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param condition condition object for which this method will
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * return its associated name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return user friendly name given to the condition object;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>null</code> if not present
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getConditionName(Condition condition) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = conditions.keySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (condition.equals(conditions.get(conditionName))) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if two <code>Conditions</code> are identical.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Two conditions (or conditions collections) are identical only
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if both have the same set of <code>Condition</code> objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param o object againt which this conditions object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will be checked for equality
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if all the conditions match;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>false</code> otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (o instanceof Conditions) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator iter = conditions.entrySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object ss = ((Map.Entry) iter.next()).getValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a new copy of this object with the identical
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * set of conditions collections (conditions).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a copy of this object with identical values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = conditions.keySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Condition condition = (Condition) conditions.get(item);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster answer.conditions.put(item, condition.clone());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks whether the effective result of conditions is an allow or deny.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The effective result is an allow only if each condition type of this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * contraint collection evaluates to allow, for the environment parameters
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * passed in env. When there are multiple condition elements in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * conditions collection, the condition evaluation logic does a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * logical or for the condition elements of the same type and does a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * logical and between sets of condition elements of different condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param token single sign on token of the user
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param env a map of key/value pairs containing any information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that could be used by each contraint to evaluate
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the effective result is an allow.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Otherwise <code>false</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws PolicyException if an error occured
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the token is invalid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isAllowed(SSOToken token, Map env)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getConditionDecision(token, env).isAllowed();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Gets result of evalutating the conditions.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The effective result is an allow only if each condition type of this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * contraint collection evaluates to allow, for the environment parameters
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * passed in env. When there are multiple condition elements in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * conditions collection, the condition evaluation logic does a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * logical or for the condition elements of the same type and does a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * logical and between sets of condition elements of different condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param token single sign on token of the user
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param env a map of key/value pairs containing any information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that could be used by each contraint to evaluate
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>result of evaluating the conditions</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws PolicyException if an error occured
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the token is invalid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ConditionDecision getConditionDecision(SSOToken token, Map env)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean allowed = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = conditions.entrySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster = ConditionTypeManager.conditionTypeName(condition);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean previousAllowed = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean previousValue = (Boolean) allowMap.get(conditionType);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster previousAllowed = previousValue.booleanValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ConditionDecision cd = condition.getConditionDecision(token, env);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster currentAllowed = currentAllowed || previousAllowed;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster allowMap.put(conditionType, Boolean.valueOf(currentAllowed));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ( (cdAdvices != null) && (!cdAdvices.isEmpty()) ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map advices = (Map) advicesMap.get(conditionType);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cdAdvices, (Map)advicesMap.get(conditionType));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ( !allowMap.containsValue(Boolean.FALSE) ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator conditionTypes = advicesMap.keySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String conditionType = (String) conditionTypes.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean result = (Boolean) allowMap.get(conditionType);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster DEBUG.message("At Conditions.getConditionDecision():allowed,"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "timeToLive, " + " advices=" + allowed +"," + timeToLive
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new ConditionDecision(allowed, timeToLive, effectiveAdvices);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns XML string representation of the condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (conditions collection) object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return xml string representation of this object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns XML string representation of the condition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (conditions collection) object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return xml string representation of this object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append("\n").append(CONDITIONS_ELEMENT_BEGIN)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(XMLUtils.escapeSpecialCharacters(name))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(XMLUtils.escapeSpecialCharacters(description))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = conditions.keySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Condition condition = (Condition) conditions.get(conditionName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(XMLUtils.escapeSpecialCharacters(conditionName))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ConditionTypeManager.conditionTypeName(condition)))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Add attribute values pairs
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ( (valueSet != null ) && (!valueSet.isEmpty()) ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append("\n").append(CONDITIONS_ELEMENT_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Places quotes around a string
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ( s == null ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the number of <code>Condition</code> elements in this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * </code>Conditions</code> object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the number of <code>Condition</code> elements in this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * </code>Conditions</code> object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Private variables to construct the XML document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITIONS_ELEMENT_BEGIN = "<Conditions name=\"";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITIONS_DESCRIPTION = "\" description=\"";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITIONS_ELEMENT_END = "</Conditions>";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITION_ELEMENT = "<Condition name=\"";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITION_TYPE = "\" type=\"";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String CONDITION_ELEMENT_END = "</Condition>";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String ATTR_VALUE_PAIR_BEGIN = "<AttributeValuePair>";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String ATTR_NAME_BEGIN = "<Attribute name=";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static String ATTR_VALUE_PAIR_END = "</AttributeValuePair>";