Response.java revision b3b3b7da0bb140cb1fe4613cc2e322683dc034d5
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Response.java,v 1.3 2009/02/13 04:05:10 bina Exp $
*
*/
/**
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* This <code>Response</code> class represents a Response XML document.
* The schema of Response is defined as the following:
*
* @supported.all.api
*/
public class Response extends AbstractResponse {
// Response ID attribute name
/** default constructor */
protected Response() {}
/**
* Return whether the signature on the object is valid or not.
* @return true if the signature on the object is valid; false otherwise.
*/
public boolean isSignatureValid() {
if (signed & ! validationDone) {
validationDone = true;
}
return valid;
}
/**
* Method that signs the Response.
*
* @exception SAMLException if could not sign the Response.
*/
public void signXML() throws SAMLException {
if (signed) {
+ "already signed.");
}
throw new SAMLException(
}
"com.sun.identity.saml.xmlsig.certalias");
+ "this site's cert alias.");
}
throw new SAMLResponderException(
}
// this block is used for later return of signature element by
// getSignature() method
} else {
// sign with SAML 1.1 spec & include cert in KeyInfo
}
signed = true;
}
{
// generate one
if (this.responseID == null) {
throw new SAMLRequesterException(
}
} else {
this.responseID = responseID;
}
this.inResponseTo = inResponseTo;
issueInstant = new Date();
throw new SAMLRequesterException(
}
for (int i = 0; i < length; i++) {
+ "for Assertion.");
}
throw new SAMLRequesterException(
}
}
}
}
/**
* 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 unique <code>ResponseID</code>,
* <code>MajorVersion</code>, etc. to form a complete Response object.
*
* @param responseID If it's null, the constructor will create one.
* @param inResponseTo the <code>RequestID</code> that this response is
* corresponding. It could be null or empty string "".
* @param status The status of the response.
* @param 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.
*/
{
}
/**
* 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 unique <code>ResponseID</code>,
* <code>MajorVersion</code>, etc. to form a complete Response object.
*
* @param responseID If it's null, the constructor will create one.
* @param inResponseTo the <code>RequestID</code> that this response is
* corresponding. It could be null or empty string "".
* @param status The status of the response.
* @param recipient The intended recipient of the response. It could be
* null or empty string since it's optional.
* @param 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.
*/
{
}
/**
* 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 unique <code>ResponseID</code>,
* <code>MajorVersion</code>, etc. to form a complete Response object.
*
* @param responseID If it's null, the constructor will create one.
* @param status The status of the response.
* @param recipient The intended recipient of the response. It could be
* null or empty string since it's optional.
* @param 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.
*/
{
}
/**
* 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 unique <code>ResponseID</code>,
* <code>MajorVersion</code>, etc. to form a complete Response object.
*
* @param responseID If it's null, the constructor will create one.
* @param status The status of the response.
* @param 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.
*/
{
}
/**
* 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.
*
* @param xml The Response XML document String.
* NOTE: this is a complete SAML response XML string with
* <code>ResponseID</code>, <code>MajorVersion</code>, etc.
* @return Response object based on the XML document received from server.
* @exception SAMLException if XML parsing failed
*/
// parse the xml string
}
/**
* 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.
*
* @param is The Response XML <code>InputStream</code>.
* NOTE: The <code>InputStream</code> contains a complete
* SAML response with
* <code>ResponseID</code>, <code>MajorVersion</code>, etc.
* @return Response object based on the XML document received from server.
* @exception SAMLException if XML parsing failed
*/
}
/**
* Constructor.
*
* @param root <code>Response</code> element
* @throws SAMLException if error occurs.
*/
// Make sure this is a Response
throw new SAMLRequesterException(
}
throw new SAMLRequesterException(
}
if (signsSize == 1) {
signed = true;
} else if (signsSize != 0) {
+ " one Signature element.");
}
throw new SAMLRequesterException(
}
// Attribute ResponseID
+ "Reponse doesn't have ResponseID.");
}
throw new SAMLRequesterException(
}
// Attribute InResponseTo
}
// Attribute MajorVersion
}
// Attribute IssueInstant
throw new SAMLRequesterException(
} else {
try {
} catch (ParseException e) {
"Resposne(Element): could not parse IssueInstant", e);
"wrongInput"));
}
}
for (int i = 0; i < length; i++) {
+ " than one <Status>");
}
throw new SAMLRequesterException(
}
assertions = new ArrayList();
}
throw new SAMLRequesterException(
}
} else {
+ "element:" + childName);
}
throw new SAMLRequesterException(
}
} // end if childName != null
} // end for loop
throw new SAMLRequesterException(
}
}
/**
* Parse the input and set the majorVersion accordingly.
* @param majorVer a String representing the MajorVersion to be set.
* @exception SAMLException when the version mismatchs.
*/
try {
} catch (NumberFormatException e) {
+ "MajorVersion", e);
}
throw new SAMLRequesterException(
}
+ " the Response is too high.");
}
throw new SAMLVersionMismatchException(
} else {
+ " the Response is too low.");
}
throw new SAMLVersionMismatchException(
}
}
}
/**
* Parse the input and set the minorVersion accordingly.
* @param minorVer a String representing the MinorVersion to be set.
* @exception SAMLException when the version mismatchs.
*/
try {
} catch (NumberFormatException e) {
+ "MinorVersion", e);
}
throw new SAMLRequesterException(
}
+ " of the Response is too high.");
}
throw new SAMLRequestVersionTooHighException(
+ " of the Response is too low.");
}
throw new SAMLRequestVersionTooLowException(
}
}
/**
* This method returns the set of Assertions that is the content of
* the response.
* @return 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.
*/
public List getAssertion() {
return assertions;
}
/**
* Add an assertion to the Response.
* @param assertion The assertion to be added.
* @return A boolean value: true if the operation is successful;
* false otherwise.
*/
if (signed) {
return false;
}
return false;
}
assertions = new ArrayList();
}
return true;
}
/**
* Gets the Status of the Response.
* @return The Status of the response.
*/
return status;
}
/**
* Set the Status of the Response.
*
* @param status The Status of the Response to be set.
* @return true if the operation is successful.
*/
if (signed) {
return false;
}
return false;
}
return true;
}
/**
* Set the signature for the Response.
* @param elem ds:Signature element
* @return A boolean value: true if the operation succeeds; false otherwise.
*/
return super.setSignature(elem);
}
/**
* This method translates the response to an XML document String based on
* the Response schema described above.
* @return An XML String representing the response. NOTE: this is a
* complete SAML response XML string with <code>ResponseID</code>,
* <code>MajorVersion</code>, etc.
*/
return this.toString(true, true);
}
/**
* Creates a String representation of the
* <code><samlp:Response></code> element.
*
* @param includeNS Determines whether or not the namespace qualifier
* is prepended to the Element when converted
* @param declareNS Determines whether or not the namespace is declared
* within the Element.
* @return A string containing the valid XML for this element
*/
}
/**
* Creates a String representation of the
* <code><samlp:Response></code> element.
*
* @param includeNS Determines whether or not the namespace qualifier
* is prepended to the Element when converted
* @param declareNS Determines whether or not the namespace is declared
* within the Element.
* @param includeHeader Determines whether the output include the XML
* declaration header.
* @return A string containing the valid XML for this element
*/
boolean declareNS,
boolean includeHeader) {
return xmlString;
}
if (includeHeader) {
}
if (includeNS) {
}
if (declareNS) {
}
if (inResponseTo != null) {
}
}
if (signed) {
if (signatureString != null) {
}
}
while (j.hasNext()) {
}
}
}
}