com.sun.identity.liberty.ws.soapbinding
Class Message

java.lang.Object
  extended by com.sun.identity.liberty.ws.soapbinding.Message

public class Message
extends Object

The Message class is used by web service client and server to construct request or response. It will be sent over the SOAP connection. The Message contains SOAP headers and bodies. The SOAP binding defines the following headers: CorrelationHeader, ProviderHeader, ConsentHeader, UsageDirectiveHeader, ProcessingContextHeader and ServiceInstanceUpdateHeader. The first 2 are required and the others are optional. Signing is mandatory for CorrelationHeader and 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
static int ANONYMOUS
          anonymous profile is specified.
static int BEARER_TOKEN
          Bearer Token profile is specified.
static String CLIENT_TLS_BEARER
          Authentication mechanism "urn:liberty:security:2004-04:ClientTLS:Bearer"
static String CLIENT_TLS_BEARER_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:Bearer"
static String CLIENT_TLS_NULL
          Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:null"
static String CLIENT_TLS_SAML
          Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:SAML"
static String CLIENT_TLS_SAML_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:SAML"
static String CLIENT_TLS_X509
          Authentication mechanism "urn:liberty:security:2003-08:ClientTLS:X509"
static String CLIENT_TLS_X509_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:ClientTLS:X509"
static String NULL_BEARER
          Authentication mechanism "urn:liberty:security:2004-04:null:Bearer"
static String NULL_BEARER_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:null:Bearer"
static String NULL_NULL
          Authentication mechanism "urn:liberty:security:2003-08:null:null"
static String NULL_SAML
          Authentication mechanism "urn:liberty:security:2003-08:null:SAML"
static String NULL_SAML_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:null:SAML"
static String NULL_X509
          Authentication mechanism "urn:liberty:security:2003-08:null:X509"
static String NULL_X509_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:null:X509"
static int SAML_TOKEN
          SAML Token profile is specified.
static String TLS_BEARER
          Authentication mechanism "urn:liberty:security:2004-04:TLS:Bearer"
static String TLS_BEARER_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:TLS:Bearer"
static String TLS_NULL
          Authentication mechanism "urn:liberty:security:2003-08:TLS:null"
static String TLS_SAML
          Authentication mechanism "urn:liberty:security:2003-08:TLS:SAML"
static String TLS_SAML_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:TLS:SAML"
static String TLS_X509
          Authentication mechanism "urn:liberty:security:2003-08:TLS:X509"
static String TLS_X509_WSF11
          Authentication mechanism "urn:liberty:security:2005-02:TLS:X509"
static int X509_TOKEN
          X509 Token profile is specified.
 
Constructor Summary
Message()
          Default Constructor.
Message(InputStream inputStream)
          This constructor takes an InputStream.
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(javax.xml.soap.SOAPMessage soapMessage)
          This constructor takes a SOAP message which is received from a SOAP connection.
 
Method Summary
 SecurityAssertion getAssertion()
          Returns the SAML assertion used for signing.
 String getAuthenticationMechanism()
          Gets authentication mechanism.
 BinarySecurityToken getBinarySecurityToken()
          Returns a binary security token used for signing.
 List getBodies()
          Returns a list of SOAP bodies.
 List getBodies(String namespaceURI, String localName)
          Returns a list of SOAP bodies.
 ConsentHeader getConsentHeader()
          Returns the ConsentHeader.
 CorrelationHeader getCorrelationHeader()
          Returns the CorrelationHeader.
 String getIPAddress()
          Returns the IP address of remote site of the SOAP connection.
 X509Certificate getMessageCertificate()
          Returns the X509 certificate used in message level authentication.
 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.
 List getOtherSOAPHeaders()
          Returns a list of SOAP headers except CorrelationHeader, ConsentHeader, UsageDirectiveHeader and Security header.
 X509Certificate getPeerCertificate()
          Returns the X509 certificate used in client authentication.
 ProcessingContextHeader getProcessingContextHeader()
          Returns the ProcessingContextHeader.
 ProviderHeader getProviderHeader()
          Returns the ProviderHeader.
 int getSecurityProfileType()
          Gets security profile type.
 ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader()
          Returns the ServiceInstanceUpdateHeader.
 List getSigningIds()
          Returns a list of id's for signing.
 SOAPFault getSOAPFault()
          Returns the SOAPFault.
 Object getToken()
          Returns a token for the sender of this Message.
 List getUsageDirectiveHeaders()
          Returns a list of UsageDirectiveHeader.
 String getWSFVersion()
          Returns the web services version of the message.
 boolean isClientAuthentication()
          Returns a boolean flag to determine if this Message will be sent to a server that requires client authentication.
 void setBinarySecurityToken(BinarySecurityToken binaryToken)
          Sets a binary security token for this message.
 void setClientAuthentication(boolean clientAuthentication)
          Sets a boolean flag.
 void setConsentHeader(ConsentHeader consentHeader)
          Sets ConsentHeader.
 void setCorrelationHeader(CorrelationHeader correlationHeader)
          Sets the CorrelationHeader.
 void setOtherSecurityHeader(Element header)
          Sets a security header.
 void setOtherSecurityHeaders(List headers)
          Sets a list of security headers.
 void setOtherSOAPHeader(Element header, String signingId)
          Sets a SOAP header except CorrelationHeader, ConsentHeader and UsageDirectiveHeader.
 void setOtherSOAPHeaders(List headers, List signingIds)
          Sets a list of SOAP headers except CorrelationHeader, ConsentHeader, UsageDirectiveHeader and 'Security' header.
 void setProcessingContextHeader(ProcessingContextHeader processingContextHeader)
          Sets the ProcessingContextHeader.
 void setProviderHeader(ProviderHeader providerHeader)
          Sets ProviderHeader if it is not null.
 void setSecurityProfileType(int profileType)
          Sets security profile type.
 void setServiceInstanceUpdateHeader(ServiceInstanceUpdateHeader serviceInstanceUpdateHeader)
          Sets the ServiceInstanceUpdateHeader.
 void setSOAPBodies(List bodies)
          Sets a list of SOAP bodies.
 void setSOAPBody(Element body)
          Sets a SOAP body.
 void setSOAPFault(SOAPFault soapFault)
          Sets the SOAPFault.
 void setUsageDirectiveHeaders(List usageDirectiveHeaders)
          Sets a list of UsageDirectiveHeader.
 void setWSFVersion(String version)
          Sets the web services version to the message.
 Document toDocument()
          Returns the SOAP message in org.w3c.dom.Document format.
 Document toDocument(boolean refresh)
          Returns the SOAP message in org.w3c.dom.Document format.
 String toString()
          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 - ProviderHeader
assertion - 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 - ProviderHeader
token - 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(javax.xml.soap.SOAPMessage soapMessage)
        throws SOAPBindingException,
               SOAPFaultException
This 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 message
SOAPFaultException
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 the CorrelationHeader.

Returns:
the CorrelationHeader.

getConsentHeader

public ConsentHeader getConsentHeader()
Returns the ConsentHeader.

Returns:
the ConsentHeader.

getUsageDirectiveHeaders

public List getUsageDirectiveHeaders()
Returns a list of UsageDirectiveHeader.

Returns:
a list of UsageDirectiveHeader.

getProviderHeader

public ProviderHeader getProviderHeader()
Returns the ProviderHeader.

Returns:
the ProviderHeader.

getProcessingContextHeader

public ProcessingContextHeader getProcessingContextHeader()
Returns the ProcessingContextHeader.

Returns:
the ProcessingContextHeader.

getServiceInstanceUpdateHeader

public ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader()
Returns the ServiceInstanceUpdateHeader.

Returns:
the ServiceInstanceUpdateHeader.

getOtherSOAPHeaders

public List getOtherSOAPHeaders()
Returns a list of SOAP headers except CorrelationHeader, ConsentHeader, UsageDirectiveHeader and Security header. Each entry will be a org.w3c.dom.Element.

Returns:
a list of SOAP headers

getSOAPFault

public SOAPFault getSOAPFault()
Returns the SOAPFault.

Returns:
the SOAPFault.

getBodies

public List getBodies()
Returns a list of SOAP bodies. Each entry will be a org.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 a org.w3c.dom.Element with specified namespace URI and local name.

Parameters:
namespaceURI - namspace URI
localName - 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 a org.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 the CorrelationHeader.

Parameters:
correlationHeader - CorrelationHeader

setConsentHeader

public void setConsentHeader(ConsentHeader consentHeader)
Sets ConsentHeader.

Parameters:
consentHeader - the ConsentHeader.

setUsageDirectiveHeaders

public void setUsageDirectiveHeaders(List usageDirectiveHeaders)
Sets a list of UsageDirectiveHeader.

Parameters:
usageDirectiveHeaders - a list of UsageDirectiveHeader.

setProviderHeader

public void setProviderHeader(ProviderHeader providerHeader)
Sets ProviderHeader if it is not null.

Parameters:
providerHeader - the ProviderHeader.

setProcessingContextHeader

public void setProcessingContextHeader(ProcessingContextHeader processingContextHeader)
Sets the ProcessingContextHeader.

Parameters:
processingContextHeader - ProcessingContextHeader

setServiceInstanceUpdateHeader

public void setServiceInstanceUpdateHeader(ServiceInstanceUpdateHeader serviceInstanceUpdateHeader)
Sets the ServiceInstanceUpdateHeader.

Parameters:
serviceInstanceUpdateHeader - the ServiceInstanceUpdateHeader

setOtherSOAPHeaders

public void setOtherSOAPHeaders(List headers,
                                List signingIds)
Sets a list of SOAP headers except CorrelationHeader, ConsentHeader, UsageDirectiveHeader and 'Security' header. Each entry will be a org.w3c.dom.Element.

Parameters:
headers - a list of SOAP headers.
signingIds - a list of values of id attribute for signing

setOtherSOAPHeader

public void setOtherSOAPHeader(Element header,
                               String signingId)
Sets a SOAP header except CorrelationHeader, ConsentHeader and UsageDirectiveHeader.

Parameters:
header - a org.w3c.dom.Element
signingId - the value of id attribute 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 a org.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 the SOAPFault.

Parameters:
soapFault - the SOAPFault.

setSOAPBodies

public void setSOAPBodies(List bodies)
Sets a list of SOAP bodies. Each entry will be a org.w3c.dom.Element. To send a SOAP Fault, please use method setSOAPFault.

Parameters:
bodies - a list of SOAP bodies.

setSOAPBody

public void setSOAPBody(Element body)
Sets a SOAP body. To send a SOAP Fault, please use method setSOAPFault.

Parameters:
body - a org.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.

Overrides:
toString in class Object
Returns:
the SOAP message in String format.

toDocument

public Document toDocument()
                    throws SOAPBindingException
Returns the SOAP message in org.w3c.dom.Document format.

Returns:
the SOAP message in org.w3c.dom.Document format.
Throws:
SOAPBindingException - if an error occurs while constructing a document.

toDocument

public Document toDocument(boolean refresh)
                    throws SOAPBindingException
Returns the SOAP message in org.w3c.dom.Document format.

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.Document format.
Throws:
SOAPBindingException - if an error occurs while constructing the org.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.