public class AttributeSelector extends AbstractAttributeSelector
AttributeFinderModule
s so that it's easy to plugin different XPath implementations.Constructor and Description |
---|
AttributeSelector(URI type,
String contextPath,
boolean mustBePresent,
String xpathVersion)
Creates a new
AttributeSelector with no policy root. |
AttributeSelector(URI type,
String contextPath,
Node policyRoot,
boolean mustBePresent,
String xpathVersion)
Creates a new
AttributeSelector . |
Modifier and Type | Method and Description |
---|---|
void |
encode(StringBuilder builder)
Encodes this
AttributeSelector into its XML form and writes this out to the provided
StringBuilder |
EvaluationResult |
evaluate(EvaluationCtx context)
Invokes the
AttributeFinder used by the given EvaluationCtx to try
to resolve an attribute value. |
boolean |
evaluatesToBag()
Deprecated.
As of 2.0, you should use the
returnsBag method from the
super-interface Expression . |
List |
getChildren()
Always returns an empty list since selectors never have children.
|
String |
getContextPath()
Returns the XPath query used to resolve attribute values.
|
static AttributeSelector |
getInstance(Node root,
PolicyMetaData metaData)
Creates a new
AttributeSelector based on the DOM root of the XML type. |
static AttributeSelector |
getInstance(Node root,
String xpathVersion)
Deprecated.
As of 2.0 you should avoid using this method and should instead use the version
that takes a
PolicyMetaData instance. This method will only work for
XACML 1.x policies. |
boolean |
returnsBag()
Always returns true, since a selector always returns a bag of attribute values.
|
getType, getXPathVersion, isMustBePresent
public AttributeSelector(URI type, String contextPath, boolean mustBePresent, String xpathVersion)
AttributeSelector
with no policy root.type
- the data type of the attribute values this selector looks forcontextPath
- the XPath to querymustBePresent
- must resolution find a matchxpathVersion
- the XPath version to use, which must be a valid XPath version string (the
identifier for XPath 1.0 is provided in PolicyMetaData
)public AttributeSelector(URI type, String contextPath, Node policyRoot, boolean mustBePresent, String xpathVersion)
AttributeSelector
.type
- the data type of the attribute values this selector looks forcontextPath
- the XPath to querypolicyRoot
- the root DOM Element for the policy containing this selector, which defines
namespace mappingsmustBePresent
- must resolution find a matchxpathVersion
- the XPath version to use, which must be a valid XPath version string (the
identifier for XPath 1.0 is provided in PolicyMetaData
)public static AttributeSelector getInstance(Node root, String xpathVersion) throws ParsingException
PolicyMetaData
instance. This method will only work for
XACML 1.x policies.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.root
- the root of the DOM tree for the XML AttributeSelectorType XML typexpathVersion
- the XPath version to use, or null if this is unspecified (ie, not
supplied in the defaults section of the policy)AttributeSelector
ParsingException
- if the AttributeSelectorType was invalidpublic static AttributeSelector getInstance(Node root, PolicyMetaData metaData) throws ParsingException
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.root
- the root of the DOM tree for the XML AttributeSelectorType XML typemetaData
- the meta-data associated with the containing policyAttributeSelector
ParsingException
- if the AttributeSelectorType was invalidpublic String getContextPath()
public boolean returnsBag()
public boolean evaluatesToBag()
returnsBag
method from the
super-interface Expression
.public List getChildren()
List
public EvaluationResult evaluate(EvaluationCtx context)
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.context
- representation of the request to searchpublic void encode(StringBuilder builder)
AttributeSelector
into its XML form and writes this out to the provided
StringBuilder
builder
- string stream into which the XML-encoded data is writtenCopyright © 2016 WSO2. All rights reserved.