/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: PolicyDecision.java,v 1.3 2008/06/25 05:43:44 qcheng Exp $
*
* Portions Copyrighted 2011-2014 ForgeRock AS.
*/
/**
* The <code>PolicyDecision</code> class represents the result of a policy
* evaluation.
*
* @supported.api
* @deprecated since 12.0.0
*/
public class PolicyDecision {
//added in 7.0 for attributes provided by policy response providers
private boolean advicesAreSet = false;
/**
* Default constructor.
* @supported.api
*/
public PolicyDecision() {
}
/**
* Gets the <code>Map</code> of action decisions associated
* with this policy decision. The
* action name is the key to the Map. The value for each key is an
* <code>ActionDecision</code>.
*
* @return the <code>Map</code> of action decisions associated
* with this policy decision. The
* action name is the key to the Map. The value for each key is an
* <code>ActionDecision</code>.
* @supported.api
*/
return actionDecisions;
}
/**
* Add an <code>ActionDecision</code> to the <code>PolicyDecision</code>
* These are the rules followed to add action decision:
* If the action schema has boolean syntax, boolean false value
* overrides boolean true value. The time to live of boolean false
* value overrides the time to live of boolean true value.
* Otherwise, action values are simply aggregated. Time to live
* is set to the minimum of time to live(s) of all values of the
* action.
*
* @param newActionDecision an <code>ActionDecision</code> to be added.
* @param resourceType <code>ServiceType</code> representing the
* service which provides the schema for the action.
*
*/
resourceType) {
if ( oldActionDecision == null ) {
} else {
try {
} catch(InvalidNameException e) {
"can not find action schmea for action = "
+ action, e );
}
actionSyntax)) {
} else { //boolean valued action
}
}
}
/**
* Add an <code>ActionDecision</code> to the <code>PolicyDecision</code>
* using the provided <code>trueValue</code> and <code>falseValue</code>
* These are the rules followed to add action decision:
* Boolean false value overrides boolean true value. The time to live
* of boolean false value overrides the time to live of boolean true value.
* Otherwise, action values are simply aggregated. Time to live
* is set to the minimum of time to live(s) of all values of the
* action.
*
* @param newActionDecision an <code>ActionDecision</code> to be added.
* @param trueValue <code>String</code> representing the </code>true</code>
* value in the action schema.
* @param falseValue <code>String</code> representing the
* </code>false</code> value in the action schema.
*
*/
if ( (oldActionDecision == null)
} else { //boolean valued action
if ( (oldActionValues != null)
if ( (newActionValues != null)
//both old and new values are false
//get the ttl to max of newTtl and oldTtl
}
/* else block not required here since
oldActionDecision does not need to change as it is false
and newActionDecision is null or true
*/
} else if ( (oldActionValues != null)
if ( (newActionValues != null)
//get the ttl to max of newTtl and oldTtl
}
} else {
}
}
}
/**
* Adds an action decision to this object
* if there is already an existing actionDecision associated with the
* action name in the param <code>actionDecision</code>, merges
* the values of the new decision with the existing one,
* changing the time to live for the decision appropriately.
*
* @param actionDecision action decision to be added
* @supported.api
*/
if ( oldDecision == null ) {
} else {
} else {
}
if ( actionDecision.getTimeToLive()
< oldDecision.getTimeToLive() ) {
}
}
}
/**
* Gets a String representation of this <code>PolicyDecision</code>
* @return a String representation of this <code>PolicyDecision</code>
*
* @supported.api
*/
if ((responseAttributes != null) &&
}
}
while ( actionNames.hasNext() ) {
}
}
/**
* Gets an XML representation of this object
* @return an XML representation of this object
*
* @supported.api
*/
/*
.append(" ").append("timeToLive")
.append("=\"").append(timeToLive).append("\"")
.append(" ").append("hasAdvices")
.append("=\"").append(hasAdvices()).append("\"")
*/
if ((responseAttributes != null) &&
}
while ( actionNames.hasNext() ) {
}
if (responseDecisions != null) {
}
}
/**
* Gets a PolicyDecision given corresponding XML node
* @param policyDecisionNode XML node for the policy decision
* @return policy decision based on the XML node
*/
throws PolicyException
{
+ "not found in policy decision node:"
} else {
}
}
}
}
return policyDecision;
}
/**
*
* Gets response decisions associated with this policy decision
* @return <code>Map</code> representing the response decisions associated
* with this policy decision
*
*/
return responseDecisions;
}
/**
*
* Sets response decisions associated with this policy decision
* @param responseDecisions A <code>Map</code> representing response
* decisions associated with this policy decision
*/
this.responseDecisions = responseDecisions;
}
/**
*
* Gets response attributes associated with this policy decision.
* Response attributes are computed as an aggregation of the return
* <code>Map</code>(s) of the <code>ResponseProvider</code> objects
* associated with the policy obtained via the getResponseDecision() call.
* @return the <code>Map</code> of response attributes associated with
* this policy decision.
*
*/
return responseAttributes;
}
/**
*
* Sets response attributes associated with this policy decision
* @param responseAttributes <code>Map</code> of attribute value pairs
* associated with this policy decision.
*/
this.responseAttributes = responseAttributes;
}
/**
* Makes a copy of this object
*
* @return a copied instance
*/
while (actionDecisionIter.hasNext()) {
}
if (responseDecisions != null) {
while (responseDecisionsIter.hasNext()) {
}
}
if (responseAttributes != null) {
while (responseAttributesIter.hasNext()) {
}
}
return clone;
}
/**
* Gets the GMT time in milliseconds since epoch when this object is to
* be treated as expired. That is the policy decision would likely
* be different after that time.
* This is computed as a result of <code>SimpleTimeCondition</code>s
* specified in the <code>Policy</code> definition.
*
* @return time to live
*/
public long getTimeToLive() {
return timeToLive;
}
/**
* Sets the <code>timeToLive</code> value of the policy decision to the
* smallest of <code>timeToLive(s)<code> of contained
* <code>ActionDecision(s)<code>. Also sets value of
* <code>advicesAreSet</code>. This is set to <code>true</code>
* if any of the contained action decision(s) has advice defined.
*/
private void setTimeToLive() {
advicesAreSet = false;
while (actionDecisionIter.hasNext()) {
if ( actionTtl < timeToLive) {
}
}
}
/**
* Sets the timeToLive value of the policy decision.
*
* @param ttl timeToLive value to be set
*/
timeToLive = ttl;
}
/**
* Checks wether advices are set in this object
* @return <code>true</code>, if advices are set, else <code>false</code>
*/
public boolean hasAdvices() {
return advicesAreSet;
}
}