org.wso2.balana.attr.xacml3
Class AttributeSelector

java.lang.Object
  extended by org.wso2.balana.attr.AbstractAttributeSelector
      extended by org.wso2.balana.attr.xacml3.AttributeSelector
All Implemented Interfaces:
Evaluatable, Expression

public class AttributeSelector
extends AbstractAttributeSelector

Supports the standard selector functionality in XACML 3.0 version, which uses XPath expressions to resolve values from the Request or elsewhere. All selector queries are done by AttributeFinderModules so that it's easy to plugin different XPath implementations.


Field Summary
 
Fields inherited from class org.wso2.balana.attr.AbstractAttributeSelector
mustBePresent, type, xpathVersion
 
Constructor Summary
AttributeSelector(URI category, URI type, URI contextSelectorId, String path, boolean mustBePresent, String xpathVersion)
          Creates a new AttributeSelector.
 
Method Summary
 void encode(StringBuilder builder)
          Encodes this AttributeValue into its XML representation and writes this encoding to the given StringBuilder This will always produce the version used in a policy rather than that used in a request, so this is equivalent to calling encodeWithTags(true) and then stuffing that into a stream.
 EvaluationResult evaluate(EvaluationCtx context)
          Invokes the AttributeFinder used by the given EvaluationCtx to try to resolve an attribute value.
 boolean evaluatesToBag()
          Tells whether evaluation will return a bag or a single value.
 List getChildren()
          Returns all children, in order, of this element in the Condition tree, or en empty set if this element has no children.
static AttributeSelector getInstance(Node root, PolicyMetaData metaData)
          Creates a new AttributeSelector based on the DOM root of the XML type.
 boolean returnsBag()
          Returns whether or not this expression returns, or evaluates to a Bag.
 
Methods inherited from class org.wso2.balana.attr.AbstractAttributeSelector
getType, getXPathVersion, isMustBePresent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeSelector

public AttributeSelector(URI category,
                         URI type,
                         URI contextSelectorId,
                         String path,
                         boolean mustBePresent,
                         String xpathVersion)
Creates a new AttributeSelector.

Parameters:
category - category of the attribute select
type - the data type of the attribute values this selector looks for
contextSelectorId - XPath search for context node
path - the XPath to query attribute
mustBePresent - must resolution find a match
xpathVersion - the XPath version to use, which must be a valid XPath version string (the identifier for XPath 1.0 is provided in PolicyMetaData)
Method Detail

getInstance

public static AttributeSelector getInstance(Node root,
                                            PolicyMetaData metaData)
                                     throws ParsingException
Creates a new AttributeSelector based on the DOM root of the XML type. Note that as of XACML 1.1 the XPathVersion element is required in any policy that uses a selector, so if the xpathVersion string is null, then this will throw an exception.

Parameters:
root - the root of the DOM tree for the XML AttributeSelectorType XML type
metaData - the meta-data associated with the containing policy
Returns:
an AttributeSelector
Throws:
ParsingException - if the AttributeSelectorType was invalid

evaluate

public EvaluationResult evaluate(EvaluationCtx context)
Invokes the AttributeFinder used by the given EvaluationCtx to try to resolve an attribute value. If the selector is defined with MustBePresent as true, then failure to find a matching value will result in Indeterminate, otherwise it will result in an empty bag. To support the basic selector functionality defined in the XACML specification, use a finder that has only the SelectorModule as a module that supports selector finding.

Parameters:
context - representation of the request to search
Returns:
a result containing a bag either empty because no values were found or containing at least one value, or status associated with an Indeterminate result

evaluatesToBag

public boolean evaluatesToBag()
Description copied from interface: Evaluatable
Tells whether evaluation will return a bag or a single value.

Returns:
true if evaluation will return a bag, false otherwise

getChildren

public List getChildren()
Description copied from interface: Evaluatable
Returns all children, in order, of this element in the Condition tree, or en empty set if this element has no children. In XACML 1.x, only the ApplyType ever has children.

Returns:
a List of Evaluatables

returnsBag

public boolean returnsBag()
Description copied from interface: Expression
Returns whether or not this expression returns, or evaluates to a Bag. Note that Evaluatable, which extends this interface, defines evaluatesToBag which is essentially the same function. This method has been deprecated, and returnsBag is now the preferred way to query all Expressions.


encode

public void encode(StringBuilder builder)
Description copied from interface: Expression
Encodes this AttributeValue into its XML representation and writes this encoding to the given StringBuilder This will always produce the version used in a policy rather than that used in a request, so this is equivalent to calling encodeWithTags(true) and then stuffing that into a stream.

Parameters:
builder - string stream into which the XML-encoded data is written


Copyright © 2015 WSO2. All rights reserved.