use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSAuthnRequest method toXMLString.
/**
* Creates a String representation of the <lib:AuthnRequest> 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.
* @throws FSMsgException if there is an error.
*/
public String toXMLString(boolean includeNS, boolean declareNS, boolean includeHeader) throws FSMsgException {
if (xmlString != null) {
return xmlString;
}
if ((providerId == null) || (providerId.length() == 0)) {
FSUtils.debug.error("FSAuthnRequest.toXMLString: " + "providerId is null in the request with requestId:" + requestID);
String[] args = { requestID };
throw new FSMsgException("nullProviderIdWRequestId", args);
}
if ((requestID == null) || (requestID.length() == 0)) {
requestID = SAMLUtils.generateID();
if (requestID == null) {
FSUtils.debug.error("FSAuthnRequest.toXMLString: " + "couldn't generate RequestID.");
throw new FSMsgException("errorGenerateID", null);
}
}
StringBuffer xml = new StringBuffer(300);
if (includeHeader) {
xml.append("<?xml version=\"1.0\" encoding=\"").append(IFSConstants.DEFAULT_ENCODING).append("\" ?>");
}
String prefix = "";
String samlpPrefix = "";
String uri = "";
String samlpUri = "";
if (includeNS) {
prefix = IFSConstants.LIB_PREFIX;
samlpPrefix = IFSConstants.PROTOCOL_PREFIX;
}
if (declareNS) {
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
uri = IFSConstants.LIB_12_NAMESPACE_STRING;
} else {
uri = IFSConstants.LIB_NAMESPACE_STRING;
}
samlpUri = IFSConstants.PROTOCOL_NAMESPACE_STRING;
}
String instantString = DateUtils.toUTCDateFormat(issueInstant);
if (requestID != null) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AUTHN_REQUEST).append(uri).append(IFSConstants.SPACE).append(samlpUri);
if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION && id != null && !(id.length() == 0)) {
xml.append(IFSConstants.SPACE).append(IFSConstants.ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(id).append(IFSConstants.QUOTE);
}
xml.append(IFSConstants.SPACE).append(IFSConstants.REQUEST_ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(requestID).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.MAJOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(majorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.MINOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(minorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.ISSUE_INSTANT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(instantString).append(IFSConstants.QUOTE);
if (consentURI != null) {
xml.append(IFSConstants.SPACE).append(IFSConstants.CONSENT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(consentURI).append(IFSConstants.QUOTE);
}
xml.append(IFSConstants.RIGHT_ANGLE);
if ((respondWiths != null) && (respondWiths != Collections.EMPTY_LIST)) {
Iterator i = respondWiths.iterator();
while (i.hasNext()) {
xml.append(IFSConstants.LEFT_ANGLE).append(samlpPrefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE).append((String) i.next()).append(IFSConstants.START_END_ELEMENT).append(samlpPrefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE);
}
}
if (signed) {
if (signatureString != null) {
xml.append(signatureString);
} else if (signature != null) {
signatureString = XMLUtils.print(signature);
xml.append(signatureString);
}
}
if ((extensions != null) && (!extensions.isEmpty())) {
for (Iterator iter = extensions.iterator(); iter.hasNext(); ) {
Extension extension = (Extension) iter.next();
extension.setMinorVersion(minorVersion);
xml.append(extension.toXMLString());
}
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE).append(providerId).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE);
if (affiliationID != null) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AFFILIATIONID).append(IFSConstants.RIGHT_ANGLE).append(affiliationID).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AFFILIATIONID).append(IFSConstants.RIGHT_ANGLE);
}
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
String strFederate = IFSConstants.NAME_ID_POLICY_NONE;
if (federate) {
strFederate = IFSConstants.NAME_ID_POLICY_FEDERATED;
if (nameIDPolicy != null && nameIDPolicy.length() > 0) {
strFederate = nameIDPolicy;
}
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.NAMEID_POLICY_ELEMENT).append(IFSConstants.RIGHT_ANGLE).append(strFederate).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.NAMEID_POLICY_ELEMENT).append(IFSConstants.RIGHT_ANGLE);
} else {
String strFederate = IFSConstants.FALSE;
if (federate) {
strFederate = IFSConstants.TRUE;
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.FEDERATE).append(IFSConstants.RIGHT_ANGLE).append(strFederate).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.FEDERATE).append(IFSConstants.RIGHT_ANGLE);
}
String strForceAuthn = IFSConstants.FALSE;
if (forceAuthn) {
strForceAuthn = IFSConstants.TRUE;
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.FORCE_AUTHN_ELEM).append(IFSConstants.RIGHT_ANGLE).append(strForceAuthn).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.FORCE_AUTHN_ELEM).append(IFSConstants.RIGHT_ANGLE);
String strIsPassive = IFSConstants.FALSE;
if (isPassive) {
strIsPassive = IFSConstants.TRUE;
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.IS_PASSIVE_ELEM).append(IFSConstants.RIGHT_ANGLE).append(strIsPassive).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.IS_PASSIVE_ELEM).append(IFSConstants.RIGHT_ANGLE);
if (protocolProfile != null && protocolProfile.length() != 0) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.PROTOCOL_PROFILE).append(IFSConstants.RIGHT_ANGLE).append(protocolProfile).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.PROTOCOL_PROFILE).append(IFSConstants.RIGHT_ANGLE);
}
if (assertionConsumerServiceID != null) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.ASSERTION_CONSUMER_SVC_ID).append(IFSConstants.RIGHT_ANGLE).append(assertionConsumerServiceID).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.ASSERTION_CONSUMER_SVC_ID).append(IFSConstants.RIGHT_ANGLE);
}
if (authnContext != null) {
authnContext.setMinorVersion(minorVersion);
xml.append(authnContext.toXMLString());
}
if (relayState != null && relayState.length() != 0) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE).append(XMLUtils.escapeSpecialCharacters(relayState)).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE);
}
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
if (scoping != null) {
xml.append(scoping.toXMLString(true, false));
}
}
if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
if (authContextCompType != null && authContextCompType.length() != 0) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AUTHN_CONTEXT_COMPARISON).append(IFSConstants.RIGHT_ANGLE).append(authContextCompType).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AUTHN_CONTEXT_COMPARISON).append(IFSConstants.RIGHT_ANGLE);
}
}
xml.append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AUTHN_REQUEST).append(IFSConstants.RIGHT_ANGLE);
} else {
FSUtils.debug.error("FSAuthnRequest.toString: requestID is null ");
throw new FSMsgException("nullAuthnRequestID", null);
}
return xml.toString();
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSAuthnResponse method toXMLString.
/**
* 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
*/
public String toXMLString(boolean includeNS, boolean declareNS, boolean includeHeader) throws FSMsgException {
FSUtils.debug.message("FSAuthnResponse.toXMLString(3): Called");
if ((providerId == null) || (providerId.length() == 0)) {
FSUtils.debug.error("FSAuthnResponse.toXMLString: " + "providerId is null ");
throw new FSMsgException("nullProviderID", null);
}
StringBuffer xml = new StringBuffer(300);
if (includeHeader) {
xml.append(IFSConstants.XML_PREFIX).append(SAMLConstants.DEFAULT_ENCODING).append("\" ?>\n").append(IFSConstants.QUOTE).append(IFSConstants.QUESTION_MARK).append(IFSConstants.RIGHT_ANGLE).append(IFSConstants.NL);
}
String prefixSAML = "";
String prefixLIB = "";
String prefixSAML_PROTOCOL = "";
String uriSAML_PROTOCOL = "";
String uriSAML = "";
String uriLIB = "";
String uriDS = "";
String uriXSI = "";
if (includeNS) {
prefixLIB = IFSConstants.LIB_PREFIX;
prefixSAML = IFSConstants.ASSERTION_PREFIX;
prefixSAML_PROTOCOL = IFSConstants.PROTOCOL_PREFIX;
}
if (declareNS) {
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
uriLIB = IFSConstants.LIB_12_NAMESPACE_STRING;
} else {
uriLIB = IFSConstants.LIB_NAMESPACE_STRING;
}
uriSAML = IFSConstants.assertionDeclareStr;
uriSAML_PROTOCOL = IFSConstants.PROTOCOL_NAMESPACE_STRING;
uriDS = IFSConstants.DSSAMLNameSpace;
uriXSI = IFSConstants.XSI_NAMESPACE_STRING;
}
String instantString = DateUtils.toUTCDateFormat(issueInstant);
if ((responseID != null) && (inResponseTo != null)) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefixLIB).append(IFSConstants.AUTHN_RESPONSE).append(uriLIB).append(uriSAML).append(uriSAML_PROTOCOL).append(IFSConstants.SPACE).append(uriDS).append(IFSConstants.SPACE).append(uriXSI).append(IFSConstants.SPACE).append(IFSConstants.RESPONSE_ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(responseID).append(IFSConstants.QUOTE).append(IFSConstants.SPACE);
if ((inResponseTo != null) && (inResponseTo.length() != 0)) {
xml.append(IFSConstants.SPACE).append(IFSConstants.IN_RESPONSE_TO).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(inResponseTo).append(IFSConstants.QUOTE);
}
if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION && id != null && (id.length() > 0)) {
xml.append(IFSConstants.SPACE).append(IFSConstants.ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(id).append(IFSConstants.QUOTE);
}
xml.append(IFSConstants.SPACE).append(IFSConstants.MAJOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(majorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.MINOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(minorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.ISSUE_INSTANT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(instantString).append(IFSConstants.QUOTE);
if (consentURI != null) {
xml.append(IFSConstants.SPACE).append(IFSConstants.CONSENT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(consentURI).append(IFSConstants.QUOTE).append(IFSConstants.SPACE);
}
if ((recipient != null) && (recipient.length() != 0)) {
xml.append(IFSConstants.SPACE).append(IFSConstants.RECIPIENT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(recipient).append(IFSConstants.QUOTE).append(IFSConstants.SPACE);
}
xml.append(IFSConstants.RIGHT_ANGLE);
}
if (signed) {
if (signatureString != null && signatureString.length() != 0) {
xml.append(signatureString);
} else if (signature != null) {
signatureString = XMLUtils.print(signature);
xml.append(signatureString);
}
}
if (status != null) {
xml.append(status.toString(includeNS, false));
}
if ((assertions != null) && (assertions != Collections.EMPTY_LIST)) {
Iterator j = assertions.iterator();
while (j.hasNext()) {
xml.append(((FSAssertion) j.next()).toXMLString(true, declareNS));
}
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefixLIB).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE).append(providerId).append(IFSConstants.START_END_ELEMENT).append(prefixLIB).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE);
if (relayState != null && relayState.length() != 0) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefixLIB).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE).append(XMLUtils.escapeSpecialCharacters(relayState)).append(IFSConstants.START_END_ELEMENT).append(prefixLIB).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE);
}
xml.append(IFSConstants.START_END_ELEMENT).append(prefixLIB).append(IFSConstants.AUTHN_RESPONSE).append(IFSConstants.RIGHT_ANGLE).append(IFSConstants.NL);
return xml.toString();
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSNameRegistrationRequest method toXMLString.
/**
* Returns a String representation of the Logout Response.
*
* @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
* @throws FSMsgException if there is an error converting
* this object ot a string.
*/
public String toXMLString(boolean includeNS, boolean declareNS, boolean includeHeader) throws FSMsgException {
if ((providerId == null) || (providerId.length() == 0)) {
FSUtils.debug.error("FSNameRegistrationRequest.toXMLString: " + "providerId is null in the request with requestId:" + requestID);
String[] args = { requestID };
throw new FSMsgException("nullProviderIdWRequestId", args);
}
if ((requestID == null) || (requestID.length() == 0)) {
requestID = SAMLUtils.generateID();
if (requestID == null) {
FSUtils.debug.error("FSNameRegistrationRequest.toXMLString: " + "couldn't generate RequestID.");
throw new FSMsgException("errorGenerateID", null);
}
}
StringBuffer xml = new StringBuffer(1000);
if (includeHeader) {
xml.append("<?xml version=\"1.0\" encoding=\"").append(IFSConstants.DEFAULT_ENCODING).append("\" ?>\n");
}
String prefix = "";
String uri = "";
String uriSAML = "";
if (includeNS) {
prefix = IFSConstants.LIB_PREFIX;
}
if (declareNS) {
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
uri = IFSConstants.LIB_12_NAMESPACE_STRING;
} else {
uri = IFSConstants.LIB_NAMESPACE_STRING;
}
uriSAML = IFSConstants.assertionDeclareStr;
}
String instantString = DateUtils.toUTCDateFormat(issueInstant);
if (requestID != null) {
xml.append("<").append(prefix).append("RegisterNameIdentifierRequest").append(uri).append(uriSAML);
if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION && id != null && !(id.length() == 0)) {
xml.append(" id=\"").append(id).append("\" ");
}
xml.append(" RequestID=\"").append(requestID).append("\" ").append(" MajorVersion=\"").append(majorVersion).append("\" ").append(" MinorVersion=\"").append(minorVersion).append("\" ").append(" IssueInstant=\"").append(instantString).append("\"").append(">");
if ((respondWiths != null) && (respondWiths != Collections.EMPTY_LIST)) {
Iterator i = respondWiths.iterator();
while (i.hasNext()) {
xml.append("<").append(prefix).append("RespondWith>").append((String) i.next()).append("</").append(prefix).append("RespondWith>");
}
}
if (signed) {
if (signatureString != null) {
xml.append(signatureString);
} else if (signature != null) {
signatureString = XMLUtils.print(signature);
xml.append(signatureString);
}
}
xml.append("<").append(prefix).append("ProviderID").append(">").append(providerId).append("</").append(prefix).append("ProviderID").append(">");
if (idpProvidedNameIdentifier != null && idpProvidedNameIdentifier.getName().length() != 0) {
xml.append(idpProvidedNameIdentifier.toXMLString());
}
if (spProvidedNameIdentifier != null && spProvidedNameIdentifier.getName().length() != 0) {
xml.append(spProvidedNameIdentifier.toXMLString());
}
if (oldProvidedNameIdentifier != null && oldProvidedNameIdentifier.getName().length() != 0) {
xml.append(oldProvidedNameIdentifier.toXMLString());
}
if (relayState != null) {
xml.append("<").append(prefix).append("RelayState").append(">").append(relayState).append("</").append(prefix).append("RelayState").append(">");
}
xml.append("</").append(prefix).append("RegisterNameIdentifierRequest>");
} else {
FSUtils.debug.error("FSNameRegistrationRequest.toString: " + "requestID is null ");
throw new FSMsgException("nullRequestID", null);
}
return xml.toString();
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSNameRegistrationResponse method parseURLEncodedRequest.
/**
* Returns <code>FSNameRegistrationLogoutResponse</code> object. The
* object is creating by parsing the <code>HttpServletRequest</code>
* object.
*
* @param request the <code>HttpServletRequest</code> object.
* @throws FSMsgException if there is an error
* creating this object.
*/
public static FSNameRegistrationResponse parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
FSNameRegistrationResponse retNameRegistrationResponse = new FSNameRegistrationResponse();
try {
FSUtils.debug.message("checking minor version");
retNameRegistrationResponse.majorVersion = Integer.parseInt(request.getParameter("MajorVersion"));
retNameRegistrationResponse.minorVersion = Integer.parseInt(request.getParameter("MinorVersion"));
} catch (NumberFormatException ex) {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: version parsing error:" + ex);
throw new FSMsgException("invalidNumber", null);
}
if (request.getParameter("ResponseID") != null) {
retNameRegistrationResponse.responseID = request.getParameter("ResponseID");
} else {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: Response ID is null");
String[] args = { IFSConstants.RESPONSE_ID };
throw new FSMsgException("missingAttribute", args);
}
String instantString = request.getParameter("IssueInstant");
if (instantString == null || instantString.length() == 0) {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: Issue Instant is null");
String[] args = { IFSConstants.ISSUE_INSTANT };
throw new FSMsgException("missingAttribute", args);
}
try {
retNameRegistrationResponse.issueInstant = DateUtils.stringToDate(instantString);
} catch (ParseException e) {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: Can not parse Issue Instant", e);
throw new FSMsgException("parseError", null);
}
if (request.getParameter("ProviderID") != null) {
retNameRegistrationResponse.providerId = request.getParameter("ProviderID");
} else {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: Provider ID is null ");
throw new FSMsgException("missingElement", null);
}
if (request.getParameter("RelayState") != null) {
retNameRegistrationResponse.relayState = request.getParameter("RelayState");
}
if (request.getParameter("InResponseTo") != null) {
retNameRegistrationResponse.inResponseTo = request.getParameter("InResponseTo");
}
if (request.getParameter("Value") != null) {
FSUtils.debug.message("Status : " + request.getParameter("Value"));
StatusCode statusCode = new StatusCode(request.getParameter("Value"));
retNameRegistrationResponse.status = new Status(statusCode);
} else {
FSUtils.debug.error("FSNameRegistrationResponse.parseURL" + "EncodedRequest: Status Value is null ");
throw new FSMsgException("missingElement", null);
}
FSUtils.debug.message("Returning registration response Object");
return retNameRegistrationResponse;
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSLogoutNotification method toXMLString.
/**
* Returns the string representation of this object.
*
* @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 <code>XML</code> for this element
* @throws FSMsgException if there is an error creating
* <code>XML</code> string from this object.
*/
public String toXMLString(boolean includeNS, boolean declareNS, boolean includeHeader) throws FSMsgException {
if ((providerId == null) || (providerId.length() == 0)) {
FSUtils.debug.error("FSLogoutNotification.toXMLString: " + "providerId is null in the request with requestId:" + requestID);
String[] args = { requestID };
throw new FSMsgException("nullProviderIdWRequestId", args);
}
if ((requestID == null) || (requestID.length() == 0)) {
requestID = SAMLUtils.generateID();
if (requestID == null) {
FSUtils.debug.error("FSLogoutNotification.toXMLString: " + "couldn't generate RequestID.");
throw new FSMsgException("errorGenerateID", null);
}
}
StringBuffer xml = new StringBuffer(300);
if (includeHeader) {
xml.append(IFSConstants.XML_PREFIX).append(IFSConstants.DEFAULT_ENCODING).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.QUESTION_MARK).append(IFSConstants.RIGHT_ANGLE).append(IFSConstants.NL);
}
String prefix = "";
String uri = "";
String uriSAML = "";
if (includeNS) {
prefix = IFSConstants.LIB_PREFIX;
}
if (declareNS) {
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
uri = IFSConstants.LIB_12_NAMESPACE_STRING;
} else {
uri = IFSConstants.LIB_NAMESPACE_STRING;
}
uriSAML = IFSConstants.assertionDeclareStr;
}
String instantString = DateUtils.toUTCDateFormat(issueInstant);
if (notOnOrAfter == null) {
notOnOrAfter = new Date(issueInstant.getTime() + IFSConstants.ASSERTION_TIMEOUT_ALLOWED_DIFFERENCE);
}
String notAfter = DateUtils.toUTCDateFormat(notOnOrAfter);
if (requestID != null) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.LOGOUT_REQUEST).append(uri).append(uriSAML);
if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION && id != null && !(id.length() == 0)) {
xml.append(IFSConstants.SPACE).append(IFSConstants.ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(id).append(IFSConstants.QUOTE).append(IFSConstants.SPACE);
}
xml.append(IFSConstants.SPACE).append(IFSConstants.REQUEST_ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(requestID).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.SPACE).append(IFSConstants.MAJOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(majorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.SPACE).append(IFSConstants.MINOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(minorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.SPACE).append(IFSConstants.ISSUE_INSTANT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(instantString).append(IFSConstants.QUOTE);
if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
xml.append(IFSConstants.SPACE).append(IFSConstants.NOT_ON_OR_AFTER).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(notAfter).append(IFSConstants.QUOTE);
}
xml.append(IFSConstants.RIGHT_ANGLE);
if ((respondWiths != null) && (respondWiths != Collections.EMPTY_LIST)) {
Iterator i = respondWiths.iterator();
while (i.hasNext()) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE).append((String) i.next()).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE);
}
}
if (signed) {
if (signatureString != null) {
xml.append(signatureString);
} else if (signature != null) {
signatureString = XMLUtils.print(signature);
xml.append(signatureString);
}
}
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.PROVIDER_ID).append(uri).append(IFSConstants.RIGHT_ANGLE).append(providerId).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE);
if (nameIdentifier != null) {
xml.append(nameIdentifier.toString());
}
if ((sessionIndex != null) && sessionIndex.length() != 0) {
xml.append("<").append(prefix).append("SessionIndex").append(uri).append(">").append(sessionIndex).append("</").append(prefix).append("SessionIndex").append(">");
}
if (relayState != null && relayState.length() != 0) {
xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.RELAY_STATE).append(uri).append(IFSConstants.RIGHT_ANGLE).append(relayState).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE);
}
xml.append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.LOGOUT_REQUEST).append(IFSConstants.RIGHT_ANGLE);
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLogoutNotification.toString: " + "requestID is null ");
}
throw new FSMsgException("nullRequestID", null);
}
return xml.toString();
}
Aggregations