Package com.sun.identity.saml.protocol
Class Response
- java.lang.Object
-
- com.sun.identity.saml.protocol.AbstractResponse
-
- com.sun.identity.saml.protocol.Response
-
- Direct Known Subclasses:
FSAuthnResponse,FSResponse
public class Response extends AbstractResponse
ThisResponseclass represents a Response XML document. The schema of Response is defined as the following:
-
-
Field Summary
Fields Modifier and Type Field Description protected Listassertionsprotected Stringissuerprotected StringsignatureStringprotected Statusstatusprotected StringxmlString-
Fields inherited from class com.sun.identity.saml.protocol.AbstractResponse
inResponseTo, issueInstant, majorVersion, minorVersion, recipient, responseID, signature, signed, valid, validationDone
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedResponse()default constructorResponse(String responseID, Status status, String recipient, List contents)This constructor shall only be used at the server side to construct a Response object.Response(String responseID, Status status, List contents)This constructor shall only be used at the server side to construct a Response object.Response(String responseID, String inResponseTo, Status status, String recipient, List contents)This constructor shall only be used at the server side to construct a Response object.Response(String responseID, String inResponseTo, Status status, List contents)This constructor shall only be used at the server side to construct a Response object.Response(Element root)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAssertion(Assertion assertion)Add an assertion to the Response.ListgetAssertion()This method returns the set of Assertions that is the content of the response.StatusgetStatus()Gets the Status of the Response.booleanisSignatureValid()Return whether the signature on the object is valid or not.static ResponseparseXML(InputStream is)Returns Response object based on the XML document received from server.static ResponseparseXML(String xml)Returns Response object based on the XML document received from server.booleansetSignature(Element elem)Set the signature for the Response.booleansetStatus(Status status)Set the Status of the Response.voidsignXML()Method that signs the Response.StringtoString()This method translates the response to an XML document String based on the Response schema described above.StringtoString(boolean includeNS, boolean declareNS)Creates a String representation of the<samlp:Response>element.StringtoString(boolean includeNS, boolean declareNS, boolean includeHeader)Creates a String representation of the<samlp:Response>element.-
Methods inherited from class com.sun.identity.saml.protocol.AbstractResponse
getInResponseTo, getIssueInstant, getMajorVersion, getMinorVersion, getRecipient, getResponseID, getSignature, isSigned, setInResponseTo, setIssueInstant, setMajorVersion, setMinorVersion, setRecipient, setResponseID
-
-
-
-
Constructor Detail
-
Response
protected Response()
default constructor
-
Response
public Response(String responseID, String inResponseTo, Status status, List contents) throws SAMLException
This constructor shall only be used at the server side to construct a Response object. NOTE: The content here is just the body for the Response. The constructor will add the uniqueResponseID,MajorVersion, etc. to form a complete Response object.- Parameters:
responseID- If it's null, the constructor will create one.inResponseTo- theRequestIDthat this response is corresponding. It could be null or empty string "".status- The status of the response.contents- A List of Assertions that are the content of the Response. It could be null when there is no Assertion.- Throws:
SAMLException- if error occurs.
-
Response
public Response(String responseID, String inResponseTo, Status status, String recipient, List contents) throws SAMLException
This constructor shall only be used at the server side to construct a Response object. NOTE: The content here is just the body for the Response. The constructor will add the uniqueResponseID,MajorVersion, etc. to form a complete Response object.- Parameters:
responseID- If it's null, the constructor will create one.inResponseTo- theRequestIDthat this response is corresponding. It could be null or empty string "".status- The status of the response.recipient- The intended recipient of the response. It could be null or empty string since it's optional.contents- A List of Assertions that are the content of the Response. It could be null when there is no Assertion.- Throws:
SAMLException- if error occurs.
-
Response
public Response(String responseID, Status status, String recipient, List contents) throws SAMLException
This constructor shall only be used at the server side to construct a Response object. NOTE: The content here is just the body for the Response. The constructor will add the uniqueResponseID,MajorVersion, etc. to form a complete Response object.- Parameters:
responseID- If it's null, the constructor will create one.status- The status of the response.recipient- The intended recipient of the response. It could be null or empty string since it's optional.contents- A List of Assertions that are the content of the Response. It could be null when there is no Assertion.- Throws:
SAMLException- if error occurs.
-
Response
public Response(String responseID, Status status, List contents) throws SAMLException
This constructor shall only be used at the server side to construct a Response object. NOTE: The content here is just the body for the Response. The constructor will add the uniqueResponseID,MajorVersion, etc. to form a complete Response object.- Parameters:
responseID- If it's null, the constructor will create one.status- The status of the response.contents- A List of Assertions that are the content of the Response. It could be null when there is no Assertion.- Throws:
SAMLException- if error occurs.
-
Response
public Response(Element root) throws SAMLException
Constructor.- Parameters:
root-Responseelement- Throws:
SAMLException- if error occurs.
-
-
Method Detail
-
isSignatureValid
public boolean isSignatureValid()
Return whether the signature on the object is valid or not.- Overrides:
isSignatureValidin classAbstractResponse- Returns:
- true if the signature on the object is valid; false otherwise.
-
signXML
public void signXML() throws SAMLExceptionMethod that signs the Response.- Specified by:
signXMLin classAbstractResponse- Throws:
SAMLException- if could not sign the Response.
-
parseXML
public static Response parseXML(String xml) throws SAMLException
Returns Response object based on the XML document received from server. This method is used primarily at the client side. The schema of the XML document is describe above.- Parameters:
xml- The Response XML document String. NOTE: this is a complete SAML response XML string withResponseID,MajorVersion, etc.- Returns:
- Response object based on the XML document received from server.
- Throws:
SAMLException- if XML parsing failed
-
parseXML
public static Response parseXML(InputStream is) throws SAMLException
Returns Response object based on the XML document received from server. This method is used primarily at the client side. The schema of the XML document is describe above.- Parameters:
is- The Response XMLInputStream. NOTE: TheInputStreamcontains a complete SAML response withResponseID,MajorVersion, etc.- Returns:
- Response object based on the XML document received from server.
- Throws:
SAMLException- if XML parsing failed
-
getAssertion
public List getAssertion()
This method returns the set of Assertions that is the content of the response.- Returns:
- The set of Assertions that is the content of the response. It could be Collections.EMPTY_LIST when there is no Assertion in the response.
-
addAssertion
public boolean addAssertion(Assertion assertion)
Add an assertion to the Response.- Parameters:
assertion- The assertion to be added.- Returns:
- A boolean value: true if the operation is successful; false otherwise.
-
getStatus
public Status getStatus()
Gets the Status of the Response.- Returns:
- The Status of the response.
-
setStatus
public boolean setStatus(Status status)
Set the Status of the Response.- Parameters:
status- The Status of the Response to be set.- Returns:
- true if the operation is successful.
-
setSignature
public boolean setSignature(Element elem)
Set the signature for the Response.- Overrides:
setSignaturein classAbstractResponse- Parameters:
elem- ds:Signature element- Returns:
- A boolean value: true if the operation succeeds; false otherwise.
-
toString
public String toString()
This method translates the response to an XML document String based on the Response schema described above.
-
toString
public String toString(boolean includeNS, boolean declareNS)
Creates a String representation of the<samlp:Response>element.- Parameters:
includeNS- Determines whether or not the namespace qualifier is prepended to the Element when converteddeclareNS- Determines whether or not the namespace is declared within the Element.- Returns:
- A string containing the valid XML for this element
-
toString
public String toString(boolean includeNS, boolean declareNS, boolean includeHeader)
Creates a String representation of the<samlp:Response>element.- Parameters:
includeNS- Determines whether or not the namespace qualifier is prepended to the Element when converteddeclareNS- Determines whether or not the namespace is declared within the Element.includeHeader- Determines whether the output include the XML declaration header.- Returns:
- A string containing the valid XML for this element
-
-