/*
* 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 legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at 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 copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/**
* The SOAPCommunicator is a utility package to assist in SAML2 communication over SOAP.
*/
public class SOAPCommunicator {
private SOAPCommunicator() {
try {
} catch (SOAPException se) {
}
}
/**
* Gets the singleton instance of the SOAPCommunicator.
*
* @return the SOAPCommunicator instance.
*/
return instance;
}
/**
* Opens a SOAP Connection.
*
* @return a new <code>SOAPConnection</code>
* @throws if there was an exception creating the
* <code>SOAPConnection</code> object.
*/
return soapConnectionFactory.createConnection();
}
/**
* Creates <code>SOAPMessage</code> with the input XML String
* as message body.
*
* @param xmlString XML string to be put into <code>SOAPMessage</code> body.
* @param isClientMessage true if the message is sent from SOAP client to
* server.
* @return newly created <code>SOAPMessage</code>.
* @throws SOAPException if it cannot create the
* <code>SOAPMessage</code>.
*/
final boolean isClientMessage)
throws SOAPException, SAML2Exception {
}
/**
* Creates <code>SOAPMessage</code> with the input XML String
* as message header and body.
*
* @param header XML string to be put into <code>SOAPMessage</code> header.
* @param body XML string to be put into <code>SOAPMessage</code> body.
* @param isClientMessage true if the message is sent from SOAP client to
* server.
* @return newly created <code>SOAPMessage</code>.
* @throws SOAPException if it cannot create the <code>SOAPMessage</code>.
*/
final boolean isClientMessage)
throws SOAPException, SAML2Exception {
try {
if (isClientMessage) {
}
if (debug.messageEnabled()) {
}
.append(":Header>");
}
.append(":Body>");
}
if (debug.messageEnabled()) {
}
} catch (IOException io) {
}
}
/**
* Returns SOAP body as DOM Element from SOAPMessage.
*
* @param message SOAPMessage object.
* @return SOAP body, return null if unable to get the SOAP body element.
*/
throws SAML2Exception {
// check the SOAP message for any SOAP
// related errors before passing control to SAML processor
try {
} catch (IOException ie) {
} catch (SOAPException se) {
}
if (debug.messageEnabled()) {
}
}
"element is not Envelope or invalid name space or prefix");
}
if (length <= 0) {
}
for (int i = 0; i < length; i++) {
continue;
}
if (debug.messageEnabled()) {
}
// found the Body element
}
}
"missingSOAPBody"));
}
/**
* Forms a SOAP Fault and puts it in the SOAP Message Body.
*
* @param faultCode Fault code.
* @param faultString Fault string.
* @param detail Fault details.
* @return SOAP Fault in the SOAP Message Body or null if unable to generate the message.
*/
final String faultString,
try {
"Problem"));
}
return message;
} catch (SOAPException e) {
return null;
}
}
/**
* Returns SOAP Message from <code>HttpServletRequest</code>.
*
* @param request <code>HttpServletRequest</code> includes SOAP Message.
* @return SOAPMessage if request include any soap message in the header.
* @throws IOException if error in creating input stream.
* @throws SOAPException if error in creating soap message.
*/
throws IOException, SOAPException {
// Get all the headers from the HTTP request
// Get the body of the HTTP request
// Create a SOAPMessage
}
/**
* Send SOAP Message to specified url and returns message from peer.
*
* @param xmlMessage <code>String</code> will be sent.
* @param soapUrl URL the mesaage send to.
* @param isClientMessage true if the message is sent from SOAP client to
* server.
* @return SOAPMessage if the peer send back any reply.
* @throws SOAPException if error in creating soap message.
* @throws SAML2Exception if error in creating soap message.
*/
final boolean isClientMessage)
throws SOAPException, SAML2Exception {
}
/**
* Converts a <code>SOAPMessage</code> to a <code>String</code>.
*
* @param message SOAPMessage object.
* @return the <code>String</code> converted from the
* <code>SOAPMessage</code> or null if an error ocurred.
*/
try {
} catch (IOException ie) {
return null;
} catch (SOAPException soapex) {
return null;
}
}
/**
* Returns first Element with given local name in samlp name space inside
* SOAP message.
*
* @param message SOAP message.
* @param localName local name of the Element to be returned.
* @return first Element matching the local name.
* @throws SAML2Exception if the Element could not be found or there is
* SOAP Fault present.
*/
if (childNodeLength <= 0) {
}
for (int i = 0; i < childNodeLength; i++) {
continue;
}
if (debug.messageEnabled()) {
}
"soapFaultInSOAPResponse"));
node.getNamespaceURI())) {
break;
}
}
if (returnElement == null) {
}
return returnElement;
}
/**
* Returns mime headers in HTTP servlet request.
*
* @param req HTTP servlet request.
* @return mime headers in HTTP servlet request.
*/
while (e.hasMoreElements()) {
while (values.hasMoreTokens()) {
}
}
if (debug.messageEnabled()) {
}
return headers;
}
}