JBoss port of sunxacml 2.0.5

org.jboss.security.xacml.sunxacml
Class TargetMatch

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.TargetMatch

public class TargetMatch
extends Object

Represents the SubjectMatch, ResourceMatch, ActionMatch, or EnvironmentMatch (in XACML 2.0 and later) XML types in XACML, depending on the value of the type field. This is the part of the Target that actually evaluates whether the specified attribute values in the Target match the corresponding attribute values in the request context.

Since:
1.0
Author:
Seth Proctor

Field Summary
static int ACTION
          An integer value indicating that this class represents an ActionMatch
static int ENVIRONMENT
          An integer value indicating that this class represents an EnvironmentMatch
static String[] NAMES
          Mapping from the 4 match types to their string representations
static int RESOURCE
          An integer value indicating that this class represents a ResourceMatch
static int SUBJECT
          An integer value indicating that this class represents a SubjectMatch
 
Constructor Summary
TargetMatch(int type, Function function, Evaluatable eval, AttributeValue attrValue)
          Constructor that creates a TargetMatch from components.
 
Method Summary
 void encode(OutputStream output)
          Encodes this TargetMatch into its XML representation and writes this encoding to the given OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this TargetMatch into its XML representation and writes this encoding to the given OutputStream with indentation.
static TargetMatch getInstance(Node root, int matchType, PolicyMetaData metaData)
          Creates a TargetMatch by parsing a node, using the input prefix to determine whether this is a SubjectMatch, ResourceMatch, or ActionMatch.
static TargetMatch getInstance(Node root, String prefix, 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.
 Evaluatable getMatchEvaluatable()
          Returns the AttributeDesignator or AttributeSelector used by the matching function.
 Function getMatchFunction()
          Returns the Function used to do the matching.
 AttributeValue getMatchValue()
          Returns the AttributeValue used by the matching function.
 int getType()
          Returns the type of this TargetMatch, either SUBJECT, RESOURCE, ACTION, or ENVIRONMENT.
 MatchResult match(EvaluationCtx context)
          Determines whether this TargetMatch matches the input request (whether it is applicable)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUBJECT

public static final int SUBJECT
An integer value indicating that this class represents a SubjectMatch

See Also:
Constant Field Values

RESOURCE

public static final int RESOURCE
An integer value indicating that this class represents a ResourceMatch

See Also:
Constant Field Values

ACTION

public static final int ACTION
An integer value indicating that this class represents an ActionMatch

See Also:
Constant Field Values

ENVIRONMENT

public static final int ENVIRONMENT
An integer value indicating that this class represents an EnvironmentMatch

See Also:
Constant Field Values

NAMES

public static final String[] NAMES
Mapping from the 4 match types to their string representations

Constructor Detail

TargetMatch

public TargetMatch(int type,
                   Function function,
                   Evaluatable eval,
                   AttributeValue attrValue)
            throws IllegalArgumentException
Constructor that creates a TargetMatch from components.

Parameters:
type - an integer indicating whether this class represents a SubjectMatch, ResourceMatch, or ActionMatch
function - the Function that represents the MatchId
eval - the AttributeDesignator or AttributeSelector to be used to select attributes from the request context
attrValue - the AttributeValue to compare against
Throws:
IllegalArgumentException - if the input type isn't a valid value
Method Detail

getInstance

public static TargetMatch getInstance(Node root,
                                      String prefix,
                                      String xpathVersion)
                               throws ParsingException,
                                      IllegalArgumentException
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 TargetMatch by parsing a node, using the input prefix to determine whether this is a SubjectMatch, ResourceMatch, or ActionMatch.

Parameters:
root - the node to parse for the TargetMatch
prefix - a String indicating what type of TargetMatch to instantiate (Subject, Resource, or Action)
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 TargetMatch constructed by parsing
Throws:
ParsingException - if there was an error during parsing
IllegalArgumentException - if the input prefix isn't a valid value

getInstance

public static TargetMatch getInstance(Node root,
                                      int matchType,
                                      PolicyMetaData metaData)
                               throws ParsingException
Creates a TargetMatch by parsing a node, using the input prefix to determine whether this is a SubjectMatch, ResourceMatch, or ActionMatch.

Parameters:
root - the node to parse for the TargetMatch
matchType - the type of TargetMatch as specified by the SUBJECT, RESOURCE, ACTION, or ENVIRONMENT fields
metaData - the policy's meta-data
Returns:
a new TargetMatch constructed by parsing
Throws:
ParsingException - if there was an error during parsing

getType

public int getType()
Returns the type of this TargetMatch, either SUBJECT, RESOURCE, ACTION, or ENVIRONMENT.

Returns:
the type

getMatchFunction

public Function getMatchFunction()
Returns the Function used to do the matching.

Returns:
the match function

getMatchValue

public AttributeValue getMatchValue()
Returns the AttributeValue used by the matching function.

Returns:
the AttributeValue for the match

getMatchEvaluatable

public Evaluatable getMatchEvaluatable()
Returns the AttributeDesignator or AttributeSelector used by the matching function.

Returns:
the designator or selector for the match

match

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

Parameters:
context - the representation of the request
Returns:
the result of trying to match the TargetMatch and the request

encode

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

Parameters:
output - a stream into which the XML-encoded data is written

encode

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

Parameters:
output - a stream into which the XML-encoded data is written
indenter - an object that creates indentation strings

JBoss port of sunxacml 2.0.5

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.