SunTM's XACML Implementation for JavaTM

com.sun.xacml
Class BasicEvaluationCtx

java.lang.Object
  extended bycom.sun.xacml.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.

Since:
1.2

Field Summary
 
Fields inherited from interface com.sun.xacml.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.
 AttributeFinder getAttributeFinder()
          Returns the AttributeFinder used by this context.
 DateAttribute getCurrentDate()
          Returns the cached value for the current date.
 DateTimeAttribute getCurrentDateTime()
          Returns the cached value for the current dateTime.
 TimeAttribute getCurrentTime()
          Returns the cached 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 setCurrentDate(DateAttribute currentDate)
          Sets the current date for this evaluation.
 void setCurrentDateTime(DateTimeAttribute currentDateTime)
          Sets the current dateTime for this evaluation.
 void setCurrentTime(TimeAttribute currentTime)
          Sets the current time for this evaluation.
 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

getAttributeFinder

public AttributeFinder getAttributeFinder()
Returns the AttributeFinder used by this context. Note that this is a deprecated method and will be removed in the next major release.

Specified by:
getAttributeFinder in interface EvaluationCtx
Returns:
the AttributeFinder

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

getResourceId

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

Specified by:
getResourceId in interface EvaluationCtx
Returns:
the resource

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

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 cached value for the current time. If The value has never been set by a call to setCurrentTime, or if caching is not enabled in this instance, then this will return null. Note that this only applies to dynamically resolved values, not those supplied in the Request.

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

setCurrentTime

public void setCurrentTime(TimeAttribute currentTime)
Sets the current time for this evaluation. If caching is not enabled for this instance then the value is ignored.

Specified by:
setCurrentTime in interface EvaluationCtx
Parameters:
currentTime - the dynamically resolved current time

getCurrentDate

public DateAttribute getCurrentDate()
Returns the cached value for the current date. If The value has never been set by a call to setCurrentDate, or if caching is not enabled in this instance, then this will return null. Note that this only applies to dynamically resolved values, not those supplied in the Request.

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

setCurrentDate

public void setCurrentDate(DateAttribute currentDate)
Sets the current date for this evaluation. If caching is not enabled for this instance then the value is ignored.

Specified by:
setCurrentDate in interface EvaluationCtx
Parameters:
currentDate - the dynamically resolved current date

getCurrentDateTime

public DateTimeAttribute getCurrentDateTime()
Returns the cached value for the current dateTime. If The value has never been set by a call to setCurrentDateTime, or if caching is not enabled in this instance, then this will return null. Note that this only applies to dynamically resolved values, not those supplied in the Request.

Specified by:
getCurrentDateTime in interface EvaluationCtx
Returns:
the current date or null

setCurrentDateTime

public void setCurrentDateTime(DateTimeAttribute currentDateTime)
Sets the current dateTime for this evaluation. If caching is not enabled for this instance then the value is ignored.

Specified by:
setCurrentDateTime in interface EvaluationCtx
Parameters:
currentDateTime - the dynamically resolved 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

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.