/**
* 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: FSAuthnResponse.java,v 1.2 2008/06/25 05:46:43 qcheng Exp $
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* The class <code>FSAuthnResponse</code> creates and parses the
* Liberty Response. This class extends the <code>SAML</code>
* <code>Response</code>.
*
* @supported.all.api
* @deprecated since 12.0.0
*/
/**
* Constructor to create <code>FSAuthnResponse</code> object.
*
* @param responseID value of the <code>ResponseID</code> attribute.
* @param inResponseTo value of the <code>inResponseTo</code> attribute.
* @param status the <code>Status</code> object.
* @param contents List of Assertions in the response.
* It could be null when there are no Assertions.
* @param relayState value of the <code>RelayState</code> attribute.
* @throws FSMsgException on error.
* @throws SAMLException on error.
*/
throws SAMLException, FSMsgException {
setIssueInstant(new Date());
this.relayState = relayState;
}
/**
* Creates <code>FSAuthnResponse</code> object from XML Schema.
*
* @param xml the XML Schema for this object.
* @throws <code>SAMLException</code> on error.
* @throws FSMsgException on error.
*/
// parse the xml string
"FSAuthnResponse.parseXML:Error "
+ "while parsing input xml string");
}
}
return new FSAuthnResponse(root);
}
/**
* Constructor creates <code>FSAuthnResponse</code> object from
* Document Element.
*
* @param root the Document Element
* @throws SAMLException on error.
* @throws FSMsgException on error.
*/
// Make sure this is a Response
+ "Input paramenter (root) is null");
}
+ "Root element name is not AuthnResponse");
}
domElement = root;
// Attribute ResponseID
+ "AuthnResponse doesn't have ResponseID attribute");
}
}
if (inResponseTo == null) {
+ "AuthnResponse doesn't have InResponseTo attribute");
}
}
// Attribute IssueInstant
+ " missing IssueInstant");
} else {
try {
} catch (ParseException e) {
"FSAuthnResponse(Element): could not parse IssueInstant",e);
}
}
for (int i = 0; i < length; i++) {
+ "included more than one <Status>");
}
}
assertions = new ArrayList();
}
// make sure the providerId is not assigned already
if (relayState != null) {
+ "should contain only one RelayState.");
}
}
+ "should contain only one ProviderID.");
}
}
} else {
+ "included wrong element: " + childName);
}
}
} // end if childName != null
} // end for loop
+ "missing element <Status>.");
}
//check for signature
if (signsSize == 1) {
signed = true;
} else if (signsSize != 0) {
+ "included more than one Signature element.");
}
}
//end check for signature
}
/**
* Returns the value of the <code>id</code> attribute.
*
* @return the value of <code>id</code> attribute.
* @see #setID(String)
*/
return id;
}
/**
* Sets the value of the <code>id</code> attribute.
*
* @param id the new value of <code>id</code> attribute.
* @see #getID
*/
}
/**
* Returns the <code>ProviderID</code> attribute value.
*
* @return value of the <code>ProviderID</code> attribute.
* @see #setProviderId(String)
*/
return providerId;
}
/**
* Sets the <code>ProviderID</code> attribute value.
*
* @param provId new value of <code>ProviderID</code> attribute.
* @see #getProviderId
*/
providerId = provId;
}
/**
* Returns a signed XML Representation of this object.
*
* @return a signed XML Representation of this object.
*/
return xmlString;
}
/**
* Returns the Signature string.
*
* @return the Signature string.
*/
return signatureString;
}
/**
* Returns the value <code>MinorVersion</code> attribute.
*
* @return the value <code>MinorVersion</code> attribute.
* @see #setMinorVersion(int)
*/
public int getMinorVersion() {
return minorVersion;
}
/**
* Returns the value of <code>MajorVersion</code> attribute.
*
* @param version the value of <code>MajorVersion</code> attribute.
* @see #getMinorVersion
*/
}
/**
* Returns the value of the <code>consent</code> attribute.
*
* @return value of <code>consent</code> attribute.
* @see #setConsentURI(String)
*/
return consentURI;
}
/**
* Sets the value of the <code>consent</code> attribute.
*
* @param consent new value of <code>consent</code> attribute.
* @see #getConsentURI
*/
this.consentURI = consent;
}
/**
* Returns the Document Element for this object.
*
* @return the Document Element for this object.
*/
return domElement;
}
/**
* Parses the input and sets the <code>MajorVersion</code>.
*
* @param majorVer value of <code>MajorVersion</code> attribute to be set.
* @throws FSMsgException on error.
* @throws SAMLException if the version is incorrect.
*/
throws SAMLException, FSMsgException {
try {
} catch (NumberFormatException e) {
+ "MajorVersion", e);
}
}
"FSAuthnResponse(Element):MajorVersion of"
+ " the Response is too high.");
}
"responseVersionTooHigh",null);
} else {
"FSAuthnResponse(Element):MajorVersion of"
+ " the Response is too low.");
}
throw new SAMLVersionMismatchException(
}
}
}
/**
* Parses the input and set the <code>MinorVersion</code>.
*
* @param minorVer value of <code>MinorVersion</code> attribute to be set.
* @throws FSMsgException on error.
* @throws SAMLException if the version is incorrect.
*/
private void parseMinorVersion(
try {
} catch (NumberFormatException e) {
+ "MinorVersion", e);
}
}
" Minor Version of the AuthnResponse is too high.");
}
" Minor Version of the AuthnResponse is too low.");
}
}
}
/**
* Returns the <code>RelayState</code> attribute in the Response.
*
* @return the <code>RelayState</code> attribute in the Response.
*/
return relayState;
}
/**
* Returns the string representation of this object.
* 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 ResponseID,
* MajorVersion, etc.
*/
return this.toXMLString(true, true);
}
/**
* Returns a String representation of the <samlp:Response> 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
*/
throws FSMsgException {
}
/**
* Returns a String representation of the <samlp:Response> 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) throws FSMsgException {
+ "providerId is null ");
}
if (includeHeader) {
}
if (includeNS) {
}
if (declareNS) {
} else {
}
}
}
}
if (consentURI != null) {
}
}
}
if (signed) {
}
}
}
while (j.hasNext()) {
.toXMLString(true,declareNS));
}
}
}
}
/**
* Returns <code>FSAutnResponse</code> object by parsing a
* <code>Base64</code> encoding XML string.
*
*
* @param encodedRes the <code>Base64</code> encoded string.
* @return <code>FSAuthnResponse</code> object.
* @throws FSMsgException if there is an error parsing
* the <code>Base64</code> encoded string.
* @throws SAMLException if there is an error creating
* the <code>FSAuthnResponse</code> object.
*/
throws FSMsgException, SAMLException {
"FSAuthnResponse.parseBASE64EncodedString: Called new");
if(encodedRes != null){
"FSAuthnResponse.parseBASE64EncodedString: "
+ "Decoded AuthnResponse message: \n"
+ decodedAuthnRes);
}
return parseAuthnResponseXML(decodedAuthnRes);
} else {
"FSAuthnResponse.parseBASE64EncodedString: "
+ "null String passed in as argument.");
}
}
}
/**
* Returns a <code>Base64</code> encoded string representing this
* object.
*
* @return a <code>Base64</code> encoded string representing this
* object.
* @throws FSMsgException if there is an error creating
* a <code>Base64</code> encoded string.
*/
if (responseID == null) {
+ "couldn't generate ResponseID.");
}
}
}
/**
* Signs the <code>Response</code>.
*
* @param certAlias the Certificate Alias
* @throws SAMLException if <code>Response</code>
* cannot be signed.
*/
if (signed) {
"FSAuthnResponse.signXML: the assertion is "
+ "already signed.");
}
throw new SAMLResponderException(
}
throw new SAMLResponderException(
}
try{
this.id, false);
} else if (minorVersion ==
this.toXMLString(true, true),
this.getResponseID(), false);
} else {
}
}
signed = true;
xmlString = this.toXMLString(true, true);
} catch(Exception e) {
"signFailed",null);
}
}
/**
* Sets the <code>Element</code> signature.
*
* @param elem the <code>Element</code> object
* @return true if signature is set otherwise false
*/
return super.setSignature(elem);
}
}