public class PolicyReference extends AbstractPolicy
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.
Modifier and Type | Field and Description |
---|---|
static int |
POLICY_REFERENCE
Identifies this as a reference to a
Policy |
static int |
POLICYSET_REFERENCE
Identifies this as a reference to a
PolicySet |
metaData
Constructor and Description |
---|
PolicyReference(URI reference,
int policyType,
PolicyFinder finder,
PolicyMetaData parentMetaData)
Creates a new
PolicyReference instance. |
PolicyReference(URI reference,
int policyType,
VersionConstraints constraints,
PolicyFinder finder,
PolicyMetaData parentMetaData)
Creates a new
PolicyReference instance with version constraints. |
Modifier and Type | Method and Description |
---|---|
String |
encode()
Encodes this
PolicyReference into its XML form |
void |
encode(StringBuilder builder)
Encodes this
PolicyReference into its XML form and writes this out to the provided
StringBuilder |
AbstractResult |
evaluate(EvaluationCtx context)
Tries to evaluate the policy by calling the combining algorithm on the given policies or
rules.
|
List |
getChildElements()
Returns the child policy nodes and their associated parameters.
|
List |
getChildren()
Returns the child policy nodes under this node in the policy tree.
|
CombiningAlgorithm |
getCombiningAlg()
Returns the combining algorithm used by this policy.
|
VersionConstraints |
getConstraints()
Returns the version constraints associated with this reference.
|
String |
getDefaultVersion()
Returns the default version for this policy.
|
String |
getDescription()
Returns the given description of this policy or null if there is no description.
|
URI |
getId()
Returns the id of this policy.
|
static PolicyReference |
getInstance(Node root,
PolicyFinder finder)
Deprecated.
As of 2.0 you should avoid using this method and should instead use the version
that takes a
PolicyMetaData instance. This method will only work for
XACML 1.x policies. |
static PolicyReference |
getInstance(Node root,
PolicyFinder finder,
PolicyMetaData metaData)
Creates an instance of a
PolicyReference object based on a DOM node. |
PolicyMetaData |
getMetaData()
Returns the meta-data associated with this policy.
|
Set |
getObligationExpressions()
Returns the Set of obligations for this policy, which may be empty if there are no
obligations.
|
URI |
getReference()
Returns the reference identifier used to resolve the policy.
|
int |
getReferenceType()
Returns whether this is a reference to a policy or to a policy set.
|
AbstractTarget |
getTarget()
Returns the target for this policy.
|
String |
getVersion()
Returns the version of this policy.
|
MatchResult |
match(EvaluationCtx context)
Given the input context sees whether or not the request matches this policy.
|
encodeCommonElements, getActionPolicyValue, getAdviceExpressions, getCombiningParameters, getEnvPolicyValue, getResourcePolicyValue, getSubjectPolicyValue, setActionPolicyValue, setChildren, setEnvPolicyValue, setResourcePolicyValue, setSubjectPolicyValue
public static final int POLICY_REFERENCE
Policy
public static final int POLICYSET_REFERENCE
PolicySet
public PolicyReference(URI reference, int policyType, PolicyFinder finder, PolicyMetaData parentMetaData) throws IllegalArgumentException
PolicyReference
instance. This has no constraints on version
matching. Note that an XACML 1.x reference may not have any constraints.reference
- the reference to the policypolicyType
- one of the two fields in this classfinder
- the PolicyFinder
used to handle the referenceparentMetaData
- the meta-data associated with the containing (parent) policyIllegalArgumentException
- if the input policyType isn't validpublic PolicyReference(URI reference, int policyType, VersionConstraints constraints, PolicyFinder finder, PolicyMetaData parentMetaData) throws IllegalArgumentException
PolicyReference
instance with version constraints. Note that an
XACML 1.x reference may not have any constraints.reference
- the reference to the policypolicyType
- one of the two fields in this classconstraints
- any optional constraints on the version of the referenced policy (this is
never null, but it may impose no constraints, and in fact will never impose
constraints when used from a pre-2.0 XACML policy)finder
- the PolicyFinder
used to handle the referenceparentMetaData
- the meta-data associated with the containing (parent) policyIllegalArgumentException
- if the input policyType isn't validpublic static PolicyReference getInstance(Node root, PolicyFinder finder) throws ParsingException
PolicyMetaData
instance. This method will only work for
XACML 1.x policies.PolicyReference
object based on a DOM node.root
- the DOM root of a PolicyIdReference or a PolicySetIdReference XML typefinder
- the PolicyFinder
used to handle the referenceParsingException
- if the node is invalidpublic static PolicyReference getInstance(Node root, PolicyFinder finder, PolicyMetaData metaData) throws ParsingException
PolicyReference
object based on a DOM node.root
- the DOM root of a PolicyIdReference or a PolicySetIdReference XML typefinder
- the PolicyFinder
used to handle the referencemetaData
- the meta-data associated with the containing policyParsingException
- if the node is invalidpublic URI getReference()
URI
public VersionConstraints getConstraints()
public int getReferenceType()
POLICY_REFERENCE
or
POLICYSET_REFERENCE
public URI getId()
getId
in interface PolicyTreeElement
getId
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic String getVersion()
getVersion
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic CombiningAlgorithm getCombiningAlg()
getCombiningAlg
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic String getDescription()
getDescription
in interface PolicyTreeElement
getDescription
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic AbstractTarget getTarget()
getTarget
in interface PolicyTreeElement
getTarget
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic String getDefaultVersion()
getDefaultVersion
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic List getChildren()
getChildren
in interface PolicyTreeElement
getChildren
in class AbstractPolicy
List
of child policy nodesProcessingException
- if the referenced policy can't be retrievedpublic List getChildElements()
getChildElements
in class AbstractPolicy
List
of CombinerElement
sProcessingException
- if the referenced policy can't be retrievedpublic Set getObligationExpressions()
getObligationExpressions
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic PolicyMetaData getMetaData()
getMetaData
in class AbstractPolicy
ProcessingException
- if the referenced policy can't be retrievedpublic MatchResult match(EvaluationCtx context)
match
in interface PolicyTreeElement
match
in class AbstractPolicy
context
- the representation of the requestpublic AbstractResult evaluate(EvaluationCtx context)
match
method must always be called first, and must always return
MATCH, before this method is called.evaluate
in interface PolicyTreeElement
evaluate
in class AbstractPolicy
context
- the representation of the requestpublic String encode()
PolicyReference
into its XML formString
public void encode(StringBuilder builder)
PolicyReference
into its XML form and writes this out to the provided
StringBuilder
builder
- string stream into which the XML-encoded data is writtenCopyright © 2021 WSO2. All rights reserved.