org.opensaml
Class SAMLResponse

java.lang.Object
  extended by org.opensaml.SAMLObject
      extended by org.opensaml.SAMLSignedObject
          extended by org.opensaml.SAMLResponse
All Implemented Interfaces:
Cloneable

public class SAMLResponse
extends SAMLSignedObject

Represents a SAML protocol response

Author:
Scott Cantor

Field Summary
protected  ArrayList assertions
           
protected  SAMLException e
           
protected  String inResponseTo
           
protected  Date issueInstant
           
protected  int minor
           
protected  String recipient
           
protected  String responseId
           
 
Fields inherited from class org.opensaml.SAMLObject
config, dirty, log, parentObject, root
 
Constructor Summary
SAMLResponse()
          Default constructor
SAMLResponse(Element e)
          Reconstructs a response from a DOM tree
SAMLResponse(InputStream in)
          Reconstructs a response from a stream
SAMLResponse(InputStream in, int minor)
          Reconstructs a response of a particular minor version from a stream
SAMLResponse(String responseId, Date issueInstant, String inResponseTo, String recipient, Collection assertions, SAMLException e)
          Builds a SAML response out of its component parts
SAMLResponse(String inResponseTo, String recipient, Collection assertions, SAMLException e)
          Builds a SAML response out of its component parts
 
Method Summary
 void addAssertion(SAMLAssertion assertion)
          Adds an assertion to the response
protected  Element buildRoot(Document doc, boolean xmlns)
          Delegates the process of building the root element of an object and inserting appropriate namespaces.
 void checkValidity()
          Evaluates the object's content to see if it is currently valid if serialized.
 Object clone()
          Copies a SAML object such that no dependencies exist between the original and the copy
 void fromDOM(Element e)
          Initialization of an object from a DOM element
 Iterator getAssertions()
          Gets the SAML assertions contained in the response, if any
 String getId()
          Gets the response ID
 String getInResponseTo()
          Gets the InResponseTo attribute
 Date getIssueInstant()
          Gets the issue timestamp of the SAML response
 int getMinorVersion()
          Gets the MinorVersion of the response.
 String getRecipient()
          Gets the Recipient attribute of the SAML response
 SAMLException getStatus()
          Gets the SAML Status contained in the response, if any (a SAMLException object is used to express the information, even in a successful case)
protected  void insertSignature()
          Places the signature into the object's DOM to prepare for signing
 void removeAssertion(int index)
          Removes assertion by position (zero-based)
 void setAssertions(Collection assertions)
          Sets the SAML assertions to include in the response
 void setId(String id)
          Sets the response ID NOTE: Use this method with caution.
 void setInResponseTo(String inResponseTo)
          Sets the InResponseTo attribute
 void setIssueInstant(Date issueInstant)
          Sets the issue timestamp of the response
 void setMinorVersion(int minor)
          Sets the MinorVersion of the response
 void setRecipient(String recipient)
          Sets the Recipient attribute
 void setStatus(SAMLException e)
          Sets the SAML status to include in the response
 Node toDOM(Document doc, boolean xmlns)
          Transforms the object into a DOM tree using an existing document context
 
Methods inherited from class org.opensaml.SAMLSignedObject
getDigestAlgorithm, getNativeSignature, getSignatureAlgorithm, getSignatureElement, getX509Certificates, isSigned, setDirty, sign, sign, toDOM, unsign, verify, verify, verify
 
Methods inherited from class org.opensaml.SAMLObject
fromStream, fromStream, getParent, plantRoot, setParent, toBase64, toDOM, toDOM, toStream, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minor

protected int minor

responseId

protected String responseId

inResponseTo

protected String inResponseTo

issueInstant

protected Date issueInstant

recipient

protected String recipient

assertions

protected ArrayList assertions

e

protected SAMLException e
Constructor Detail

SAMLResponse

public SAMLResponse()
Default constructor


SAMLResponse

public SAMLResponse(String inResponseTo,
                    String recipient,
                    Collection assertions,
                    SAMLException e)
             throws SAMLException
Builds a SAML response out of its component parts

Parameters:
inResponseTo - The request ID that prompted the response, if any
recipient - The URL of the intended recipient of the response
assertions - The SAML assertion(s) to return in the response, if any
e - The SAML error status information to return in the response, if any
Throws:
SAMLException - Raised if a response cannot be constructed from the supplied information

SAMLResponse

public SAMLResponse(String responseId,
                    Date issueInstant,
                    String inResponseTo,
                    String recipient,
                    Collection assertions,
                    SAMLException e)
             throws SAMLException
Builds a SAML response out of its component parts

Parameters:
responseId - Unique identifier for response
issueInstant - Time of issuance
inResponseTo - The request ID that prompted the response, if any
recipient - The URL of the intended recipient of the response
assertions - The SAML assertion(s) to return in the response, if any
e - The SAML error status information to return in the response, if any
Throws:
SAMLException - Raised if a response cannot be constructed from the supplied information

SAMLResponse

public SAMLResponse(Element e)
             throws SAMLException
Reconstructs a response from a DOM tree

Parameters:
e - The root of a DOM tree
Throws:
SAMLException - Thrown if the object cannot be constructed

SAMLResponse

public SAMLResponse(InputStream in)
             throws SAMLException
Reconstructs a response from a stream

Parameters:
in - A stream containing XML
Throws:
SAMLException - Raised if an exception occurs while constructing the object.

SAMLResponse

public SAMLResponse(InputStream in,
                    int minor)
             throws SAMLException
Reconstructs a response of a particular minor version from a stream

Parameters:
in - A stream containing XML
minor - The minor version of the incoming response
Throws:
SAMLException - Raised if an exception occurs while constructing the object.
Method Detail

insertSignature

protected void insertSignature()
                        throws SAMLException
Places the signature into the object's DOM to prepare for signing

Specified by:
insertSignature in class SAMLSignedObject
Throws:
SAMLException - Thrown if an error occurs while placing the signature

fromDOM

public void fromDOM(Element e)
             throws SAMLException
Description copied from class: SAMLObject
Initialization of an object from a DOM element

Overrides:
fromDOM in class SAMLSignedObject
Parameters:
e - Root element of a DOM tree
Throws:
SAMLException - Raised if an exception occurs while constructing the object
See Also:
SAMLObject.fromDOM(org.w3c.dom.Element)

getMinorVersion

public int getMinorVersion()
Gets the MinorVersion of the response.

Returns:
The minor version

setMinorVersion

public void setMinorVersion(int minor)
Sets the MinorVersion of the response

Parameters:
minor - The minor version

getId

public String getId()
Gets the response ID

Specified by:
getId in class SAMLSignedObject
Returns:
The response ID

setId

public void setId(String id)
Sets the response ID NOTE: Use this method with caution. Responses must contain unique identifiers and only specialized applications should need to explicitly assign an identifier.

Parameters:
id - The response ID

getInResponseTo

public String getInResponseTo()
Gets the InResponseTo attribute

Returns:
The InResponseTo value

setInResponseTo

public void setInResponseTo(String inResponseTo)
Sets the InResponseTo attribute

Parameters:
inResponseTo - The InResponseTo value

getIssueInstant

public Date getIssueInstant()
Gets the issue timestamp of the SAML response

Returns:
The issue timestamp

setIssueInstant

public void setIssueInstant(Date issueInstant)
Sets the issue timestamp of the response

Parameters:
issueInstant - The issue timestamp

getRecipient

public String getRecipient()
Gets the Recipient attribute of the SAML response

Returns:
The Recipient value

setRecipient

public void setRecipient(String recipient)
Sets the Recipient attribute

Parameters:
recipient - The Recipient value

getAssertions

public Iterator getAssertions()
Gets the SAML assertions contained in the response, if any

Returns:
The assertions in the response

setAssertions

public void setAssertions(Collection assertions)
                   throws SAMLException
Sets the SAML assertions to include in the response

Parameters:
assertions - The assertions to include
Throws:
SAMLException - Raised if the assertions are invalid

addAssertion

public void addAssertion(SAMLAssertion assertion)
                  throws SAMLException
Adds an assertion to the response

Parameters:
assertion - The assertion to add
Throws:
SAMLException - Raised if the assertion is invalid

removeAssertion

public void removeAssertion(int index)
                     throws IndexOutOfBoundsException
Removes assertion by position (zero-based)

Parameters:
index - The position of the assertion to remove
Throws:
IndexOutOfBoundsException

getStatus

public SAMLException getStatus()
Gets the SAML Status contained in the response, if any (a SAMLException object is used to express the information, even in a successful case)

Returns:
The status information in the response

setStatus

public void setStatus(SAMLException e)
               throws SAMLException
Sets the SAML status to include in the response

Parameters:
assertions - The status to include
Throws:
SAMLException - Raised if the status cannot be set or is invalid

buildRoot

protected Element buildRoot(Document doc,
                            boolean xmlns)
Description copied from class: SAMLObject
Delegates the process of building the root element of an object and inserting appropriate namespaces.

Specified by:
buildRoot in class SAMLObject
Parameters:
doc - The document context to use
xmlns - Include namespace(s) on root element?
Returns:
A new root element for the object
See Also:
SAMLObject.buildRoot(org.w3c.dom.Document,boolean)

toDOM

public Node toDOM(Document doc,
                  boolean xmlns)
           throws SAMLException
Description copied from class: SAMLObject
Transforms the object into a DOM tree using an existing document context

Overrides:
toDOM in class SAMLObject
Parameters:
doc - A Document object to use in manufacturing the tree
xmlns - Include namespace(s) on root element?
Returns:
Root element node of the DOM tree capturing the object
Throws:
SAMLException - Raised if the object is incompletely defined
See Also:
SAMLObject.toDOM(org.w3c.dom.Document,boolean)

checkValidity

public void checkValidity()
                   throws SAMLException
Description copied from class: SAMLObject
Evaluates the object's content to see if it is currently valid if serialized. Does not evaluate embedded objects except on the basis of whether they exist. For example, an Assertion must have a Statement, but if an invalid statement is added, SAMLAssertion.checkValidity() would succeed, while SAMLStatement.checkValidity would raise an exception.

Specified by:
checkValidity in class SAMLObject
Throws:
SAMLException - Raised if the serialized object would be invalid SAML, excluding any embedded objects
See Also:
SAMLObject.checkValidity()

clone

public Object clone()
             throws CloneNotSupportedException
Copies a SAML object such that no dependencies exist between the original and the copy

Overrides:
clone in class SAMLSignedObject
Returns:
The new object
Throws:
CloneNotSupportedException
See Also:
Object.clone()


Copyright ? 2005 UCAID. All Rights Reserved.