org.wso2.balana
Class Policy

java.lang.Object
  extended by org.wso2.balana.AbstractPolicy
      extended by org.wso2.balana.Policy
All Implemented Interfaces:
PolicyTreeElement

public class Policy
extends AbstractPolicy

Represents one of the two top-level constructs in XACML, the PolicyType. This optionally contains rules, which in turn contain most of the logic of a policy.

Since:
1.0
Author:
Seth Proctor

Field Summary
 
Fields inherited from class org.wso2.balana.AbstractPolicy
metaData
 
Constructor Summary
Policy(URI id, RuleCombiningAlgorithm combiningAlg, AbstractTarget target)
          Creates a new Policy with only the required elements.
Policy(URI id, RuleCombiningAlgorithm combiningAlg, AbstractTarget target, List<Rule> rules)
          Creates a new Policy with only the required elements plus rules.
Policy(URI id, String version, RuleCombiningAlgorithm combiningAlg, String description, AbstractTarget target, List<Rule> rules)
          Creates a new Policy with the required elements plus a version, rules, and a String description.
Policy(URI id, String version, RuleCombiningAlgorithm combiningAlg, String description, AbstractTarget target, String defaultVersion, List<CombinerElement> ruleElements, Set<AbstractObligation> obligations, Set<VariableDefinition> definitions, List<CombinerParameter> parameters)
          Creates a new Policy with the required and optional elements.
Policy(URI id, String version, RuleCombiningAlgorithm combiningAlg, String description, AbstractTarget target, String defaultVersion, List<Rule> rules)
          Creates a new Policy with the required elements plus a version, rules, a String description and policy defaults.
Policy(URI id, String version, RuleCombiningAlgorithm combiningAlg, String description, AbstractTarget target, String defaultVersion, List<Rule> rules, Set<AbstractObligation> obligations)
          Creates a new Policy with the required elements plus a version, rules, a String description, policy defaults, and obligations.
Policy(URI id, String version, RuleCombiningAlgorithm combiningAlg, String description, AbstractTarget target, String defaultVersion, List<Rule> rules, Set<AbstractObligation> obligations, Set<VariableDefinition> definitions)
          Creates a new Policy with the required elements plus a version, rules, a String description, policy defaults, obligations, and variable definitions.
 
Method Summary
 String encode()
          Encodes this Policy into its XML form
 void encode(StringBuilder builder)
          Encodes this Policy into its XML form and writes this out to the provided StringBuilder
static Policy getInstance(Node root)
          Creates an instance of a Policy object based on a DOM node.
 Set getVariableDefinitions()
          Returns the variable definitions in this Policy.
 
Methods inherited from class org.wso2.balana.AbstractPolicy
encodeCommonElements, evaluate, getActionPolicyValue, getAdviceExpressions, getChildElements, getChildren, getCombiningAlg, getCombiningParameters, getDefaultVersion, getDescription, getEnvPolicyValue, getId, getMetaData, getObligationExpressions, getResourcePolicyValue, getSubjectPolicyValue, getTarget, getVersion, match, setActionPolicyValue, setChildren, setEnvPolicyValue, setResourcePolicyValue, setSubjectPolicyValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Policy

public Policy(URI id,
              RuleCombiningAlgorithm combiningAlg,
              AbstractTarget target)
Creates a new Policy with only the required elements.

Parameters:
id - the policy identifier
combiningAlg - the CombiningAlgorithm used on the rules in this set
target - the AbstractTarget for this policy

Policy

public Policy(URI id,
              RuleCombiningAlgorithm combiningAlg,
              AbstractTarget target,
              List<Rule> rules)
Creates a new Policy with only the required elements plus rules.

Parameters:
id - the policy identifier
combiningAlg - the CombiningAlgorithm used on the rules in this set
target - the AbstractTarget for this policy
rules - a list of Rule objects
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a Rule

Policy

public Policy(URI id,
              String version,
              RuleCombiningAlgorithm combiningAlg,
              String description,
              AbstractTarget target,
              List<Rule> rules)
Creates a new Policy with the required elements plus a version, rules, and a String description. Note that the version is an XACML 2.0 feature.

Parameters:
id - the policy identifier
version - the policy version or null for the default (this must always be null for XACML 1.x policies)
combiningAlg - the CombiningAlgorithm used on the rules in this set
description - a String describing the policy
target - the AbstractTarget for this policy
rules - a list of Rule objects
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a Rule

Policy

public Policy(URI id,
              String version,
              RuleCombiningAlgorithm combiningAlg,
              String description,
              AbstractTarget target,
              String defaultVersion,
              List<Rule> rules)
Creates a new Policy with the required elements plus a version, rules, a String description and policy defaults. Note that the version is an XACML 2.0 feature.

Parameters:
id - the policy identifier
version - the policy version or null for the default (this must always be null for XACML 1.x policies)
combiningAlg - the CombiningAlgorithm used on the rules in this set
description - a String describing the policy
target - the AbstractTarget for this policy
defaultVersion - the XPath version to use
rules - a list of Rule objects
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a Rule

Policy

public Policy(URI id,
              String version,
              RuleCombiningAlgorithm combiningAlg,
              String description,
              AbstractTarget target,
              String defaultVersion,
              List<Rule> rules,
              Set<AbstractObligation> obligations)
Creates a new Policy with the required elements plus a version, rules, a String description, policy defaults, and obligations. Note that the version is an XACML 2.0 feature.

Parameters:
id - the policy identifier
version - the policy version or null for the default (this must always be null for XACML 1.x policies)
combiningAlg - the CombiningAlgorithm used on the rules in this set
description - a String describing the policy
target - the AbstractTarget for this policy
defaultVersion - the XPath version to use
rules - a list of Rule objects
obligations - a set of Obligations objects
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a Rule

Policy

public Policy(URI id,
              String version,
              RuleCombiningAlgorithm combiningAlg,
              String description,
              AbstractTarget target,
              String defaultVersion,
              List<Rule> rules,
              Set<AbstractObligation> obligations,
              Set<VariableDefinition> definitions)
Creates a new Policy with the required elements plus a version, rules, a String description, policy defaults, obligations, and variable definitions. Note that the version and definitions are XACML 2.0 features.

Parameters:
id - the policy identifier
version - the policy version or null for the default (this must always be null for XACML 1.x policies)
combiningAlg - the CombiningAlgorithm used on the rules in this set
description - a String describing the policy
target - the AbstractTarget for this policy
defaultVersion - the XPath version to use
rules - a list of Rule objects
obligations - a set of Obligations objects
definitions - a set of VariableDefinition objects that must provide all definitions referenced by all VariableReferences in the policy
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a Rule

Policy

public Policy(URI id,
              String version,
              RuleCombiningAlgorithm combiningAlg,
              String description,
              AbstractTarget target,
              String defaultVersion,
              List<CombinerElement> ruleElements,
              Set<AbstractObligation> obligations,
              Set<VariableDefinition> definitions,
              List<CombinerParameter> parameters)
Creates a new Policy with the required and optional elements. If you need to provide combining algorithm parameters, you need to use this constructor. Note that unlike the other constructors in this class, the rules list is actually a list of CombinerElements used to match a rule with any combiner parameters it may have.

Parameters:
id - the policy identifier
version - the policy version or null for the default (this must always be null for XACML 1.x policies)
combiningAlg - the CombiningAlgorithm used on the rules in this set
description - a String describing the policy or null if there is no description
target - the AbstractTarget for this policy
defaultVersion - the XPath version to use or null if there is no default version
ruleElements - a list of RuleCombinerElement objects or null if there are no rules
obligations - a set of Obligations objects or null if there are no obligations
definitions - a set of VariableDefinition objects that must provide all definitions referenced by all VariableReferences in the policy
parameters - the List of CombinerParameters provided for general use by the combining algorithm
Throws:
IllegalArgumentException - if the List of rules contains an object that is not a RuleCombinerElement
Method Detail

getInstance

public static Policy getInstance(Node root)
                          throws ParsingException
Creates an instance of a Policy object based on a DOM node. The node must be the root of PolicyType XML object, otherwise an exception is thrown.

Parameters:
root - the DOM root of a PolicyType XML type the XACML policy, if null use default factories
Returns:
a Policy object
Throws:
ParsingException - if the PolicyType is invalid

getVariableDefinitions

public Set getVariableDefinitions()
Returns the variable definitions in this Policy.

Returns:
a Set of VariableDefinitions

encode

public String encode()
Encodes this Policy into its XML form

Returns:
String

encode

public void encode(StringBuilder builder)
Encodes this Policy into its XML form and writes this out to the provided StringBuilder

Parameters:
builder - string stream into which the XML-encoded data is written


Copyright © 2015 WSO2. All rights reserved.