Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sun.xacml
Class PolicyReference  view PolicyReference download PolicyReference.java

java.lang.Object
  extended bycom.sun.xacml.AbstractPolicy
      extended bycom.sun.xacml.PolicyReference
All Implemented Interfaces:
PolicyTreeElement

public class PolicyReference
extends AbstractPolicy

This class is used as a placeholder for the PolicyIdReference and PolicySetIdReference fields in a PolicySetType. When a reference is used in a policy set, it is telling the PDP to use an external policy in the current policy. Each time the PDP needs to evaluate that policy reference, it asks the policy finder for the policy. Typically the policy finder will have cached the referenced policy, so this isn't too slow.

NOTE: all of the accessor methods, the match method, and the evaluate method require this class to ask its PolicyFinder for the referenced policy, which can be a slow operation. Care should be taken, therefore in calling these methods too often. Also note that it's not safe to cache the results of these calls, since the referenced policy may change.

Since:
1.0

Field Summary
private  com.sun.xacml.finder.PolicyFinder finder
           
private static java.util.logging.Logger logger
           
static int POLICY_REFERENCE
          Identifies this as a reference to a Policy
static int POLICYSET_REFERENCE
          Identifies this as a reference to a PolicySet
private  int policyType
           
private  java.net.URI reference
           
 
Fields inherited from class com.sun.xacml.AbstractPolicy
XPATH_1_0_VERSION
 
Constructor Summary
PolicyReference(java.net.URI reference, int policyType, com.sun.xacml.finder.PolicyFinder finder)
          Creates a new PolicyReference.
 
Method Summary
 void encode(java.io.OutputStream output)
          Encodes this PolicyReference into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(java.io.OutputStream output, Indenter indenter)
          Encodes this PolicyReference into its XML representation and writes this encoding to the given OutputStream with indentation.
 com.sun.xacml.ctx.Result evaluate(EvaluationCtx context)
          Tries to evaluate the policy by calling the combining algorithm on the given policies or rules.
 java.util.List getChildren()
          Returns the child policy nodes under this node in the policy tree.
 com.sun.xacml.combine.CombiningAlgorithm getCombiningAlg()
          Returns the combining algorithm used by this policy.
 java.lang.String getDefaultVersion()
          Returns the default version for this policy.
 java.lang.String getDescription()
          Returns the given description of this policy or null if there is no description.
 java.net.URI getId()
          Returns the id of this policy.
static PolicyReference getInstance(org.w3c.dom.Node root, com.sun.xacml.finder.PolicyFinder finder)
          Creates an instance of a PolicyReference object based on a DOM node.
 java.util.Set getObligations()
          Returns the Set of obligations for this policy, which may be empty if there are no obligations.
 Target getTarget()
          Returns the target for this policy.
 MatchResult match(EvaluationCtx context)
          Given the input context sees whether or not the request matches this policy.
private  AbstractPolicy resolvePolicy()
          Private helper method that tried to resolve the policy
 
Methods inherited from class com.sun.xacml.AbstractPolicy
encodeCommonElements, setChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_REFERENCE

public static final int POLICY_REFERENCE
Identifies this as a reference to a Policy

See Also:
Constant Field Values

POLICYSET_REFERENCE

public static final int POLICYSET_REFERENCE
Identifies this as a reference to a PolicySet

See Also:
Constant Field Values

reference

private java.net.URI reference

policyType

private int policyType

finder

private com.sun.xacml.finder.PolicyFinder finder

logger

private static final java.util.logging.Logger logger
Constructor Detail

PolicyReference

public PolicyReference(java.net.URI reference,
                       int policyType,
                       com.sun.xacml.finder.PolicyFinder finder)
                throws java.lang.IllegalArgumentException
Creates a new PolicyReference.

Method Detail

getInstance

public static PolicyReference getInstance(org.w3c.dom.Node root,
                                          com.sun.xacml.finder.PolicyFinder finder)
                                   throws ParsingException
Creates an instance of a PolicyReference object based on a DOM node.


getId

public java.net.URI getId()
Returns the id of this policy. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Specified by:
getId in interface PolicyTreeElement
Overrides:
getId in class AbstractPolicy

getCombiningAlg

public com.sun.xacml.combine.CombiningAlgorithm getCombiningAlg()
Returns the combining algorithm used by this policy. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Overrides:
getCombiningAlg in class AbstractPolicy

getDescription

public java.lang.String getDescription()
Returns the given description of this policy or null if there is no description. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Specified by:
getDescription in interface PolicyTreeElement
Overrides:
getDescription in class AbstractPolicy

getTarget

public Target getTarget()
Returns the target for this policy. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Specified by:
getTarget in interface PolicyTreeElement
Overrides:
getTarget in class AbstractPolicy

getDefaultVersion

public java.lang.String getDefaultVersion()
Returns the default version for this policy. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Overrides:
getDefaultVersion in class AbstractPolicy

getChildren

public java.util.List getChildren()
Returns the child policy nodes under this node in the policy tree. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Specified by:
getChildren in interface PolicyTreeElement
Overrides:
getChildren in class AbstractPolicy

getObligations

public java.util.Set getObligations()
Returns the Set of obligations for this policy, which may be empty if there are no obligations. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Overrides:
getObligations in class AbstractPolicy

match

public MatchResult match(EvaluationCtx context)
Given the input context sees whether or not the request matches this policy. This must be called by combining algorithms before they evaluate a policy. This is also used in the initial policy finding operation to determine which top-level policies might apply to the request. If the policy is invalid or can't be retrieved, then a runtime exception is thrown.

Specified by:
match in interface PolicyTreeElement
Overrides:
match in class AbstractPolicy

resolvePolicy

private AbstractPolicy resolvePolicy()
Private helper method that tried to resolve the policy


evaluate

public com.sun.xacml.ctx.Result evaluate(EvaluationCtx context)
Tries to evaluate the policy by calling the combining algorithm on the given policies or rules. The match method must always be called first, and must always return MATCH, before this method is called.

Specified by:
evaluate in interface PolicyTreeElement
Overrides:
evaluate in class AbstractPolicy

encode

public void encode(java.io.OutputStream output)
Encodes this PolicyReference into its XML representation and writes this encoding to the given OutputStream with no indentation.


encode

public void encode(java.io.OutputStream output,
                   Indenter indenter)
Encodes this PolicyReference into its XML representation and writes this encoding to the given OutputStream with indentation.