Package com.sun.identity.saml2.common
Class SOAPCommunicator
- java.lang.Object
-
- com.sun.identity.saml2.common.SOAPCommunicator
-
public class SOAPCommunicator extends Object
The SOAPCommunicator is a utility package to assist in SAML2 communication over SOAP.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.xml.soap.SOAPMessagecreateSOAPFault(String faultCode, String faultString, String detail)Forms a SOAP Fault and puts it in the SOAP Message Body.jakarta.xml.soap.SOAPMessagecreateSOAPMessage(String xmlString, boolean isClientMessage)CreatesSOAPMessagewith the input XML String as message body.jakarta.xml.soap.SOAPMessagecreateSOAPMessage(String header, String body, boolean isClientMessage)CreatesSOAPMessagewith the input XML String as message header and body.jakarta.xml.soap.MimeHeadersgetHeaders(jakarta.servlet.http.HttpServletRequest req)Returns mime headers in HTTP servlet request.static SOAPCommunicatorgetInstance()Gets the singleton instance of the SOAPCommunicator.ElementgetSamlpElement(jakarta.xml.soap.SOAPMessage message, String localName)Returns first Element with given local name in samlp name space inside SOAP message.ElementgetSOAPBody(jakarta.xml.soap.SOAPMessage message)Returns SOAP body as DOM Element from SOAPMessage.jakarta.xml.soap.SOAPMessagegetSOAPMessage(jakarta.servlet.http.HttpServletRequest request)Returns SOAP Message fromHttpServletRequest.jakarta.xml.soap.SOAPConnectionopenSOAPConnection()Opens a SOAP Connection.jakarta.xml.soap.SOAPMessagesendSOAPMessage(String xmlMessage, String soapUrl, boolean isClientMessage)Send SOAP Message to specified url and returns message from peer.StringsoapMessageToString(jakarta.xml.soap.SOAPMessage message)Converts aSOAPMessageto aString.
-
-
-
Method Detail
-
getInstance
public static SOAPCommunicator getInstance()
Gets the singleton instance of the SOAPCommunicator.- Returns:
- the SOAPCommunicator instance.
-
openSOAPConnection
public jakarta.xml.soap.SOAPConnection openSOAPConnection() throws jakarta.xml.soap.SOAPExceptionOpens a SOAP Connection.- Returns:
- a new
SOAPConnection - Throws:
jakarta.xml.soap.SOAPException
-
createSOAPMessage
public jakarta.xml.soap.SOAPMessage createSOAPMessage(String xmlString, boolean isClientMessage) throws jakarta.xml.soap.SOAPException, SAML2Exception
CreatesSOAPMessagewith the input XML String as message body.- Parameters:
xmlString- XML string to be put intoSOAPMessagebody.isClientMessage- true if the message is sent from SOAP client to server.- Returns:
- newly created
SOAPMessage. - Throws:
jakarta.xml.soap.SOAPException- if it cannot create theSOAPMessage.SAML2Exception
-
createSOAPMessage
public jakarta.xml.soap.SOAPMessage createSOAPMessage(String header, String body, boolean isClientMessage) throws jakarta.xml.soap.SOAPException, SAML2Exception
CreatesSOAPMessagewith the input XML String as message header and body.- Parameters:
header- XML string to be put intoSOAPMessageheader.body- XML string to be put intoSOAPMessagebody.isClientMessage- true if the message is sent from SOAP client to server.- Returns:
- newly created
SOAPMessage. - Throws:
jakarta.xml.soap.SOAPException- if it cannot create theSOAPMessage.SAML2Exception
-
getSOAPBody
public Element getSOAPBody(jakarta.xml.soap.SOAPMessage message) throws SAML2Exception
Returns SOAP body as DOM Element from SOAPMessage.- Parameters:
message- SOAPMessage object.- Returns:
- SOAP body, return null if unable to get the SOAP body element.
- Throws:
SAML2Exception
-
createSOAPFault
public jakarta.xml.soap.SOAPMessage createSOAPFault(String faultCode, String faultString, String detail)
Forms a SOAP Fault and puts it in the SOAP Message Body.- Parameters:
faultCode- Fault code.faultString- Fault string.detail- Fault details.- Returns:
- SOAP Fault in the SOAP Message Body or null if unable to generate the message.
-
getSOAPMessage
public jakarta.xml.soap.SOAPMessage getSOAPMessage(jakarta.servlet.http.HttpServletRequest request) throws IOException, jakarta.xml.soap.SOAPExceptionReturns SOAP Message fromHttpServletRequest.- Parameters:
request-HttpServletRequestincludes SOAP Message.- Returns:
- SOAPMessage if request include any soap message in the header.
- Throws:
IOException- if error in creating input stream.jakarta.xml.soap.SOAPException- if error in creating soap message.
-
sendSOAPMessage
public jakarta.xml.soap.SOAPMessage sendSOAPMessage(String xmlMessage, String soapUrl, boolean isClientMessage) throws jakarta.xml.soap.SOAPException, SAML2Exception
Send SOAP Message to specified url and returns message from peer.- Parameters:
xmlMessage-Stringwill be sent.soapUrl- URL the mesaage send to.isClientMessage- true if the message is sent from SOAP client to server.- Returns:
- SOAPMessage if the peer send back any reply.
- Throws:
jakarta.xml.soap.SOAPException- if error in creating soap message.SAML2Exception- if error in creating soap message.
-
soapMessageToString
public String soapMessageToString(jakarta.xml.soap.SOAPMessage message)
Converts aSOAPMessageto aString.- Parameters:
message- SOAPMessage object.- Returns:
- the
Stringconverted from theSOAPMessageor null if an error ocurred.
-
getSamlpElement
public Element getSamlpElement(jakarta.xml.soap.SOAPMessage message, String localName) throws SAML2Exception
Returns first Element with given local name in samlp name space inside SOAP message.- Parameters:
message- SOAP message.localName- local name of the Element to be returned.- Returns:
- first Element matching the local name.
- Throws:
SAML2Exception- if the Element could not be found or there is SOAP Fault present.
-
getHeaders
public jakarta.xml.soap.MimeHeaders getHeaders(jakarta.servlet.http.HttpServletRequest req)
Returns mime headers in HTTP servlet request.- Parameters:
req- HTTP servlet request.- Returns:
- mime headers in HTTP servlet request.
-
-