public class Apply extends Object implements Evaluatable
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 Expression
s 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.
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
String |
encode()
Encodes this
Apply into its XML form |
void |
encode(StringBuilder builder)
Encodes this
Apply into its XML form and writes this out to the provided
StringBuilder |
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. |
public Apply(Function function, List xprs) throws IllegalArgumentException
Apply
instance.function
- the Function
to use in evaluating the elements in the applyxprs
- the contents of the apply which will be the parameters to the function, each of
which is an Expression
IllegalArgumentException
- if the input expressions don't match the signature of the
functionpublic Apply(Function function, List xprs, boolean isCondition) throws IllegalArgumentException
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.Apply
instance.function
- the Function
to use in evaluating the elements in the applyxprs
- 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 falseIllegalArgumentException
- if the input expressions don't match the signature of the
function or if isCondition
is truepublic static Apply getConditionInstance(Node root, String xpathVersion, VariableManager manager) throws ParsingException
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
.
root
- the DOM root of a ConditionType XML typexpathVersion
- 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
parsingParsingException
- if this is not a valid ConditionTypepublic static Apply getConditionInstance(Node root, String xpathVersion) throws ParsingException
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.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.root
- the DOM root of a ConditionType XML typexpathVersion
- 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)ParsingException
- if this is not a valid ConditionTypepublic static Apply getInstance(Node root, PolicyMetaData metaData, VariableManager manager) throws ParsingException
Apply
based on the given DOM root.root
- the DOM root of an ApplyType XML typemetaData
- the meta-data associated with the containing policymanager
- VariableManager
used to connect references and definitions while
parsingParsingException
- if this is not a valid ApplyTypepublic static Apply getInstance(Node root, String xpathVersion) throws ParsingException
VariableManager
. This will return an Apply
instance for XACML 1.x policies.Apply
based on the given DOM root.root
- the DOM root of an ApplyType XML typexpathVersion
- 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)ParsingException
- if this is not a valid ApplyTypepublic Function getFunction()
Function
used by this Apply
.Function
public List getChildren()
List
of children for this Apply
. The List
contains Expression
s. The list is unmodifiable, and may be empty.getChildren
in interface Evaluatable
List
of Expression
spublic boolean isCondition()
Apply
is never a
Condition.public EvaluationResult evaluate(EvaluationCtx context)
Apply
objects.evaluate
in interface Evaluatable
context
- the representation of the requestpublic URI getType()
evaluate
. In practice, this will always be the same as the result of calling
getReturnType
on the function used by this object.getType
in interface Expression
evaluate
public boolean returnsBag()
Function
will return a bag of values on evaluation.returnsBag
in interface Expression
public boolean evaluatesToBag()
returnsBag
method from the
super-interface Expression
.Function
will return a bag of values on evaluation.evaluatesToBag
in interface Evaluatable
public String encode()
Apply
into its XML formString
public void encode(StringBuilder builder)
Apply
into its XML form and writes this out to the provided
StringBuilder
encode
in interface Expression
builder
- string stream into which the XML-encoded data is writtenCopyright © 2021 WSO2. All rights reserved.