org.wso2.balana.xacml2
Class Target

java.lang.Object
  extended by org.wso2.balana.AbstractTarget
      extended by org.wso2.balana.xacml2.Target

public class Target
extends AbstractTarget

Represents the TargetType XML type in XACML. This also stores several other XML types: Subjects, Resources, Actions, and Environments (in XACML 2.0 and later). The target is used to quickly identify whether the parent element (a policy set, policy, or rule) is applicable to a given request.

Since:
1.0
Author:
Seth Proctor

Constructor Summary
Target(TargetSection subjectsSection, TargetSection resourcesSection, TargetSection actionsSection)
          Constructor that creates an XACML 1.x Target from components.
Target(TargetSection subjectsSection, TargetSection resourcesSection, TargetSection actionsSection, TargetSection environmentsSection)
          Constructor that creates an XACML 2.0 Target from components.
 
Method Summary
 String encode()
          Encodes this Target into its XML form
 void encode(StringBuilder builder)
          Encodes this Target into its XML form and writes this out to the provided StringBuilder
 TargetSection getActionsSection()
          Returns the Actions section of this Target.
 TargetSection getEnvironmentsSection()
          Returns the Environments section of this Target.
static Target getInstance(Node root, PolicyMetaData metaData)
          Creates a Target by parsing a node.
static Target getInstance(Node root, String xpathVersion)
          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.
 TargetSection getResourcesSection()
          Returns the Resources section of this Target.
 TargetSection getSubjectsSection()
          Returns the Subjects section of this Target.
 MatchResult match(EvaluationCtx context)
          Determines whether this Target matches the input request (whether it is applicable).
 boolean matchesAny()
          Returns whether or not this Target matches any request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Target

public Target(TargetSection subjectsSection,
              TargetSection resourcesSection,
              TargetSection actionsSection)
Constructor that creates an XACML 1.x Target from components. Each of the sections must be non-null, but they may match any request. Because this is only used for 1.x Targets, there is no Environments section.

Parameters:
subjectsSection - a TargetSection representing the Subjects section of this target
resourcesSection - a TargetSection representing the Resources section of this target
actionsSection - a TargetSection representing the Actions section of this target

Target

public Target(TargetSection subjectsSection,
              TargetSection resourcesSection,
              TargetSection actionsSection,
              TargetSection environmentsSection)
Constructor that creates an XACML 2.0 Target from components. Each of the sections must be non-null, but they may match any request.

Parameters:
subjectsSection - a TargetSection representing the Subjects section of this target
resourcesSection - a TargetSection representing the Resources section of this target
actionsSection - a TargetSection representing the Actions section of this target
environmentsSection - a TargetSection representing the Environments section of this target
Method Detail

getInstance

public static Target getInstance(Node root,
                                 String xpathVersion)
                          throws ParsingException
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.

Creates a Target by parsing a node.

Parameters:
root - the node to parse for the Target
xpathVersion - the XPath version to use in any selectors, or null if this is unspecified (ie, not supplied in the defaults section of the policy)
Returns:
a new Target constructed by parsing
Throws:
ParsingException - if the DOM node is invalid

getInstance

public static Target getInstance(Node root,
                                 PolicyMetaData metaData)
                          throws ParsingException
Creates a Target by parsing a node.

Parameters:
root - the node to parse for the Target
metaData -
Returns:
a new Target constructed by parsing
Throws:
ParsingException - if the DOM node is invalid

getSubjectsSection

public TargetSection getSubjectsSection()
Returns the Subjects section of this Target.

Returns:
a TargetSection representing the Subjects

getResourcesSection

public TargetSection getResourcesSection()
Returns the Resources section of this Target.

Returns:
a TargetSection representing the Resources

getActionsSection

public TargetSection getActionsSection()
Returns the Actions section of this Target.

Returns:
a TargetSection representing the Actions

getEnvironmentsSection

public TargetSection getEnvironmentsSection()
Returns the Environments section of this Target. Note that if this is an XACML 1.x policy, then the section will always match anything, since XACML 1.x doesn't support matching on the Environment.

Returns:
a TargetSection representing the Environments

matchesAny

public boolean matchesAny()
Returns whether or not this Target matches any request.

Returns:
true if this Target matches any request, false otherwise

match

public MatchResult match(EvaluationCtx context)
Determines whether this Target matches the input request (whether it is applicable).

Specified by:
match in class AbstractTarget
Parameters:
context - the representation of the request
Returns:
the result of trying to match the target and the request

encode

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

Specified by:
encode in class AbstractTarget
Returns:
String

encode

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

Specified by:
encode in class AbstractTarget
Parameters:
builder - string stream into which the XML-encoded data is written


Copyright © 2015 WSO2. All rights reserved.