SunTM's XACML Implementation for JavaTM

com.sun.xacml.ctx
Class Result

java.lang.Object
  extended bycom.sun.xacml.ctx.Result

public class Result
extends Object

Represents the ResultType XML object from the Context schema. Any number of these may included in a ResponseCtx. This class encodes the decision effect, as well as an optional resource identifier and optional status data. Any number of obligations may also be included.

Since:
1.0

Field Summary
static int DECISION_DENY
          The decision to deny the request
static int DECISION_INDETERMINATE
          The decision that a decision about the request cannot be made
static int DECISION_NOT_APPLICABLE
          The decision that nothing applied to us
static int DECISION_PERMIT
          The decision to permit the request
static String[] DECISIONS
           
 
Constructor Summary
Result(int decision)
          Constructs a Result object with default status data (OK).
Result(int decision, Set obligations)
          Constructs a Result object with default status data (OK), and obligations, but no resource identifier.
Result(int decision, Status status)
          Constructs a Result object with status data but without a resource identifier.
Result(int decision, Status status, Set obligations)
          Constructs a Result object with status data and obligations but without a resource identifier.
Result(int decision, Status status, String resource)
          Constructs a Result object with status data and a resource identifier.
Result(int decision, Status status, String resource, Set obligations)
          Constructs a Result object with status data, a resource identifier, and obligations.
Result(int decision, String resource)
          Constructs a Result object with a resource identifier, but default status data (OK).
Result(int decision, String resource, Set obligations)
          Constructs a Result object with a resource identifier, and obligations, but default status data (OK).
 
Method Summary
 void addObligation(Obligation obligation)
          Adds an obligation to the set of obligations that the PEP must fulfill
 void encode(OutputStream output)
          Encodes this Result into its XML form and writes this out to the provided OutputStream with no indentation.
 void encode(OutputStream output, Indenter indenter)
          Encodes this Result into its XML form and writes this out to the provided OutputStream with indentation.
 int getDecision()
          Returns the decision associated with this Result.
static Result getInstance(Node root)
          Creates a new instance of a Result based on the given DOM root node.
 Set getObligations()
          Returns the set of obligations that the PEP must fulfill, which may be empty.
 String getResource()
          Returns the resource to which this Result applies, or null if none is specified.
 Status getStatus()
          Returns the status data included in this Result.
 boolean setResource(String resource)
          Sets the resource identifier if it has not already been set before.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DECISION_PERMIT

public static final int DECISION_PERMIT
The decision to permit the request

See Also:
Constant Field Values

DECISION_DENY

public static final int DECISION_DENY
The decision to deny the request

See Also:
Constant Field Values

DECISION_INDETERMINATE

public static final int DECISION_INDETERMINATE
The decision that a decision about the request cannot be made

See Also:
Constant Field Values

DECISION_NOT_APPLICABLE

public static final int DECISION_NOT_APPLICABLE
The decision that nothing applied to us

See Also:
Constant Field Values

DECISIONS

public static final String[] DECISIONS
Constructor Detail

Result

public Result(int decision)
       throws IllegalArgumentException
Constructs a Result object with default status data (OK).

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              Set obligations)
       throws IllegalArgumentException
Constructs a Result object with default status data (OK), and obligations, but no resource identifier.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
obligations - the obligations the PEP must handle
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              Status status)
       throws IllegalArgumentException
Constructs a Result object with status data but without a resource identifier. Typically the decision is DECISION_INDETERMINATE in this case, though that's not always true.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
status - the Status to include in this result
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              Status status,
              Set obligations)
       throws IllegalArgumentException
Constructs a Result object with status data and obligations but without a resource identifier. Typically the decision is DECISION_INDETERMINATE in this case, though that's not always true.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
status - the Status to include in this result
obligations - the obligations the PEP must handle
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              String resource)
       throws IllegalArgumentException
Constructs a Result object with a resource identifier, but default status data (OK). The resource being named must match the resource (or a descendent of the resource in the case of a hierarchical resource) from the associated request.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
resource - a String naming the resource
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              String resource,
              Set obligations)
       throws IllegalArgumentException
Constructs a Result object with a resource identifier, and obligations, but default status data (OK). The resource being named must match the resource (or a descendent of the resource in the case of a hierarchical resource) from the associated request.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
resource - a String naming the resource
obligations - the obligations the PEP must handle
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              Status status,
              String resource)
       throws IllegalArgumentException
Constructs a Result object with status data and a resource identifier.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
status - the Status to include in this result
resource - a String naming the resource
Throws:
IllegalArgumentException - if decision is not valid

Result

public Result(int decision,
              Status status,
              String resource,
              Set obligations)
       throws IllegalArgumentException
Constructs a Result object with status data, a resource identifier, and obligations.

Parameters:
decision - the decision effect to include in this result. This must be one of the four fields in this class.
status - the Status to include in this result
resource - a String naming the resource
obligations - the obligations the PEP must handle
Throws:
IllegalArgumentException - if decision is not valid
Method Detail

getInstance

public static Result getInstance(Node root)
                          throws ParsingException
Creates a new instance of a Result based on the given DOM root node. A ParsingException is thrown if the DOM root doesn't represent a valid ResultType.

Parameters:
root - the DOM root of a ResultType
Returns:
a new Result
Throws:
ParsingException - if the node is invalid

getDecision

public int getDecision()
Returns the decision associated with this Result. This will be one of the four DECISION_* fields in this class.

Returns:
the decision effect

getStatus

public Status getStatus()
Returns the status data included in this Result. Typically this will be STATUS_OK except when the decision is INDETERMINATE.

Returns:
status associated with this Result

getResource

public String getResource()
Returns the resource to which this Result applies, or null if none is specified.

Returns:
a resource identifier or null

setResource

public boolean setResource(String resource)
Sets the resource identifier if it has not already been set before. The core code does not set the resource identifier, so this is useful if you want to write wrapper code that needs this information.

Parameters:
resource - the resource identifier
Returns:
true if the resource identifier was set, false if it already had a value

getObligations

public Set getObligations()
Returns the set of obligations that the PEP must fulfill, which may be empty.

Returns:
the set of obligations

addObligation

public void addObligation(Obligation obligation)
Adds an obligation to the set of obligations that the PEP must fulfill

Parameters:
obligation - the Obligation to add

encode

public void encode(OutputStream output)
Encodes this Result into its XML form and writes this out to the provided 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 Result into its XML form and writes this out to the provided OutputStream with indentation.

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

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.