public class Message extends Object
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.Constructor and Description |
---|
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(SOAPMessage soapMessage)
This constructor takes a SOAP message which is received from a SOAP
connection.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public Message()
public Message(ProviderHeader providerHeader) throws SOAPBindingException
providerHeader
- ProviderHeader
.SOAPBindingException
- if provider header is null.public Message(ProviderHeader providerHeader, SecurityAssertion assertion) throws SOAPBindingException
providerHeader
- ProviderHeader
assertion
- a SAML assertionSOAPBindingException
- if an error occurs while processing
the SAML assertion or the provider
header is nullpublic Message(ProviderHeader providerHeader, BinarySecurityToken token) throws SOAPBindingException
providerHeader
- ProviderHeader
token
- a binary security tokenSOAPBindingException
- if an error occurs while processing
the token or the provider header is nullpublic Message(SOAPFault soapFault)
soapFault
- SOAPFault
public Message(InputStream inputStream) throws SOAPBindingException
inputStream
- an InputStreamSOAPBindingException
- if an error occurs while parsing the input.public Message(SOAPMessage soapMessage) throws SOAPBindingException, SOAPFaultException
soapMessage
- a SOAP messageSOAPBindingException
- if an error occurs while parsing the
SOAP messageSOAPFaultException
public int getSecurityProfileType()
public void setSecurityProfileType(int profileType)
profileType
- Profile Type. Possible values are ANONYMOUS,
X509_TOKEN , SAML_TOKEN and BEARER_TOKENpublic void setBinarySecurityToken(BinarySecurityToken binaryToken)
binaryToken
- a binary security tokenpublic String getAuthenticationMechanism()
public boolean isClientAuthentication()
public CorrelationHeader getCorrelationHeader()
CorrelationHeader
.CorrelationHeader
.public ConsentHeader getConsentHeader()
ConsentHeader
.ConsentHeader
.public List getUsageDirectiveHeaders()
UsageDirectiveHeader
.UsageDirectiveHeader
.public ProviderHeader getProviderHeader()
ProviderHeader
.ProviderHeader
.public ProcessingContextHeader getProcessingContextHeader()
ProcessingContextHeader
.ProcessingContextHeader
.public ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader()
ServiceInstanceUpdateHeader
.ServiceInstanceUpdateHeader
.public List getOtherSOAPHeaders()
CorrelationHeader
,
ConsentHeader
, UsageDirectiveHeader
and
Security
header. Each entry will be a
org.w3c.dom.Element
.public SOAPFault getSOAPFault()
SOAPFault
.SOAPFault
.public List getBodies()
org.w3c.dom.Element
.public List getBodies(String namespaceURI, String localName)
org.w3c.dom.Element
with specified
namespace URI and local name.namespaceURI
- namspace URIlocalName
- local namepublic List getOtherSecurityHeaders()
org.w3c.dom.Element
.public SecurityAssertion getAssertion()
public BinarySecurityToken getBinarySecurityToken()
public X509Certificate getPeerCertificate()
public X509Certificate getMessageCertificate()
public Object getToken()
public String getIPAddress()
public List getSigningIds()
public void setCorrelationHeader(CorrelationHeader correlationHeader)
CorrelationHeader
.correlationHeader
- CorrelationHeader
public void setConsentHeader(ConsentHeader consentHeader)
ConsentHeader
.consentHeader
- the ConsentHeader
.public void setUsageDirectiveHeaders(List usageDirectiveHeaders)
UsageDirectiveHeader
.usageDirectiveHeaders
- a list of UsageDirectiveHeader
.public void setProviderHeader(ProviderHeader providerHeader)
ProviderHeader
if it is not null.providerHeader
- the ProviderHeader
.public void setProcessingContextHeader(ProcessingContextHeader processingContextHeader)
ProcessingContextHeader
.processingContextHeader
- ProcessingContextHeader
public void setServiceInstanceUpdateHeader(ServiceInstanceUpdateHeader serviceInstanceUpdateHeader)
ServiceInstanceUpdateHeader
.serviceInstanceUpdateHeader
- the ServiceInstanceUpdateHeader
public void setOtherSOAPHeaders(List headers, List signingIds)
CorrelationHeader
,
ConsentHeader
, UsageDirectiveHeader
and
'Security' header. Each entry will be a org.w3c.dom.Element
.headers
- a list of SOAP headers.signingIds
- a list of values of id
attribute for
signingpublic void setOtherSOAPHeader(Element header, String signingId)
CorrelationHeader
,
ConsentHeader
and UsageDirectiveHeader
.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.public void setOtherSecurityHeaders(List headers)
org.w3c.dom.Element
.headers
- a list of security headers.public void setOtherSecurityHeader(Element header)
header
- the security header element.public void setSOAPFault(SOAPFault soapFault)
SOAPFault
.soapFault
- the SOAPFault
.public void setSOAPBodies(List bodies)
org.w3c.dom.Element
. To send a SOAP Fault, please use
method setSOAPFault
.bodies
- a list of SOAP bodies.public void setSOAPBody(Element body)
setSOAPFault
.body
- a org.w3c.dom.Element
public void setClientAuthentication(boolean clientAuthentication)
clientAuthentication
- a boolean flagpublic String toString()
public Document toDocument() throws SOAPBindingException
org.w3c.dom.Document
format.org.w3c.dom.Document
format.SOAPBindingException
- if an error occurs while constructing
a document.public Document toDocument(boolean refresh) throws SOAPBindingException
org.w3c.dom.Document
format.refresh
- true to reconstruct a document, false to reuse a
previous document. If previous document doesn't exist,
it will construct a new document.org.w3c.dom.Document
format.SOAPBindingException
- if an error occurs while constructing
the org.w3c.dom.Document
.public String getWSFVersion()
public void setWSFVersion(String version)
version
- the web services framework version.Copyright © 2010-2018, ForgeRock All Rights Reserved.