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

Quick Search    Search Deep

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

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

public class Rule
extends java.lang.Object
implements PolicyTreeElement

Represents the RuleType XACML type. This has a target for matching, and encapsulates the condition and all sub-operations that make up the heart of most policies.

Since:
1.0

Field Summary
private  com.sun.xacml.cond.Apply condition
           
private  java.lang.String description
           
private  int effectAttr
           
private  java.net.URI idAttr
           
private  Target target
           
 
Constructor Summary
Rule(java.net.URI id, int effect, java.lang.String description, Target target, com.sun.xacml.cond.Apply condition)
          Creates a new Rule object.
 
Method Summary
 void encode(java.io.OutputStream output)
          Encodes this Rule 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 Rule into its XML representation and writes this encoding to the given OutputStream with indentation.
 com.sun.xacml.ctx.Result evaluate(EvaluationCtx context)
          Evaluates the rule against the supplied context.
 java.util.List getChildren()
          Since a rule is always a leaf in a policy tree because it can have no children, this always returns an empty List.
 com.sun.xacml.cond.Apply getCondition()
          Returns the condition for this Rule or null if there is no condition
 java.lang.String getDescription()
          Returns the given description of this Rule or null if there is no description
 int getEffect()
          Returns the effect that this Rule will return from the evaluate method (Permit or Deny) if the request applies.
 java.net.URI getId()
          Returns the id of this Rule
static Rule getInstance(org.w3c.dom.Node root, java.lang.String xpathVersion)
          Returns a new instance of the Rule class based on a DOM node.
 Target getTarget()
          Returns the target for this Rule or null if there is no target
 MatchResult match(EvaluationCtx context)
          Given the input context sees whether or not the request matches this Rule's Target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idAttr

private java.net.URI idAttr

effectAttr

private int effectAttr

description

private java.lang.String description

target

private Target target

condition

private com.sun.xacml.cond.Apply condition
Constructor Detail

Rule

public Rule(java.net.URI id,
            int effect,
            java.lang.String description,
            Target target,
            com.sun.xacml.cond.Apply condition)
Creates a new Rule object.

Method Detail

getInstance

public static Rule getInstance(org.w3c.dom.Node root,
                               java.lang.String xpathVersion)
                        throws ParsingException
Returns a new instance of the Rule class based on a DOM node. The node must be the root of an XML RuleType.


getEffect

public int getEffect()
Returns the effect that this Rule will return from the evaluate method (Permit or Deny) if the request applies.


getId

public java.net.URI getId()
Returns the id of this Rule

Specified by:
getId in interface PolicyTreeElement

getDescription

public java.lang.String getDescription()
Returns the given description of this Rule or null if there is no description

Specified by:
getDescription in interface PolicyTreeElement

getTarget

public Target getTarget()
Returns the target for this Rule or null if there is no target

Specified by:
getTarget in interface PolicyTreeElement

getChildren

public java.util.List getChildren()
Since a rule is always a leaf in a policy tree because it can have no children, this always returns an empty List.

Specified by:
getChildren in interface PolicyTreeElement

getCondition

public com.sun.xacml.cond.Apply getCondition()
Returns the condition for this Rule or null if there is no condition


match

public MatchResult match(EvaluationCtx context)
Given the input context sees whether or not the request matches this Rule's Target. Note that unlike the matching done by the evaluate method, if the Target is missing than this will return Indeterminate. This lets you write your own custom matching routines for rules but lets evaluation proceed normally.

Specified by:
match in interface PolicyTreeElement

evaluate

public com.sun.xacml.ctx.Result evaluate(EvaluationCtx context)
Evaluates the rule against the supplied context. This will check that the target matches, and then try to evaluate the condition. If the target and condition apply, then the rule's effect is returned in the result.

Note that rules are not required to have targets. If no target is specified, then the rule inherits its parent's target. In the event that this Rule has no Target then the match is assumed to be true, since evaluating a policy tree to this level required the parent's target to match.

Specified by:
evaluate in interface PolicyTreeElement

encode

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

Specified by:
encode in interface PolicyTreeElement

encode

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

Specified by:
encode in interface PolicyTreeElement