PK
HAoa, mimetypeapplication/epub+zipPK
HA META-INF/PK
HA OEBPS/PK
HA
OEBPS/images/PK
HA OEBPS/imagesdb/PK
HAh h META-INF/container.xml
On the server side, you can verify that received credentials are authentic by registering a callback handler with the Fuse Services Framework runtime. You can either write your own custom code to perform credentials verification or you can implement a callback handler that integrates with a third-party enterprise security system (for example, an LDAP server).
To configure a server callback handler that verifies UsernameToken
credentials received from clients, set the ws-security.callback-handler
property in the server's Spring XML configuration, as follows:
<beans ... >
<jaxws:endpoint
id="UserNameOverTransport"
address="https://localhost:9001/UserNameOverTransport"
serviceName="interop:PingService10"
endpointName="interop:UserNameOverTransport_IPingService"
implementor="interop.server.UserNameOverTransport"
depends-on="tls-settings">
<jaxws:properties>
<entry key="ws-security.username" value="Alice"/>
<entry key="ws-security.callback-handler" value="interop.client.UTPasswordCallback"/>
</jaxws:properties>
</jaxws:endpoint>
...
</beans>In the preceding example, the callback handler is implemented by the
UTPasswordCallback class.
To implement a callback handler for checking passwords on the server side, implement the
javax.security.auth.callback.CallbackHandler interface. The general approach
to implementing the CallbackHandler interface for a server is similar to
implementing a CallbackHandler for a client. The interpretation given to the
returned password on the server side is different, however: the password from the callback
handler is compared against the received client password in order to verify the client's
credentials.
For example, you could use the sample implementation shown in Example 7.2 to obtain passwords on the server side. On the server side, the WSS4J runtime would compare the password obtained from the callback with the password in the received client credentials. If the two passwords match, the credentials are successfully verified.
A more realistic implementation of a server callback handler would involve writing an integration with a third-party database that is used to store security data (for example, integration with an LDAP server).
There are essentially two approaches to providing UsernameToken client
credentials: you can either set both the username and the password directly in the client's
Spring XML configuration; or you can set the username in the client's configuration and
implement a callback handler to provide passwords programmatically. The latter approach (by
programming) has the advantage that passwords are easier to hide from view.
Table 7.1 shows the properties you can use to specify WS-Security username/password credentials on a client's request context in Spring XML.
Table 7.1. Client Credentials Properties
| Properties | Description |
|---|---|
ws-security.username | Specifies the username for UsernameToken policy assertions. |
ws-security.password | Specifies the password for UsernameToken policy assertions. If not specified, the password is obtained by calling the callback handler. |
ws-security.callback-handler |
Specifies the class name of the WSS4J callback handler that retrieves passwords for UsernameToken policy assertions. Note that the callback handler can also handle other kinds of security events. |
To configure username/password credentials in a client's request context in Spring XML,
set the ws-security.username and ws-security.password properties
as follows:
<beans ... >
<jaxws:client name="{NamespaceName}LocalPortName"
createdFromAPI="true">
<jaxws:properties>
<entry key="ws-security.username" value="Alice"/>
<entry key="ws-security.password" value="abcd!1234"/>
</jaxws:properties>
</jaxws:client>
...
</beans>If you prefer not to store the password directly in Spring XML (which might potentially be a security hazard), you can provide passwords using a callback handler instead.
If you want to use a callback handler to provide passwords for the UsernameToken header,
you must first modify the client configuration in Spring XML, replacing the
ws-security.password setting by a ws-security.callback-handler
setting, as follows:
<beans ... >
<jaxws:client name="{NamespaceName}LocalPortName"
createdFromAPI="true">
<jaxws:properties>
<entry key="ws-security.username" value="Alice"/>
<entry key="ws-security.callback-handler" value="interop.client.UTPasswordCallback"/>
</jaxws:properties>
</jaxws:client>
...
</beans>In the preceding example, the callback handler is implemented by the
UTPasswordCallback class. You can write a callback handler by implementing
the javax.security.auth.callback.CallbackHandler interface, as shown in Example 7.2.
Example 7.2. Callback Handler for UsernameToken Passwords
package interop.client; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.ws.security.WSPasswordCallback; public class UTPasswordCallback implements CallbackHandler { private Map<String, String> passwords = new HashMap<String, String>(); public UTPasswordCallback() { passwords.put("Alice", "ecilA"); passwords.put("Frank", "invalid-password"); //for MS clients passwords.put("abcd", "dcba"); } public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } throw new IOException(); } // Add an alias/password pair to the callback mechanism. public void setAliasPassword(String alias, String password) { passwords.put(alias, password); } }
The callback functionality is implemented by the CallbackHandler.handle()
method. In this example, it assumed that the callback objects passed to the
handle() method are all of org.apache.ws.security.WSPasswordCallback type (in a more realistic example, you
would check the type of the callback objects).
A more realistic implementation of a client callback handler would probably consist of prompting the user to enter their password.
When a CallbackHandler is called in a Fuse Services Framework client for the purpose of
setting a UsernameToken password, the corresponding
WSPasswordCallback object has the USERNAME_TOKEN usage
code.
For more details about the WSPasswordCallback class, see org.apache.ws.security.WSPasswordCallback.
The WSPasswordCallback class defines several different usage codes, as
follows:
Obtain the password for UsernameToken credentials. This usage code is used both on the client side (to obtain a password to send to the server) and on the server side (to obtain a password in order to compare it with the password received from the client).
On the server side, this code is set in the following cases:
Digest password—if the UsernameToken contains a
digest password, the callback must return the corresponding password for the given
user name (given by WSPasswordCallback.getIdentifier()). Verification
of the password (by comparing with the digest password) is done by the WSS4J
runtime.
Plaintext password—implemented the same way as the digest password case (since Fuse Services Framework 2.4.0).
Custom password type—if
getHandleCustomPasswordTypes() is true on
org.apache.ws.security.WSSConfig, this case is implemented the same
way as the digest password case (since Fuse Services Framework 2.4.0). Otherwise, an exception
is thrown.
If no Password element is included in a received UsernameToken on the
server side, the callback handler is not called (since Fuse Services Framework 2.4.0).
Need a password to retrieve a private key from a Java keystore, where
WSPasswordCallback.getIdentifier() gives the alias of the keystore
entry. WSS4J uses this private key to decrypt the session (symmetric) key.
Need a password to retrieve a private key from a Java keystore, where
WSPasswordCallback.getIdentifier() gives the alias of the keystore
entry. WSS4J uses this private key to produce a signature.
Need a secret key for encryption or signature on the outbound side, or for
decryption or verification on the inbound side. The callback handler must set the key
using the setKey(byte[]) method.
Need the key for a wsc:SecurityContextToken, which you provide by
calling the setKey(byte[]) method.
Need a token as a DOM element. For example, this is used for the case of a
reference to a SAML Assertion or SecurityContextToken that is not in the message. The
callback handler must set the token using the setCustomToken(Element)
method.
(Obsolete) Since Fuse Services Framework 2.4.0, this usage code is obsolete.
(Obsolete) Since Fuse Services Framework 2.4.0, this usage code is obsolete.
Not used by WSS4J.
In Fuse Services Framework, an application can be set up to use authentication through a combination of policy assertions in the WSDL contract and configuration settings in Spring XML.
![]() | Note |
|---|---|
Remember, you can also use the HTTPS protocol as the basis for authentication and, in some cases, this might be easier to configure. See Authentication Alternatives. |
In outline, you need to perform the following steps to set up an application to use authentication:
Add a supporting tokens policy to an endpoint in the WSDL contract. This has the effect of requiring the endpoint to include a particular type of token (client credentials) in its request messages.
On the client side, provide credentials to send by configuring the relevant endpoint in Spring XML.
(Optional) On the client side, if you decide to provide passwords using a callback handler, implement the callback handler in Java.
On the server side, associate a callback handler class with the endpoint in Spring XML. The callback handler is then responsible for authenticating the credentials received from remote clients.
If you want an endpoint to support authentication, associate a supporting
tokens policy assertion with the relevant endpoint binding. There are several
different kinds of supporting tokens policy assertions, whose elements all have names of the
form *SupportingTokens (for example, SupportingTokens,
SignedSupportingTokens, and so on). For a complete list, see SupportingTokens assertions.
Associating a supporting tokens assertion with an endpoint has the following effects:
Messages to or from the endpoint are required to include the specified token type
(where the token's direction is specified by the sp:IncludeToken
attribute).
Depending on the particular type of supporting tokens element you use, the endpoint might be required to sign and/or encrypt the token.
The supporting tokens assertion implies that the runtime will check that these requirements are satisified. But the WS-SecurityPolicy policies do not define the mechanism for providing credentials to the runtime. You must use Spring XML configuration to specify the credentials (see Providing Client Credentials).
The *SupportingTokens elements (that is, all elements with the
SupportingTokens suffix—see SupportingTokens assertions) have the following syntax:
<sp:SupportingTokensElementxmlns:sp="..." ... > <wsp:Policy xmlns:wsp="..."> [Token Assertion]+ <sp:AlgorithmSuite ... > ... </sp:AlgorithmSuite> ? ( <sp:SignedParts ... > ... </sp:SignedParts> | <sp:SignedElements ... > ... </sp:SignedElements> | <sp:EncryptedParts ... > ... </sp:EncryptedParts> | <sp:EncryptedElements ... > ... </sp:EncryptedElements> | ) * ... </wsp:Policy> ... </sp:SupportingTokensElement>
Where SupportingTokensElement stands for one of the
supporting token elements, *SupportingTokens.Typically, if you simply want to
include a token (or tokens) in the security header, you would include one or more token
assertions, [Token Assertion], in the policy. In particular, this is all that
is required for authentication.
If the token is of an appropriate type (for example, an X.509 certificate or a symmetric
key), you could theoretically also use it to sign or encrypt specific parts of the current
message using the sp:AlgorithmSuite, sp:SignedParts,
sp:SignedElements, sp:EncryptedParts, and
sp:EncryptedElements elements. This functionality is currently
not supported by Fuse Services Framework, however.
Example 7.1 shows an example of a policy that requires a
WS-Security UsernameToken token (which contains username/password credentials) to be
included in the security header. In addition, because the token is specified inside an
sp:SignedSupportingTokens element, the policy requires that the token is
signed. This example uses a transport binding, so it is the underlying transport that is
responsible for signing the message.
For example, if the underlying transport is HTTPS, the SSL/TLS protocol (configured with an appropriate algorithm suite) is responsible for signing the entire message, including the security header that contains the specified token. This is sufficient to satisfy the requirement that the supporting token is signed.
Example 7.1. Example of a Supporting Tokens Policy
<wsp:Policy wsu:Id="UserNameOverTransport_IPingService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding> ... </sp:TransportBinding>
<sp:SignedSupportingTokens
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:UsernameToken
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
...
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>Where the presence of the sp:WssUsernameToken10 sub-element indicates that
the UsernameToken header should conform to version 1.0 of the WS-Security UsernameToken
specification.
In principle, you can specify any of the WS-SecurityPolicy token types in a supporting
tokens assertion. For SOAP-level authentication, however, only the
sp:UsernameToken token type is relevant.
In the context of a supporting tokens assertion, this element specifies that a
WS-Security UsernameToken is to be included in the security SOAP header. Essentially, a
WS-Security UsernameToken is used to send username/password credentials in the WS-Security
SOAP header. The sp:UsernameToken element has the following syntax:
<sp:UsernameToken sp:IncludeToken="xs:anyURI"? xmlns:sp="..." ... >
(
<sp:Issuer>wsa:EndpointReferenceType</sp:Issuer> |
<sp:IssuerName>xs:anyURI</sp:IssuerName>
) ?
<wst:Claims Dialect="..."> ... </wst:Claims> ?
<wsp:Policy xmlns:wsp="...">
(
<sp:NoPassword ... /> |
<sp:HashPassword ... />
) ?
(
<sp:RequireDerivedKeys /> |
<sp:RequireImpliedDerivedKeys ... /> |
<sp:RequireExplicitDerivedKeys ... />
) ?
(
<sp:WssUsernameToken10 ... /> |
<sp:WssUsernameToken11 ... />
) ?
...
</wsp:Policy>
...
</sp:UsernameToken>The sub-elements of sp:UsernameToken are all optional and are not needed
for ordinary authentication. Normally, the only part of this syntax that is relevant is the
sp:IncludeToken attribute.
![]() | Note |
|---|---|
Currently, in the |
The value of the sp:IncludeToken must match the WS-SecurityPolicy version
from the enclosing policy. The current version is 1.2, but legacy WSDL might use version
1.1. Valid values of the sp:IncludeToken attribute are as follows:
The token MUST NOT be included in any messages sent between the initiator and the recipient; rather, an external reference to the token should be used. Valid URI values are:
| 1.2 |
|
| 1.1 |
|
The token MUST be included in only one message sent from the initiator to the recipient. References to the token MAY use an internal reference mechanism. Subsequent related messages sent between the recipient and the initiator may refer to the token using an external reference mechanism. Valid URI values are:
| 1.2 |
|
| 1.1 |
|
The token MUST be included in all messages sent from initiator to the recipient. The token MUST NOT be included in messages sent from the recipient to the initiator. Valid URI values are:
| 1.2 |
|
| 1.1 |
|
The token MUST be included in all messages sent from the recipient to the initiator. The token MUST NOT be included in messages sent from the initiator to the recipient. Valid URI values are:
| 1.2 |
|
| 1.1 |
|
The token MUST be included in all messages sent between the initiator and the recipient. This is the default behavior. Valid URI values are:
| 1.2 |
|
| 1.1 |
|
The following kinds of supporting tokens assertions are supported:
This element requires a token (or tokens) of the specified type to be included in the
wsse:Security header. No additional requirements are imposed.
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be signed or encrypted. It is normally essential, however, to protect tokens by signing and encryption. |
This element requires a token (or tokens) of the specified type to be included in the
wsse:Security header. In addition, this policy requires that the token is
signed, in order to guarantee token integrity.
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be encrypted. It is normally essential, however, to protect tokens both by signing and encryption. |
This element requires a token (or tokens) of the specified type to be included in the
wsse:Security header. In addition, this policy requires that the token is
encrypted, in order to guarantee token confidentiality.
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be signed. It is normally essential, however, to protect tokens both by signing and encryption. |
This element requires a token (or tokens) of the specified type to be included in the
wsse:Security header. In addition, this policy requires that the token is
both signed and encrypted, in order to guarantee token integrity and confidentiality.
An endorsing supporting token is used to sign the message signature (primary signature). This signature is known as an endorsing signature or secondary signature. Hence, by applying an endorsing supporting tokens policy, you can have a chain of signatures: the primary signature, which signs the message itself, and the secondary signature, which signs the primary signature.
![]() | Note |
|---|---|
If you are using a transport binding (for example, HTTPS), the message signature is not actually part of the SOAP message, so it is not possible to sign the message signature in this case. If you specify this policy with a transport binding, the endorsing token signs the timestamp instead. |
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be signed or encrypted. It is normally essential, however, to protect tokens by signing and encryption. |
This policy is the same as the endorsing supporting tokens policy, except that the tokens are required to be signed, in order to guarantee token integrity.
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be encrypted. It is normally essential, however, to protect tokens both by signing and encryption. |
This policy is the same as the endorsing supporting tokens policy, except that the tokens are required to be encrypted, in order to guarantee token confidentiality.
![]() | Warning |
|---|---|
This policy does not explicitly require the tokens to be signed. It is normally essential, however, to protect tokens both by signing and encryption. |
This chapter explains how to specify the list of cipher suites that are made available to clients and servers for the purpose of establishing HTTPS connections. During a security handshake, the client chooses a cipher suite that matches one of the cipher suites available to the server.
This section describes how to configure the HTTP transport to use SSL/TLS security, a combination usually referred to as HTTPS. In Fuse Services Framework, HTTPS security is configured by specifying settings in XML configuration files.
The following topics are discussed in this chapter:
A basic prerequisite for using SSL/TLS security is to have a collection of X.509 certificates available to identify your server applications and, optionally, to identify your client applications. You can generate X.509 certificates in one of the following ways:
Use a commercial third-party to tool to generate and manage your X.509 certificates.
Use the free openssl utility (which can be downloaded from http://www.openssl.org) and the Java keystore utility to generate certificates (see Use the CA to Create Signed Certificates in a Java Keystore).
![]() | Note |
|---|---|
The HTTPS protocol mandates a URL integrity check, which requires a certificate’s identity to match the hostname on which the server is deployed. See Special Requirements on HTTPS Certificates for details. |
In the Java runtime, you must deploy X.509 certificate chains and trusted CA certificates in the form of Java keystores. See Configuring HTTPS for details.
A prerequisite for enabling HTTPS on a WSDL endpoint is that the endpoint address must be specified as a HTTPS URL. There are two different locations where the endpoint address is set and both must be modified to use a HTTPS URL:
HTTPS specified in the WSDL contract—you must specify the endpoint
address in the WSDL contract to be a URL with the https: prefix, as
shown in Example 1.1.
Example 1.1. Specifying HTTPS in the WSDL
<wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world_soap_http"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ... >
...
<wsdl:service name="SOAPService">
<wsdl:port binding="tns:Greeter_SOAPBinding"
name="SoapPort">
<soap:address location="https://localhost:9001/SoapContext/SoapPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>Where the location attribute of the soap:address element is configured to use a HTTPS URL.
For bindings other than SOAP, you edit the URL appearing in the location attribute of the http:address element.
HTTPS specified in the server code—you must ensure that the URL
published in the server code by calling
Endpoint.publish() is defined with a
https: prefix, as shown in Example 1.2.
Example 1.2. Specifying HTTPS in the Server Code
// Java
package demo.hw_https.server;
import javax.xml.ws.Endpoint;
public class Server {
protected Server() throws Exception {
Object implementor = new GreeterImpl();
String address = "https://localhost:9001/SoapContext/SoapPort";
Endpoint.publish(address, implementor);
}
...
}For example, consider the configuration for a secure HTTPS client with no certificate, as shown in Example 1.3.
Example 1.3. Sample HTTPS Client with No Certificate
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xsi:schemaLocation="...">
<http:conduit name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit">
<http:tlsClientParameters>
<sec:trustManagers>
<sec:keyStore type="JKS" password="password"
file="certs/truststore.jks"/>
</sec:trustManagers>
<sec:cipherSuitesFilter>
<sec:include>.*_WITH_3DES_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:exclude>.*_WITH_NULL_.*</sec:exclude>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
</http:tlsClientParameters>
</http:conduit>
</beans>The preceding client configuration is described as follows:
The TLS security settings are defined on a specific WSDL port. In this
example, the WSDL port being configured has the QName,
| ||||
The | ||||
The The
| ||||
The |
Consider a secure HTTPS client that is configured to have its own certificate. Example 1.4 shows how to configure such a sample client.
Example 1.4. Sample HTTPS Client with Certificate
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xsi:schemaLocation="...">
<http:conduit name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit">
<http:tlsClientParameters>
<sec:trustManagers>
<sec:keyStore type="JKS" password="password"
file="certs/truststore.jks"/>
</sec:trustManagers>
<sec:keyManagers keyPassword="password">
<sec:keyStore type="JKS" password="password"
file="certs/wibble.jks"/>
</sec:keyManagers>
<sec:cipherSuitesFilter>
<sec:include>.*_WITH_3DES_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:exclude>.*_WITH_NULL_.*</sec:exclude>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
</http:tlsClientParameters>
</http:conduit>
<bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
</beans>The preceding client configuration is described as follows:
The | ||||
The The It is expected that the keystore file contains just one key entry, so it is
not necessary to specify a key alias to identify the entry. If you are deploying
a keystore file with multiple key entries, however, it is
possible to specify the key in this case by adding the <http:tlsClientParameters>
...
<sec:certAlias>For details of how to create a keystore file, see Use the CA to Create Signed Certificates in a Java Keystore.
|
Consider a secure HTTPS server that requires clients to present an X.509 certificate. Example 1.5 shows how to configure such a server.
Example 1.5. Sample HTTPS Server Configuration
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xsi:schemaLocation="..."> <httpj:engine-factory bus="cxf"><httpj:engine port="9001">
<httpj:tlsServerParameters>
<sec:keyManagers keyPassword="password">
<sec:keyStore type="JKS" password="password"
file="certs/cherry.jks"/> </sec:keyManagers> <sec:trustManagers>
<sec:keyStore type="JKS" password="password" file="certs/truststore.jks"/> </sec:trustManagers> <sec:cipherSuitesFilter>
<sec:include>.*_WITH_3DES_.*</sec:include> <sec:include>.*_WITH_DES_.*</sec:include> <sec:exclude>.*_WITH_NULL_.*</sec:exclude> <sec:exclude>.*_DH_anon_.*</sec:exclude> </sec:cipherSuitesFilter> <sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters> </httpj:engine> </httpj:engine-factory> </beans>
The preceding server configuration is described as follows:
The | ||||
On the server side, TLS is not configured for each WSDL
port. Instead of configuring each WSDL port, the TLS security settings are
applied to a specific IP port, which is
| ||||
The | ||||
The | ||||
The The It is expected that the keystore file contains just one key entry, so it is
not necessary to specify a key alias to identify the entry. If you are deploying
a keystore file with multiple key entries, however, it is
possible to specify the key in this case by adding the <http:tlsClientParameters>
...
<sec:certAlias>
For details of how to create such a keystore file, see Use the CA to Create Signed Certificates in a Java Keystore. | ||||
The The
| ||||
The | ||||
The
|
The asymmetric binding policy implements SOAP message protection using asymmetric key algorithms (public/private key combinations) and does so at the SOAP layer. The encryption and signing algorithms used by the asymmetric binding are similar to the encryption and signing algorithms used by SSL/TLS. A crucial difference, however, is that SOAP message protection enables you to select particular parts of a message to protect (for example, individual headers, body, or attachments), whereas transport layer security can operate only on the whole message.
An asymmetric binding policy must be applied to an endpoint policy subject (see Endpoint policy subject). For example, given the asymmetric
binding policy with ID, MutualCertificate10SignEncrypt_IPingService_policy,
you could apply the policy to an endpoint binding as follows:
<wsdl:binding name="MutualCertificate10SignEncrypt_IPingService" type="i0:IPingService">
<wsp:PolicyReference URI="#MutualCertificate10SignEncrypt_IPingService_policy"/>
...
</wsdl:binding>The AsymmetricBinding element has the following syntax:
<sp:AsymmetricBinding xmlns:sp="..." ... >
<wsp:Policy xmlns:wsp="...">
(
<sp:InitiatorToken>
<wsp:Policy> ... </wsp:Policy>
</sp:InitiatorToken>
) | (
<sp:InitiatorSignatureToken>
<wsp:Policy> ... </wsp:Policy>
</sp:InitiatorSignatureToken>
<sp:InitiatorEncryptionToken>
<wsp:Policy> ... </wsp:Policy>
</sp:InitiatorEncryptionToken>
)
(
<sp:RecipientToken>
<wsp:Policy> ... </wsp:Policy>
</sp:RecipientToken>
) | (
<sp:RecipientSignatureToken>
<wsp:Policy> ... </wsp:Policy>
</sp:RecipientSignatureToken>
<sp:RecipientEncryptionToken>
<wsp:Policy> ... </wsp:Policy>
</sp:RecipientEncryptionToken>
)
<sp:AlgorithmSuite ... > ... </sp:AlgorithmSuite>
<sp:Layout ... > ... </sp:Layout> ?
<sp:IncludeTimestamp ... /> ?
<sp:EncryptBeforeSigning ... /> ?
<sp:EncryptSignature ... /> ?
<sp:ProtectTokens ... /> ?
<sp:OnlySignEntireHeadersAndBody ... /> ?
...
</wsp:Policy>
...
</sp:AsymmetricBinding>Example 6.4 shows an example of an asymmetric binding that supports message protection with signatures and encryption, where the signing and encryption is done using pairs of public/private keys (that is, using asymmetric cryptography). This example does not specify which parts of the message should be signed and encrypted, however. For details of how to do that, see Specifying Parts of Message to Encrypt and Sign.
Example 6.4. Example of an Asymmetric Binding
<wsp:Policy wsu:Id="MutualCertificate10SignEncrypt_IPingService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:AsymmetricBinding
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:InitiatorToken>
<wsp:Policy>
<sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
<wsp:Policy>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:RecipientToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
<sp:EncryptSignature/>
<sp:OnlySignEntireHeadersAndBody/>
</wsp:Policy>
</sp:AsymmetricBinding>
<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:MustSupportRefKeyIdentifier/>
<sp:MustSupportRefIssuerSerial/>
</wsp:Policy>
</sp:Wss10>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>The initiator token refers to the public/private key-pair owned by the initiator. This token is used as follows:
The token's private key signs messages sent from initiator to recipient.
The token's public key verifies signatures received by the recipient.
The token's public key encrypts messages sent from recipient to initiator.
The token's private key decrypts messages received by the initiator.
Confusingly, this token is used both by the initiator and by the recipient. However, only the initiator has access to the private key so, in this sense, the token can be said to belong to the initiator. In Basic Signing and Encryption Scenario, the initiator token is the certificate, Alice.
This element should contain a nested wsp:Policy element and
sp:X509Token element as shown. The sp:IncludeToken attribute
is set to AlwaysToRecipient, which instructs the runtime to include Alice's
public key with every message sent to the recipient. This option is useful, in case the
recipient wants to use the initiator's certificate to perform authentication. The most
deeply nested element, WssX509V3Token10 is optional. It specifies what
specification version the X.509 certificate should conform to. The following alternatives
(or none) can be specified here:
This optional element is a policy assertion that indicates that an X509 Version 3 token should be used.
This optional element is a policy assertion that indicates that an X509 PKCS7 token should be used.
This optional element is a policy assertion that indicates that an X509 PKI Path Version 1 token should be used.
This optional element is a policy assertion that indicates that an X509 Version 1 token should be used.
This optional element is a policy assertion that indicates that an X509 Version 3 token should be used.
This optional element is a policy assertion that indicates that an X509 PKCS7 token should be used.
This optional element is a policy assertion that indicates that an X509 PKI Path Version 1 token should be used.
The recipient token refers to the public/private key-pair owned by the recipient. This token is used as follows:
The token's public key encrypts messages sent from initiator to recipient.
The token's private key decrypts messages received by the recipient.
The token's private key signs messages sent from recipient to initiator.
The token's public key verifies signatures received by the initiator.
Confusingly, this token is used both by the recipient and by the initiator. However, only the recipient has access to the private key so, in this sense, the token can be said to belong to the recipient. In Basic Signing and Encryption Scenario, the recipient token is the certificate, Bob.
This element should contain a nested wsp:Policy element and
sp:X509Token element as shown. The sp:IncludeToken attribute
is set to Never, because there is no need to include Bob's public key in the
reply messages.
![]() | Note |
|---|---|
In Fuse Services Framework, there is never a need to send Bob's or Alice's token in a message, because both Bob's certificate and Alice's certificate are provided at both ends of the connection—see Providing Encryption Keys and Signing Keys. |
This element specifies the suite of cryptographic algorithms to use for signing and encryption. For details of the available algorithm suites, see Specifying the Algorithm Suite.
This element specifies whether to impose any conditions on the order in which security
headers are added to the SOAP message. The sp:Lax element specifies that no
conditions are imposed on the order of security headers. The alternatives to
sp:Lax are sp:Strict, sp:LaxTimestampFirst, or
sp:LaxTimestampLast.
If this element is included in the policy, the runtime adds a
wsu:Timestamp element to the wsse:Security header. By default,
the timestamp is not included.
If a message part is subject to both encryption and signing, it is necessary to specify the order in which these operations are performed. The default order is to sign before encrypting. But if you include this element in your asymmetric policy, the order is changed to encrypt before signing.
![]() | Note |
|---|---|
Implicitly, this element also affects the order of the decryption and signature verification operations. For example, if the sender of a message signs before encrypting, the receiver of the message must decrypt before verifying the signature. |
This element specifies that the message signature must be encrypted (by the encryption token, specified as described in Providing Encryption Keys and Signing Keys). Default is false.
![]() | Note |
|---|---|
The message signature is the signature obtained directly by
signing various parts of the message, such as message body, message headers, or
individual elements (see Specifying Parts of Message to Encrypt and Sign). Sometimes
the message signature is referred to as the primary signature,
because the WS-SecurityPolicy specification also supports the concept of an endorsing
supporting token, which is used to sign the primary signature. Hence, if an
For more details about the various kinds of endorsing supporting token, see SupportingTokens assertions. |
This element specifies that signatures must cover the token used to generate that signature. Default is false.
This element specifies that signatures can be applied only to an
entire body or to entire headers, not to sub-elements of the body or sub-elements of a
header. When this option is enabled, you are effectively prevented from using the
sp:SignedElements assertion (see Specifying Parts of Message to Encrypt and Sign).
Encryption and signing provide two kinds of protection: confidentiality and integrity, respectively. The WS-SecurityPolicy protection assertions are used to specify which parts of a message are subject to protection. Details of the protection mechanisms, on the other hand, are specified separately in the relevant binding policy (see xSpecifying an AsymmetricBinding Policy, Specifying a SymmetricBinding Policy, and Transport Layer Message Protection).
The protection assertions described here are really intended to be used in combination with SOAP security, because they apply to features of a SOAP message. Nonetheless, these policies can also be satisfied by a transport binding (such as HTTPS), which applies protection to the entire message, rather than to specific parts.
A protection assertion must be applied to a message policy
subject (see Message policy subject). In
other words, it must be placed inside a wsdl:input, wsdl:output,
or wsdl:fault element in a WSDL binding. For example, given the protection
policy with ID,
MutualCertificate10SignEncrypt_IPingService_header_Input_policy, you could
apply the policy to a wsdl:input message part as follows:
<wsdl:operation name="header">
<soap:operation soapAction="http://InteropBaseAddress/interop/header" style="document"/>
<wsdl:input name="headerRequest">
<wsp:PolicyReference
URI="#MutualCertificate10SignEncrypt_IPingService_header_Input_policy"/>
<soap:header message="i0:headerRequest_Headers" part="CustomHeader" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
...
</wsdl:operation>The following WS-SecurityPolicy protection assertions are currently supported by Fuse Services Framework:
SignedParts
EncryptedParts
The following WS-SecurityPolicy protection assertions are not supported by Fuse Services Framework:
SignedElements
EncryptedElements
ContentEncryptedElements
RequiredElements
RequiredParts
The SignedParts element has the following syntax:
<sp:SignedParts xmlns:sp="..." ... > <sp:Body />? <sp:Header Name="xs:NCName"? Namespace="xs:anyURI" ... />* <sp:Attachments />? ... </sp:SignedParts>
The EncryptedParts element has the following syntax:
<sp:EncryptedParts xmlns:sp="..." ... > <sp:Body/>? <sp:Header Name="xs:NCName"? Namespace="xs:anyURI" ... />* <sp:Attachments />? ... </sp:EncryptedParts>
Example 6.6 shows a policy that combines
two protection assertions: a signed parts assertion and an encrypted parts assertion. When
this policy is applied to a message part, the affected message bodies are signed and
encrypted. In addition, the message header named CustomHeader is
signed.
Example 6.6. Integrity and Encryption Policy Assertions
<wsp:Policy wsu:Id="MutualCertificate10SignEncrypt_IPingService_header_Input_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Name="CustomHeader" Namespace="http://InteropBaseAddress/interop"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>This element specifies that protection (encryption or signing) is applied to the body
of the message. The protection is applied to the entire message body:
that is, the soap:Body element, its attributes, and its content.
This element specifies that protection is applied to the SOAP header specified by the
header's local name, using the Name attribute, and namespace, using the
Namespace attribute. The protection is applied to the
entire message header, including its attributes and its
content.
By applying message protection at the SOAP encoding layer, instead of at the transport layer, you have access to a more flexible range of protection policies. In particular, because the SOAP layer is aware of the message structure, you can apply protection at a finer level of granularity—for example, by encrypting and signing only those headers that actually require protection. This feature enables you to support more sophisticated multi-tier architectures. For example, one plaintext header might be aimed at an intermediate tier (located within a secure intranet), while an encrypted header might be aimed at the final destination (reached through an insecure public network).
As described in the WS-SecurityPolicy specification, one of the following binding types can be used to protect SOAP messages:
sp:TransportBinding—the transport
binding refers to message protection provided at the transport level
(for example, through HTTPS). This binding can be used to secure any message type, not
just SOAP, and it is described in detail in the preceding section, Transport Layer Message Protection.
sp:AsymmetricBinding—the asymmetric
binding refers to message protection provided at the SOAP message
encoding layer, where the protection features are implemented using asymmetric
cryptography (also known as public key cryptography).
sp:SymmetricBinding—the symmetric
binding refers to message protection provided at the SOAP message
encoding layer, where the protection features are implemented using symmetric
cryptography. Examples of symmetric cryptography are the tokens provided by
WS-SecureConversation and Kerberos tokens.
The following qualities of protection can be applied to part or all of a message:
Encryption.
Signing.
Signing+encryption (sign before encrypting).
Encryption+signing (encrypt before signing).
These qualities of protection can be arbitrarily combined in a single message. Thus, some parts of a message can be just encrypted, while other parts of the message are just signed, and other parts of the message can be both signed and encrypted. It is also possible to leave parts of the message unprotected.
The most flexible options for applying message protection are available at the SOAP
layer (sp:AsymmetricBinding or sp:SymmetricBinding). The
transport layer (sp:TransportBinding) only gives you the option of applying
protection to the whole message.
Currently, Fuse Services Framework enables you to sign or encrypt the following parts of a SOAP message:
Body—sign and/or encrypt the whole of the
soap:BODY element in a SOAP message.
Header(s)—sign and/or encrypt one or more SOAP message headers. You can specify the quality of protection for each header individually.
Attachments—sign and/or encrypt all of the attachments in a SOAP message.
The WS-SecurityPolicy specification also defines policies for applying protection to individual XML elements, but this is currently not supported in Fuse Services Framework.
Not all of the details required for message protection are specified using policies. The policies are primarily intended to provide a way of specifying the quality of protection required for a service. Supporting details, such as security tokens, passwords, and so on, must be provided using a separate, product-specific mechanism. In practice, this means that in Fuse Services Framework, some supporting configuration details must be provided in Spring XML configuration files. For details, see Providing Encryption Keys and Signing Keys.