Class Message
- java.lang.Object
-
- com.sun.identity.liberty.ws.soapbinding.Message
-
public class Message extends Object
TheMessageclass is used by web service client and server to construct request or response. It will be sent over the SOAP connection. TheMessagecontains SOAP headers and bodies. The SOAP binding defines the following headers:CorrelationHeader,ProviderHeader,ConsentHeader,UsageDirectiveHeader,ProcessingContextHeaderandServiceInstanceUpdateHeader. The first 2 are required and the others are optional. Signing is mandatory forCorrelationHeaderand SOAP Body element which is the parent of the bodies. Other headers are optional, so each header needs to have a flag to specify whether it needs to be signed or not. For each header that needs to be signed, it must have an id attribute in the top element. The constuctor will take a SAML assertion or cert alias in order to sign.
-
-
Field Summary
Fields Modifier and Type Field Description static intANONYMOUSanonymous profile is specified.static intBEARER_TOKENBearer Token profile is specified.static StringCLIENT_TLS_BEARERAuthentication mechanism "urn:liberty:security:2004-04:ClientTLS:Bearer"static StringCLIENT_TLS_BEARER_WSF11Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:Bearer"static StringCLIENT_TLS_NULLAuthentication mechanism "urn:liberty:security:2003-08:ClientTLS:null"static StringCLIENT_TLS_SAMLAuthentication mechanism "urn:liberty:security:2003-08:ClientTLS:SAML"static StringCLIENT_TLS_SAML_WSF11Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:SAML"static StringCLIENT_TLS_X509Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:X509"static StringCLIENT_TLS_X509_WSF11Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:X509"static StringNULL_BEARERAuthentication mechanism "urn:liberty:security:2004-04:null:Bearer"static StringNULL_BEARER_WSF11Authentication mechanism "urn:liberty:security:2005-02:null:Bearer"static StringNULL_NULLAuthentication mechanism "urn:liberty:security:2003-08:null:null"static StringNULL_SAMLAuthentication mechanism "urn:liberty:security:2003-08:null:SAML"static StringNULL_SAML_WSF11Authentication mechanism "urn:liberty:security:2005-02:null:SAML"static StringNULL_X509Authentication mechanism "urn:liberty:security:2003-08:null:X509"static StringNULL_X509_WSF11Authentication mechanism "urn:liberty:security:2005-02:null:X509"static intSAML_TOKENSAML Token profile is specified.static StringTLS_BEARERAuthentication mechanism "urn:liberty:security:2004-04:TLS:Bearer"static StringTLS_BEARER_WSF11Authentication mechanism "urn:liberty:security:2005-02:TLS:Bearer"static StringTLS_NULLAuthentication mechanism "urn:liberty:security:2003-08:TLS:null"static StringTLS_SAMLAuthentication mechanism "urn:liberty:security:2003-08:TLS:SAML"static StringTLS_SAML_WSF11Authentication mechanism "urn:liberty:security:2005-02:TLS:SAML"static StringTLS_X509Authentication mechanism "urn:liberty:security:2003-08:TLS:X509"static StringTLS_X509_WSF11Authentication mechanism "urn:liberty:security:2005-02:TLS:X509"static intX509_TOKENX509 Token profile is specified.
-
Constructor Summary
Constructors Constructor Description Message()Default Constructor.Message(ProviderHeader providerHeader)The default constructor uses default cert alias defined in AMConfig for signing.Message(ProviderHeader providerHeader, BinarySecurityToken token)This constructor takes a binary security token for signing.Message(ProviderHeader providerHeader, SecurityAssertion assertion)This constructor takes a SAML assertion for signing.Message(SOAPFault soapFault)This constructor is to create a SOAP fault message.Message(jakarta.xml.soap.SOAPMessage soapMessage)This constructor takes a SOAP message which is received from a SOAP connection.Message(InputStream inputStream)This constructor takes an InputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecurityAssertiongetAssertion()Returns the SAML assertion used for signing.StringgetAuthenticationMechanism()Gets authentication mechanism.BinarySecurityTokengetBinarySecurityToken()Returns a binary security token used for signing.ListgetBodies()Returns a list of SOAP bodies.ListgetBodies(String namespaceURI, String localName)Returns a list of SOAP bodies.ConsentHeadergetConsentHeader()Returns theConsentHeader.CorrelationHeadergetCorrelationHeader()Returns theCorrelationHeader.StringgetIPAddress()Returns the IP address of remote site of the SOAP connection.X509CertificategetMessageCertificate()Returns the X509 certificate used in message level authentication.ListgetOtherSecurityHeaders()Returns a list of security header except the SAML assertion used in SAML token profile or the binary security token used in X509 token profile.ListgetOtherSOAPHeaders()Returns a list of SOAP headers exceptCorrelationHeader,ConsentHeader,UsageDirectiveHeaderandSecurityheader.X509CertificategetPeerCertificate()Returns the X509 certificate used in client authentication.ProcessingContextHeadergetProcessingContextHeader()Returns theProcessingContextHeader.ProviderHeadergetProviderHeader()Returns theProviderHeader.intgetSecurityProfileType()Gets security profile type.ServiceInstanceUpdateHeadergetServiceInstanceUpdateHeader()Returns theServiceInstanceUpdateHeader.ListgetSigningIds()Returns a list of id's for signing.SOAPFaultgetSOAPFault()Returns theSOAPFault.ObjectgetToken()Returns a token for the sender of this Message.ListgetUsageDirectiveHeaders()Returns a list ofUsageDirectiveHeader.StringgetWSFVersion()Returns the web services version of the message.booleanisClientAuthentication()Returns a boolean flag to determine if this Message will be sent to a server that requires client authentication.voidsetBinarySecurityToken(BinarySecurityToken binaryToken)Sets a binary security token for this message.voidsetClientAuthentication(boolean clientAuthentication)Sets a boolean flag.voidsetConsentHeader(ConsentHeader consentHeader)SetsConsentHeader.voidsetCorrelationHeader(CorrelationHeader correlationHeader)Sets theCorrelationHeader.voidsetOtherSecurityHeader(Element header)Sets a security header.voidsetOtherSecurityHeaders(List headers)Sets a list of security headers.voidsetOtherSOAPHeader(Element header, String signingId)Sets a SOAP header exceptCorrelationHeader,ConsentHeaderandUsageDirectiveHeader.voidsetOtherSOAPHeaders(List headers, List signingIds)Sets a list of SOAP headers exceptCorrelationHeader,ConsentHeader,UsageDirectiveHeaderand 'Security' header.voidsetProcessingContextHeader(ProcessingContextHeader processingContextHeader)Sets theProcessingContextHeader.voidsetProviderHeader(ProviderHeader providerHeader)SetsProviderHeaderif it is not null.voidsetSecurityProfileType(int profileType)Sets security profile type.voidsetServiceInstanceUpdateHeader(ServiceInstanceUpdateHeader serviceInstanceUpdateHeader)Sets theServiceInstanceUpdateHeader.voidsetSOAPBodies(List bodies)Sets a list of SOAP bodies.voidsetSOAPBody(Element body)Sets a SOAP body.voidsetSOAPFault(SOAPFault soapFault)Sets theSOAPFault.voidsetUsageDirectiveHeaders(List usageDirectiveHeaders)Sets a list ofUsageDirectiveHeader.voidsetWSFVersion(String version)Sets the web services version to the message.DocumenttoDocument()Returns the SOAP message inorg.w3c.dom.Documentformat.DocumenttoDocument(boolean refresh)Returns the SOAP message inorg.w3c.dom.Documentformat.StringtoString()Returns the SOAP message in String format.
-
-
-
Field Detail
-
ANONYMOUS
public static final int ANONYMOUS
anonymous profile is specified.- See Also:
- Constant Field Values
-
X509_TOKEN
public static final int X509_TOKEN
X509 Token profile is specified.- See Also:
- Constant Field Values
-
SAML_TOKEN
public static final int SAML_TOKEN
SAML Token profile is specified.- See Also:
- Constant Field Values
-
BEARER_TOKEN
public static final int BEARER_TOKEN
Bearer Token profile is specified.- See Also:
- Constant Field Values
-
NULL_NULL
public static final String NULL_NULL
Authentication mechanism "urn:liberty:security:2003-08:null:null"- See Also:
- Constant Field Values
-
NULL_X509
public static final String NULL_X509
Authentication mechanism "urn:liberty:security:2003-08:null:X509"- See Also:
- Constant Field Values
-
NULL_SAML
public static final String NULL_SAML
Authentication mechanism "urn:liberty:security:2003-08:null:SAML"- See Also:
- Constant Field Values
-
NULL_BEARER
public static final String NULL_BEARER
Authentication mechanism "urn:liberty:security:2004-04:null:Bearer"- See Also:
- Constant Field Values
-
TLS_NULL
public static final String TLS_NULL
Authentication mechanism "urn:liberty:security:2003-08:TLS:null"- See Also:
- Constant Field Values
-
TLS_X509
public static final String TLS_X509
Authentication mechanism "urn:liberty:security:2003-08:TLS:X509"- See Also:
- Constant Field Values
-
TLS_SAML
public static final String TLS_SAML
Authentication mechanism "urn:liberty:security:2003-08:TLS:SAML"- See Also:
- Constant Field Values
-
TLS_BEARER
public static final String TLS_BEARER
Authentication mechanism "urn:liberty:security:2004-04:TLS:Bearer"- See Also:
- Constant Field Values
-
CLIENT_TLS_NULL
public static final String CLIENT_TLS_NULL
Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:null"- See Also:
- Constant Field Values
-
CLIENT_TLS_X509
public static final String CLIENT_TLS_X509
Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:X509"- See Also:
- Constant Field Values
-
CLIENT_TLS_SAML
public static final String CLIENT_TLS_SAML
Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:SAML"- See Also:
- Constant Field Values
-
CLIENT_TLS_BEARER
public static final String CLIENT_TLS_BEARER
Authentication mechanism "urn:liberty:security:2004-04:ClientTLS:Bearer"- See Also:
- Constant Field Values
-
NULL_X509_WSF11
public static final String NULL_X509_WSF11
Authentication mechanism "urn:liberty:security:2005-02:null:X509"- See Also:
- Constant Field Values
-
TLS_X509_WSF11
public static final String TLS_X509_WSF11
Authentication mechanism "urn:liberty:security:2005-02:TLS:X509"- See Also:
- Constant Field Values
-
CLIENT_TLS_X509_WSF11
public static final String CLIENT_TLS_X509_WSF11
Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:X509"- See Also:
- Constant Field Values
-
NULL_SAML_WSF11
public static final String NULL_SAML_WSF11
Authentication mechanism "urn:liberty:security:2005-02:null:SAML"- See Also:
- Constant Field Values
-
TLS_SAML_WSF11
public static final String TLS_SAML_WSF11
Authentication mechanism "urn:liberty:security:2005-02:TLS:SAML"- See Also:
- Constant Field Values
-
CLIENT_TLS_SAML_WSF11
public static final String CLIENT_TLS_SAML_WSF11
Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:SAML"- See Also:
- Constant Field Values
-
NULL_BEARER_WSF11
public static final String NULL_BEARER_WSF11
Authentication mechanism "urn:liberty:security:2005-02:null:Bearer"- See Also:
- Constant Field Values
-
TLS_BEARER_WSF11
public static final String TLS_BEARER_WSF11
Authentication mechanism "urn:liberty:security:2005-02:TLS:Bearer"- See Also:
- Constant Field Values
-
CLIENT_TLS_BEARER_WSF11
public static final String CLIENT_TLS_BEARER_WSF11
Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:Bearer"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Message
public Message()
Default Constructor.
-
Message
public Message(ProviderHeader providerHeader) throws SOAPBindingException
The default constructor uses default cert alias defined in AMConfig for signing.- Parameters:
providerHeader-ProviderHeader.- Throws:
SOAPBindingException- if provider header is null.
-
Message
public Message(ProviderHeader providerHeader, SecurityAssertion assertion) throws SOAPBindingException
This constructor takes a SAML assertion for signing.- Parameters:
providerHeader-ProviderHeaderassertion- a SAML assertion- Throws:
SOAPBindingException- if an error occurs while processing the SAML assertion or the provider header is null
-
Message
public Message(ProviderHeader providerHeader, BinarySecurityToken token) throws SOAPBindingException
This constructor takes a binary security token for signing.- Parameters:
providerHeader-ProviderHeadertoken- a binary security token- Throws:
SOAPBindingException- if an error occurs while processing the token or the provider header is null
-
Message
public Message(SOAPFault soapFault)
This constructor is to create a SOAP fault message.- Parameters:
soapFault-SOAPFault
-
Message
public Message(InputStream inputStream) throws SOAPBindingException
This constructor takes an InputStream.- Parameters:
inputStream- an InputStream- Throws:
SOAPBindingException- if an error occurs while parsing the input.
-
Message
public Message(jakarta.xml.soap.SOAPMessage soapMessage) throws SOAPBindingException, SOAPFaultExceptionThis constructor takes a SOAP message which is received from a SOAP connection.- Parameters:
soapMessage- a SOAP message- Throws:
SOAPBindingException- if an error occurs while parsing the SOAP messageSOAPFaultException
-
-
Method Detail
-
getSecurityProfileType
public int getSecurityProfileType()
Gets security profile type. Possible values are ANONYMOUS, X509_TOKEN and SAML_TOKEN.- Returns:
- the Security Profile type
-
setSecurityProfileType
public void setSecurityProfileType(int profileType)
Sets security profile type.- Parameters:
profileType- Profile Type. Possible values are ANONYMOUS, X509_TOKEN , SAML_TOKEN and BEARER_TOKEN
-
setBinarySecurityToken
public void setBinarySecurityToken(BinarySecurityToken binaryToken)
Sets a binary security token for this message.- Parameters:
binaryToken- a binary security token
-
getAuthenticationMechanism
public String getAuthenticationMechanism()
Gets authentication mechanism. Possible values are NULL_NULL,NULL_X509, NULL_SAML, TLS_NULL, TLS_X509, TLS_SAML, CLIENT_TLS_NULL,CLIENT_TLS_X509, CLIENT_TLS_SAML, NULL_BEAER, TLS_BEARER, and CLIENT_TLS_BEARER.- Returns:
- an authentication mechanism
-
isClientAuthentication
public boolean isClientAuthentication()
Returns a boolean flag to determine if this Message will be sent to a server that requires client authentication.- Returns:
- true if this Message will be sent to a server that requires client authentication
-
getCorrelationHeader
public CorrelationHeader getCorrelationHeader()
Returns theCorrelationHeader.- Returns:
- the
CorrelationHeader.
-
getConsentHeader
public ConsentHeader getConsentHeader()
Returns theConsentHeader.- Returns:
- the
ConsentHeader.
-
getUsageDirectiveHeaders
public List getUsageDirectiveHeaders()
Returns a list ofUsageDirectiveHeader.- Returns:
- a list of
UsageDirectiveHeader.
-
getProviderHeader
public ProviderHeader getProviderHeader()
Returns theProviderHeader.- Returns:
- the
ProviderHeader.
-
getProcessingContextHeader
public ProcessingContextHeader getProcessingContextHeader()
Returns theProcessingContextHeader.- Returns:
- the
ProcessingContextHeader.
-
getServiceInstanceUpdateHeader
public ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader()
Returns theServiceInstanceUpdateHeader.- Returns:
- the
ServiceInstanceUpdateHeader.
-
getOtherSOAPHeaders
public List getOtherSOAPHeaders()
Returns a list of SOAP headers exceptCorrelationHeader,ConsentHeader,UsageDirectiveHeaderandSecurityheader. Each entry will be aorg.w3c.dom.Element.- Returns:
- a list of SOAP headers
-
getSOAPFault
public SOAPFault getSOAPFault()
Returns theSOAPFault.- Returns:
- the
SOAPFault.
-
getBodies
public List getBodies()
Returns a list of SOAP bodies. Each entry will be aorg.w3c.dom.Element.- Returns:
- a list of SOAP bodies
-
getBodies
public List getBodies(String namespaceURI, String localName)
Returns a list of SOAP bodies. Each entry will be aorg.w3c.dom.Elementwith specified namespace URI and local name.- Parameters:
namespaceURI- namspace URIlocalName- local name- Returns:
- a list of SOAP bodies
-
getOtherSecurityHeaders
public List getOtherSecurityHeaders()
Returns a list of security header except the SAML assertion used in SAML token profile or the binary security token used in X509 token profile. Each entry will be aorg.w3c.dom.Element.- Returns:
- a list of security headers
-
getAssertion
public SecurityAssertion getAssertion()
Returns the SAML assertion used for signing.- Returns:
- the SAML assertion.
-
getBinarySecurityToken
public BinarySecurityToken getBinarySecurityToken()
Returns a binary security token used for signing.- Returns:
- a binary security token.
-
getPeerCertificate
public X509Certificate getPeerCertificate()
Returns the X509 certificate used in client authentication.- Returns:
- a X509 certificate
-
getMessageCertificate
public X509Certificate getMessageCertificate()
Returns the X509 certificate used in message level authentication.- Returns:
- a X509 certificate.
-
getToken
public Object getToken()
Returns a token for the sender of this Message.- Returns:
- a token Object.
-
getIPAddress
public String getIPAddress()
Returns the IP address of remote site of the SOAP connection.- Returns:
- a IP address
-
getSigningIds
public List getSigningIds()
Returns a list of id's for signing.- Returns:
- a list of id's for signing.
-
setCorrelationHeader
public void setCorrelationHeader(CorrelationHeader correlationHeader)
Sets theCorrelationHeader.- Parameters:
correlationHeader-CorrelationHeader
-
setConsentHeader
public void setConsentHeader(ConsentHeader consentHeader)
SetsConsentHeader.- Parameters:
consentHeader- theConsentHeader.
-
setUsageDirectiveHeaders
public void setUsageDirectiveHeaders(List usageDirectiveHeaders)
Sets a list ofUsageDirectiveHeader.- Parameters:
usageDirectiveHeaders- a list ofUsageDirectiveHeader.
-
setProviderHeader
public void setProviderHeader(ProviderHeader providerHeader)
SetsProviderHeaderif it is not null.- Parameters:
providerHeader- theProviderHeader.
-
setProcessingContextHeader
public void setProcessingContextHeader(ProcessingContextHeader processingContextHeader)
Sets theProcessingContextHeader.- Parameters:
processingContextHeader-ProcessingContextHeader
-
setServiceInstanceUpdateHeader
public void setServiceInstanceUpdateHeader(ServiceInstanceUpdateHeader serviceInstanceUpdateHeader)
Sets theServiceInstanceUpdateHeader.- Parameters:
serviceInstanceUpdateHeader- theServiceInstanceUpdateHeader
-
setOtherSOAPHeaders
public void setOtherSOAPHeaders(List headers, List signingIds)
Sets a list of SOAP headers exceptCorrelationHeader,ConsentHeader,UsageDirectiveHeaderand 'Security' header. Each entry will be aorg.w3c.dom.Element.- Parameters:
headers- a list of SOAP headers.signingIds- a list of values ofidattribute for signing
-
setOtherSOAPHeader
public void setOtherSOAPHeader(Element header, String signingId)
Sets a SOAP header exceptCorrelationHeader,ConsentHeaderandUsageDirectiveHeader.- Parameters:
header- aorg.w3c.dom.ElementsigningId- the value ofidattribute for signing. A value null value for this attribute is assumed as no signing.
-
setOtherSecurityHeaders
public void setOtherSecurityHeaders(List headers)
Sets a list of security headers. Each entry will be aorg.w3c.dom.Element.- Parameters:
headers- a list of security headers.
-
setOtherSecurityHeader
public void setOtherSecurityHeader(Element header)
Sets a security header.- Parameters:
header- the security header element.
-
setSOAPFault
public void setSOAPFault(SOAPFault soapFault)
Sets theSOAPFault.- Parameters:
soapFault- theSOAPFault.
-
setSOAPBodies
public void setSOAPBodies(List bodies)
Sets a list of SOAP bodies. Each entry will be aorg.w3c.dom.Element. To send a SOAP Fault, please use methodsetSOAPFault.- Parameters:
bodies- a list of SOAP bodies.
-
setSOAPBody
public void setSOAPBody(Element body)
Sets a SOAP body. To send a SOAP Fault, please use methodsetSOAPFault.- Parameters:
body- aorg.w3c.dom.Element
-
setClientAuthentication
public void setClientAuthentication(boolean clientAuthentication)
Sets a boolean flag. If the flag is true, this Message will be sent to a server that requires client authentication.- Parameters:
clientAuthentication- a boolean flag
-
toString
public String toString()
Returns the SOAP message in String format.
-
toDocument
public Document toDocument() throws SOAPBindingException
Returns the SOAP message inorg.w3c.dom.Documentformat.- Returns:
- the SOAP message in
org.w3c.dom.Documentformat. - Throws:
SOAPBindingException- if an error occurs while constructing a document.
-
toDocument
public Document toDocument(boolean refresh) throws SOAPBindingException
Returns the SOAP message inorg.w3c.dom.Documentformat.- Parameters:
refresh- true to reconstruct a document, false to reuse a previous document. If previous document doesn't exist, it will construct a new document.- Returns:
- the SOAP message in
org.w3c.dom.Documentformat. - Throws:
SOAPBindingException- if an error occurs while constructing theorg.w3c.dom.Document.
-
getWSFVersion
public String getWSFVersion()
Returns the web services version of the message.- Returns:
- the web services version.
-
setWSFVersion
public void setWSFVersion(String version)
Sets the web services version to the message.- Parameters:
version- the web services framework version.
-
-