issrg.pba.rbac.xmlpolicy.ifstatement
Class EnvironmentNode

java.lang.Object
  extended by issrg.pba.rbac.xmlpolicy.PolicyXMLNode
      extended by issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
          extended by issrg.pba.rbac.xmlpolicy.ifstatement.NamedTermNode
              extended by issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode
All Implemented Interfaces:
Term

public class EnvironmentNode
extends NamedTermNode

This is the class that represents an Environment node and evaluates the environmental variables at run-time.

EnvironmentNode expects the environment to contain either issrg.pba.rbac.Argument objects, in which case the string value will be converted using Types.construct, or other objects, which will be passed as is to the interpreters.

If the environment contains the variables of types for which there is no constructor provided by the AEF (not registered with the Types), or the AEF failed to provide the variable with the name stated in the policy, an EvaluationException will occur at run-time.

Note that if the evaluation does not reach the point where the variable is needed, no exception will be thrown.

Author:
A.Otenko
See Also:
Types.construct(java.lang.String, java.lang.String)

Field Summary
static java.lang.String ENVIRONMENT_NODE
          This is the name of the node that represents the Environment - a reference to an environmental parameter.
static java.lang.String PARAMETER_ATTRIBUTE
          This is the name of the attribute telling the name of the environmental parameter.
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.ifstatement.NamedTermNode
parameter_name, s_namedTerms, type
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
maxOperand, minOperand, terms
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
attributes, children, name, nodeStr
 
Constructor Summary
protected EnvironmentNode()
           
  EnvironmentNode(XMLPolicyParser p, org.xml.sax.Attributes attr)
          This constructor builds an EnvironmentNode given the XMLPolicyParser and the set of attributes of the XML element.
 
Method Summary
 java.lang.Object evaluate(Environment env)
          This method evaluates the environmental parameter, as it is at run-time.
static void register()
          This method should be called to register the node with the XML Parser
 
Methods inherited from class issrg.pba.rbac.xmlpolicy.ifstatement.NamedTermNode
getAllNamedTerms, getName, getNamedTerms, getType, resetNamedTerms
 
Methods inherited from class issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
construct, getInterpretersForNode, registerInterpreterForNode
 
Methods inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
addChild, addString, getAttributes, getChildren, getString, toString, toXML, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENVIRONMENT_NODE

public static final java.lang.String ENVIRONMENT_NODE
This is the name of the node that represents the Environment - a reference to an environmental parameter.

See Also:
Constant Field Values

PARAMETER_ATTRIBUTE

public static final java.lang.String PARAMETER_ATTRIBUTE
This is the name of the attribute telling the name of the environmental parameter.

See Also:
Constant Field Values
Constructor Detail

EnvironmentNode

protected EnvironmentNode()

EnvironmentNode

public EnvironmentNode(XMLPolicyParser p,
                       org.xml.sax.Attributes attr)
                throws PolicyParsingException
This constructor builds an EnvironmentNode given the XMLPolicyParser and the set of attributes of the XML element. It expects that a issrg.pba.rbac.xmlpolicy.XMLTags.TYPE_ATTRIBUTE and PARAMETER_ATTRIBUTE ("Type" and "Parameter") are present in this XML element. The value is converted from string into a Java object using the Types.construct() method at runtime, so the type of the value must be registered there.

Parameters:
p - - the XMLPolicyParser that builds this EnvironmentNode
attr - - the attributes of this XML element
Throws:
PolicyParsingException
See Also:
Types.construct(java.lang.String, java.lang.String)
Method Detail

register

public static void register()
This method should be called to register the node with the XML Parser


evaluate

public java.lang.Object evaluate(Environment env)
                          throws EvaluationException
This method evaluates the environmental parameter, as it is at run-time. It looks for the environmental parameter in the Environment by its name, as determined at construction time. If the value is of type other than issrg.pba.rbac.Argument, then it is the result of this method; otherwise the String value of the issrg.pba.rbac.Argument is extracted and decoded into a Java object using Types.construct method.

Parameters:
env - - the Environment with the variables in it indexed by their name
Returns:
Object of type guaranteed by getType() method
Throws:
EvaluationException, - if there is no variable in the Environment with the expected name, or if its type is not the expected type, or if Types.construct failed to decode the value from String (no decoder registered or other decoding problem)
EvaluationException - if the term cannot be evaluated
See Also:
Types.construct(java.lang.String, java.lang.String)