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

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

public class VariableReference
extends Object
implements Evaluatable

This class supports the VariableReferenceType type introuced in XACML 2.0. It allows an expression to reference a variable definition. If there is no such definition then the Policy is invalid. A reference can be included anywwhere in an expression where the referenced expression would be valid.

Since:
2.0
Author:
Seth Proctor

Constructor Summary
VariableReference(String variableId)
          Simple constructor that takes only the identifier.
VariableReference(String variableId, VariableManager manager)
          Constructor that takes the reference identifier and a manager.
VariableReference(VariableDefinition definition)
          Constructor that takes the definition referenced by this class.
 
Method Summary
 void encode(OutputStream output)
          Encodes this class into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this class into its XML representation and writes this encoding to the given OutputStream with indentation.
 EvaluationResult evaluate(EvaluationCtx context)
          Evaluates the referenced expression using the given context, and either returns an error or a resulting 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 references never have children in the policy tree.
static VariableReference getInstance(Node root, PolicyMetaData metaData, VariableManager manager)
          Returns a new instance of the VariableReference class based on a DOM node.
 VariableDefinition getReferencedDefinition()
          Returns the VariableDefinition referenced by this class, or null if the definition cannot be resolved.
 URI getType()
          Returns the type of the referenced expression.
 String getVariableId()
          Returns the reference identifier.
 boolean returnsBag()
          Tells whether evaluation will return a bag or a single value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableReference

public VariableReference(String variableId)
Simple constructor that takes only the identifier. This is provided for tools that want to build policies only for the sake of encoding or displaying them. This constructor will not create a reference that can be followed to its associated definition, so it cannot be used in evaluation.

Parameters:
variableId - the reference identifier

VariableReference

public VariableReference(VariableDefinition definition)
Constructor that takes the definition referenced by this class. If you're building policies programatically, this is typically the form you use. It does make the connection from reference to definition, so this will result in an evaluatable reference.

Parameters:
definition - the definition this class references

VariableReference

public VariableReference(String variableId,
                         VariableManager manager)
Constructor that takes the reference identifier and a manager. This is typically only used by parsing code, since the manager is used to handle out-of-order definitions and circular references.

Parameters:
variableId - the reference identifier
manager - a VariableManager used to handle the dependencies between references and definitions during parsing
Method Detail

getInstance

public static VariableReference getInstance(Node root,
                                            PolicyMetaData metaData,
                                            VariableManager manager)
                                     throws ParsingException
Returns a new instance of the VariableReference class based on a DOM node. The node must be the root of an XML VariableReferenceType.

Parameters:
root - the DOM root of a VariableReferenceType XML type
metaData - the meta-data associated with the containing policy
manager - the VariableManager used to connect this reference to its definition
Throws:
ParsingException - if the VariableReferenceType is invalid

getVariableId

public String getVariableId()
Returns the reference identifier.

Returns:
the reference's identifier

getReferencedDefinition

public VariableDefinition getReferencedDefinition()
Returns the VariableDefinition referenced by this class, or null if the definition cannot be resolved.

Returns:
the referenced definition or null

evaluate

public EvaluationResult evaluate(EvaluationCtx context)
Evaluates the referenced expression using the given context, and either returns an error or a resulting value. If this doesn't reference an evaluatable expression (eg, a single Function) then this will throw an exception.

Specified by:
evaluate in interface Evaluatable
Parameters:
context - the representation of the request
Returns:
the result of evaluation

getType

public URI getType()
Returns the type of the referenced expression.

Specified by:
getType in interface Expression
Returns:
the attribute return type of the referenced expression
Throws:
ProcessingException - if the type couldn't be resolved

returnsBag

public boolean returnsBag()
Tells whether evaluation will return a bag or a single value.

Specified by:
returnsBag in interface Expression
Returns:
true if evaluation will return a bag, false otherwise
Throws:
ProcessingException - if the return type couldn't be resolved

evaluatesToBag

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

Tells whether evaluation will return a bag or a single value.

Specified by:
evaluatesToBag in interface Evaluatable
Returns:
true if evaluation will return a bag, false otherwise
Throws:
ProcessingException - if the return type couldn't be resolved

getChildren

public List getChildren()
Always returns an empty list since references never have children in the policy tree. Note that the referenced definition may still have children, so tools may want to treat these as children of this reference, but must take care since circular references could create a tree of infinite depth.

Specified by:
getChildren in interface Evaluatable
Returns:
an empty List

encode

public void encode(OutputStream output)
Encodes this class 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 class 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


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