JBoss port of sunxacml 2.0.8.Final-redhat-1

org.jboss.security.xacml.sunxacml
Class BasicEvaluationCtx

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.BasicEvaluationCtx
All Implemented Interfaces:
EvaluationCtx

public class BasicEvaluationCtx
extends Object
implements EvaluationCtx

A basic implementation of EvaluationCtx that is created from an XACML Request and falls back on an AttributeFinder if a requested value isn't available in the Request.

Note that this class can do some optional caching for current date, time, and dateTime values (defined by a boolean flag to the constructors). The XACML specification requires that these values always be available, but it does not specify whether or not they must remain constant over the course of an evaluation if the values are being generated by the PDP (if the values are provided in the Request, then obviously they will remain constant). The default behavior is for these environment values to be cached, so that (for example) the current time remains constant over the course of an evaluation.

Since:
1.2
Author:
Seth Proctor

Field Summary
 
Fields inherited from interface org.jboss.security.xacml.sunxacml.EvaluationCtx
RESOURCE_ID, RESOURCE_SCOPE, SCOPE_CHILDREN, SCOPE_DESCENDANTS, SCOPE_IMMEDIATE
 
Constructor Summary
BasicEvaluationCtx(RequestCtx request)
          Constructs a new BasicEvaluationCtx based on the given request.
BasicEvaluationCtx(RequestCtx request, AttributeFinder finder)
          Constructs a new BasicEvaluationCtx based on the given request, and supports looking outside the original request for attribute values using the AttributeFinder.
BasicEvaluationCtx(RequestCtx request, AttributeFinder finder, boolean cacheEnvValues)
          Constructs a new BasicEvaluationCtx based on the given request, and supports looking outside the original request for attribute values using the AttributeFinder.
BasicEvaluationCtx(RequestCtx request, boolean cacheEnvValues)
          Constructs a new BasicEvaluationCtx based on the given request.
 
Method Summary
 EvaluationResult getActionAttribute(URI type, URI id, URI issuer)
          Returns attribute value(s) from the action section of the request.
 EvaluationResult getAttribute(String contextPath, Node namespaceNode, URI type, String xpathVersion)
          Returns the attribute value(s) retrieved using the given XPath expression.
 DateAttribute getCurrentDate()
          Returns the value for the current date.
 DateTimeAttribute getCurrentDateTime()
          Returns the value for the current dateTime.
 TimeAttribute getCurrentTime()
          Returns the value for the current time.
 EvaluationResult getEnvironmentAttribute(URI type, URI id, URI issuer)
          Returns attribute value(s) from the environment section of the request.
 Node getRequestRoot()
          Returns the DOM root of the original RequestType XML document.
 EvaluationResult getResourceAttribute(URI type, URI id, URI issuer)
          Returns attribute value(s) from the resource section of the request.
 AttributeValue getResourceId()
          Returns the resource named in the request as resource-id.
 int getScope()
          Returns the resource scope of the request, which will be one of the three fields denoting Immediate, Children, or Descendants.
 EvaluationResult getSubjectAttribute(URI type, URI id, URI category)
          Returns attribute value(s) from the subject section of the request that have no issuer.
 EvaluationResult getSubjectAttribute(URI type, URI id, URI issuer, URI category)
          Returns attribute value(s) from the subject section of the request.
 void setResourceId(AttributeValue resourceId)
          Changes the value of the resource-id attribute in this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicEvaluationCtx

public BasicEvaluationCtx(RequestCtx request)
                   throws ParsingException
Constructs a new BasicEvaluationCtx based on the given request. The resulting context will cache current date, time, and dateTime values so they remain constant for this evaluation.

Parameters:
request - the request
Throws:
ParsingException - if a required attribute is missing, or if there are any problems dealing with the request data

BasicEvaluationCtx

public BasicEvaluationCtx(RequestCtx request,
                          boolean cacheEnvValues)
                   throws ParsingException
Constructs a new BasicEvaluationCtx based on the given request.

Parameters:
request - the request
cacheEnvValues - whether or not to cache the current time, date, and dateTime so they are constant for the scope of this evaluation
Throws:
ParsingException - if a required attribute is missing, or if there are any problems dealing with the request data

BasicEvaluationCtx

public BasicEvaluationCtx(RequestCtx request,
                          AttributeFinder finder)
                   throws ParsingException
Constructs a new BasicEvaluationCtx based on the given request, and supports looking outside the original request for attribute values using the AttributeFinder. The resulting context will cache current date, time, and dateTime values so they remain constant for this evaluation.

Parameters:
request - the request
finder - an AttributeFinder to use in looking for attributes that aren't in the request
Throws:
ParsingException - if a required attribute is missing, or if there are any problems dealing with the request data

BasicEvaluationCtx

public BasicEvaluationCtx(RequestCtx request,
                          AttributeFinder finder,
                          boolean cacheEnvValues)
                   throws ParsingException
Constructs a new BasicEvaluationCtx based on the given request, and supports looking outside the original request for attribute values using the AttributeFinder.

Parameters:
request - the request
finder - an AttributeFinder to use in looking for attributes that aren't in the request
cacheEnvValues - whether or not to cache the current time, date, and dateTime so they are constant for the scope of this evaluation
Throws:
ParsingException - if a required attribute is missing, or if there are any problems dealing with the request data
Method Detail

getRequestRoot

public Node getRequestRoot()
Returns the DOM root of the original RequestType XML document.

Specified by:
getRequestRoot in interface EvaluationCtx
Returns:
the DOM root node

getScope

public int getScope()
Returns the resource scope of the request, which will be one of the three fields denoting Immediate, Children, or Descendants.

Specified by:
getScope in interface EvaluationCtx
Returns:
the scope of the resource in the request

getResourceId

public AttributeValue getResourceId()
Returns the resource named in the request as resource-id.

Specified by:
getResourceId in interface EvaluationCtx
Returns:
the resource

setResourceId

public void setResourceId(AttributeValue resourceId)
Changes the value of the resource-id attribute in this context. This is useful when you have multiple resources (ie, a scope other than IMMEDIATE), and you need to keep changing only the resource-id to evaluate the different effective requests.

Specified by:
setResourceId in interface EvaluationCtx
Parameters:
resourceId - the new resource-id value

getCurrentTime

public TimeAttribute getCurrentTime()
Returns the value for the current time. The current time, current date, and current dateTime are consistent, so that they all represent the same moment. If this is the first time that one of these three values has been requested, and caching is enabled, then the three values will be resolved and stored.

Note that the value supplied here applies only to dynamically resolved values, not those supplied in the Request. In other words, this always returns a dynamically resolved value local to the PDP, even if a different value was supplied in the Request. This is handled correctly when the value is requested by its identifier.

Specified by:
getCurrentTime in interface EvaluationCtx
Returns:
the current time

getCurrentDate

public DateAttribute getCurrentDate()
Returns the value for the current date. The current time, current date, and current dateTime are consistent, so that they all represent the same moment. If this is the first time that one of these three values has been requested, and caching is enabled, then the three values will be resolved and stored.

Note that the value supplied here applies only to dynamically resolved values, not those supplied in the Request. In other words, this always returns a dynamically resolved value local to the PDP, even if a different value was supplied in the Request. This is handled correctly when the value is requested by its identifier.

Specified by:
getCurrentDate in interface EvaluationCtx
Returns:
the current date

getCurrentDateTime

public DateTimeAttribute getCurrentDateTime()
Returns the value for the current dateTime. The current time, current date, and current dateTime are consistent, so that they all represent the same moment. If this is the first time that one of these three values has been requested, and caching is enabled, then the three values will be resolved and stored.

Note that the value supplied here applies only to dynamically resolved values, not those supplied in the Request. In other words, this always returns a dynamically resolved value local to the PDP, even if a different value was supplied in the Request. This is handled correctly when the value is requested by its identifier.

Specified by:
getCurrentDateTime in interface EvaluationCtx
Returns:
the current dateTime

getSubjectAttribute

public EvaluationResult getSubjectAttribute(URI type,
                                            URI id,
                                            URI category)
Returns attribute value(s) from the subject section of the request that have no issuer.

Specified by:
getSubjectAttribute in interface EvaluationCtx
Parameters:
type - the type of the attribute value(s) to find
id - the id of the attribute value(s) to find
category - the category the attribute value(s) must be in
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

getSubjectAttribute

public EvaluationResult getSubjectAttribute(URI type,
                                            URI id,
                                            URI issuer,
                                            URI category)
Returns attribute value(s) from the subject section of the request.

Specified by:
getSubjectAttribute in interface EvaluationCtx
Parameters:
type - the type of the attribute value(s) to find
id - the id of the attribute value(s) to find
issuer - the issuer of the attribute value(s) to find or null
category - the category the attribute value(s) must be in
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

getResourceAttribute

public EvaluationResult getResourceAttribute(URI type,
                                             URI id,
                                             URI issuer)
Returns attribute value(s) from the resource section of the request.

Specified by:
getResourceAttribute in interface EvaluationCtx
Parameters:
type - the type of the attribute value(s) to find
id - the id of the attribute value(s) to find
issuer - the issuer of the attribute value(s) to find or null
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

getActionAttribute

public EvaluationResult getActionAttribute(URI type,
                                           URI id,
                                           URI issuer)
Returns attribute value(s) from the action section of the request.

Specified by:
getActionAttribute in interface EvaluationCtx
Parameters:
type - the type of the attribute value(s) to find
id - the id of the attribute value(s) to find
issuer - the issuer of the attribute value(s) to find or null
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

getEnvironmentAttribute

public EvaluationResult getEnvironmentAttribute(URI type,
                                                URI id,
                                                URI issuer)
Returns attribute value(s) from the environment section of the request.

Specified by:
getEnvironmentAttribute in interface EvaluationCtx
Parameters:
type - the type of the attribute value(s) to find
id - the id of the attribute value(s) to find
issuer - the issuer of the attribute value(s) to find or null
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

getAttribute

public EvaluationResult getAttribute(String contextPath,
                                     Node namespaceNode,
                                     URI type,
                                     String xpathVersion)
Returns the attribute value(s) retrieved using the given XPath expression.

Specified by:
getAttribute in interface EvaluationCtx
Parameters:
contextPath - the XPath expression to search
namespaceNode - the DOM node defining namespace mappings to use, or null if mappings come from the context root
type - the type of the attribute value(s) to find
xpathVersion - the version of XPath to use
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

JBoss port of sunxacml 2.0.8.Final-redhat-1

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.