JBoss port of sunxacml 2.0.5

org.jboss.security.xacml.sunxacml.cond
Class Apply

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.cond.Apply
All Implemented Interfaces:
Evaluatable, Expression

public class Apply
extends Object
implements Evaluatable

Represents the XACML ApplyType and ConditionType XML types.

Note well: as of 2.0, there is no longer a notion of a separate higher- order bag function. Instead, if needed, it is supplied as one of the Expressions in the parameter list. As such, when this Apply is evaluated, it no longer pre-evaluates all the parameters if a bag function is used. It is now up to the implementor of a higher-order function to do this.

Also, as of 2.0, the Apply is no longer used to represent a Condition, since the XACML 2.0 specification changed how Condition works. Instead, there is now a Condition class that represents both 1.x and 2.0 style Conditions.

Since:
1.0
Author:
Seth Proctor

Field Summary
protected static Logger logger
           
 
Constructor Summary
Apply(Function function, List xprs)
          Constructs an Apply instance.
Apply(Function function, List xprs, boolean isCondition)
          Deprecated. As of 2.0 Apply is no longer used for Conditions, so the isCondition parameter is no longer needed. You should now use the 2 parameter constructor. This constructor will be removed in a future release.
 
Method Summary
 void encode(OutputStream output)
          Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with indentation.
 EvaluationResult evaluate(EvaluationCtx context)
          Evaluates the apply object using the given function.
 boolean evaluatesToBag()
          Deprecated. As of 2.0, you should use the returnsBag method from the super-interface Expression.
 List getChildren()
          Returns the List of children for this Apply.
static Apply getConditionInstance(Node root, String xpathVersion)
          Deprecated. As of 2.0 you should avoid using this method, since it does not provide a Condition instance and does not handle XACML 2.0 policies correctly. If you need a similar method you can use the new version that accepts a VariableManager. This will return an Apply instance for XACML 1.x policies.
static Apply getConditionInstance(Node root, String xpathVersion, VariableManager manager)
          Returns an instance of an Apply based on the given DOM root node.
 Function getFunction()
          Returns the Function used by this Apply.
static Apply getInstance(Node root, PolicyMetaData metaData, VariableManager manager)
          Returns an instance of Apply based on the given DOM root.
static Apply getInstance(Node root, String xpathVersion)
          Deprecated. As of 2.0 you should avoid using this method, since it does not handle XACML 2.0 policies correctly. If you need a similar method you can use the new version that accepts a VariableManager. This will return an Apply instance for XACML 1.x policies.
 URI getType()
          Returns the type of attribute that this object will return on a call to evaluate.
 boolean isCondition()
          Deprecated. As of 2.0 this method should not be used, since an Apply is never a Condition.
 boolean returnsBag()
          Returns whether or not the Function will return a bag of values on evaluation.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger
Constructor Detail

Apply

public Apply(Function function,
             List xprs)
      throws IllegalArgumentException
Constructs an Apply instance.

Parameters:
function - the Function to use in evaluating the elements in the apply
xprs - the contents of the apply which will be the parameters to the function, each of which is an Expression
Throws:
IllegalArgumentException - if the input expressions don't match the signature of the function

Apply

public Apply(Function function,
             List xprs,
             boolean isCondition)
      throws IllegalArgumentException
Deprecated. As of 2.0 Apply is no longer used for Conditions, so the isCondition parameter is no longer needed. You should now use the 2 parameter constructor. This constructor will be removed in a future release.

Constructs an Apply instance.

Parameters:
function - the Function to use in evaluating the elements in the apply
xprs - the contents of the apply which will be the parameters to the function, each of which is an Expression
isCondition - as of 2.0, this must always be false
Throws:
IllegalArgumentException - if the input expressions don't match the signature of the function or if isCondition is true
Method Detail

getConditionInstance

public static Apply getConditionInstance(Node root,
                                         String xpathVersion,
                                         VariableManager manager)
                                  throws ParsingException
Returns an instance of an Apply based on the given DOM root node. This will actually return a special kind of Apply, namely an XML ConditionType, which is the root of the condition logic in a RuleType. A ConditionType is the same as an ApplyType except that it must use a FunctionId that returns a boolean value.

Note that as of 2.0 there is a separate Condition class used to support the different kinds of Conditions in XACML 1.x and 2.0. As such, the system no longer treats a ConditionType as a special kind of ApplyType. You may still use this method to get a 1.x style ConditionType, but you will need to convert it into a Condition to use it in evaluation. The preferred way to create a Condition is now through the getInstance method on Condition.

Parameters:
root - the DOM root of a ConditionType XML type
xpathVersion - the XPath version to use in any selectors or XPath functions, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
manager - VariableManager used to connect references and definitions while parsing
Throws:
ParsingException - if this is not a valid ConditionType

getConditionInstance

public static Apply getConditionInstance(Node root,
                                         String xpathVersion)
                                  throws ParsingException
Deprecated. As of 2.0 you should avoid using this method, since it does not provide a Condition instance and does not handle XACML 2.0 policies correctly. If you need a similar method you can use the new version that accepts a VariableManager. This will return an Apply instance for XACML 1.x policies.

Returns an instance of an Apply based on the given DOM root node. This will actually return a special kind of Apply, namely an XML ConditionType, which is the root of the condition logic in a RuleType. A ConditionType is the same as an ApplyType except that it must use a FunctionId that returns a boolean value.

Parameters:
root - the DOM root of a ConditionType XML type
xpathVersion - the XPath version to use in any selectors or XPath functions, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
Throws:
ParsingException - if this is not a valid ConditionType

getInstance

public static Apply getInstance(Node root,
                                PolicyMetaData metaData,
                                VariableManager manager)
                         throws ParsingException
Returns an instance of Apply based on the given DOM root.

Parameters:
root - the DOM root of an ApplyType XML type
metaData - the meta-data associated with the containing policy
manager - VariableManager used to connect references and definitions while parsing
Throws:
ParsingException - if this is not a valid ApplyType

getInstance

public static Apply getInstance(Node root,
                                String xpathVersion)
                         throws ParsingException
Deprecated. As of 2.0 you should avoid using this method, since it does not handle XACML 2.0 policies correctly. If you need a similar method you can use the new version that accepts a VariableManager. This will return an Apply instance for XACML 1.x policies.

Returns an instance of Apply based on the given DOM root.

Parameters:
root - the DOM root of an ApplyType XML type
xpathVersion - the XPath version to use in any selectors or XPath functions, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
Throws:
ParsingException - if this is not a valid ApplyType

getFunction

public Function getFunction()
Returns the Function used by this Apply.

Returns:
the Function

getChildren

public List getChildren()
Returns the List of children for this Apply. The List contains Expressions. The list is unmodifiable, and may be empty.

Specified by:
getChildren in interface Evaluatable
Returns:
a List of Expressions

isCondition

public boolean isCondition()
Deprecated. As of 2.0 this method should not be used, since an Apply is never a Condition.

Returns whether or not this ApplyType is actually a ConditionType. As of 2.0 this always returns false;

Returns:
false

evaluate

public EvaluationResult evaluate(EvaluationCtx context)
Evaluates the apply object using the given function. This will in turn call evaluate on all the given parameters, some of which may be other Apply objects.

Specified by:
evaluate in interface Evaluatable
Parameters:
context - the representation of the request
Returns:
the result of trying to evaluate this apply object

getType

public URI getType()
Returns the type of attribute that this object will return on a call to evaluate. In practice, this will always be the same as the result of calling getReturnType on the function used by this object.

Specified by:
getType in interface Expression
Returns:
the type returned by evaluate

returnsBag

public boolean returnsBag()
Returns whether or not the Function will return a bag of values on evaluation.

Specified by:
returnsBag in interface Expression
Returns:
true if evaluation will return a bag of values, false otherwise

evaluatesToBag

public boolean evaluatesToBag()
Deprecated. As of 2.0, you should use the returnsBag method from the super-interface Expression.

Returns whether or not the Function will return a bag of values on evaluation.

Specified by:
evaluatesToBag in interface Evaluatable
Returns:
true if evaluation will return a bag of values, false otherwise

encode

public void encode(OutputStream output)
Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with no indentation.

Specified by:
encode in interface Expression
Parameters:
output - a stream into which the XML-encoded data is written

encode

public void encode(OutputStream output,
                   Indenter indenter)
Encodes this Apply into its XML representation and writes this encoding to the given OutputStream with indentation.

Specified by:
encode in interface Expression
Parameters:
output - a stream into which the XML-encoded data is written
indenter - an object that creates indentation strings

toString

public String toString()
Overrides:
toString in class Object

JBoss port of sunxacml 2.0.5

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.