Configuring a policy set and bindings for Asymmetric XML Digital Signature or XML Encryption with client and provider general bindings
You can configure the message-level WS-Security policy set and bindings to sign and encrypt a SOAP message by using asymmetric XML Digital Signature and Encryption and general bindings. As part of this procedure, you must specify whether you sign and encrypts or sign or encrypt both the request and response messages.
Before you begin
This task assumes that the service provider and client that you are configuring are in the
JaxWSServicesSamples
application. For more information about obtaining this
application, see Obtaining the JAX-WS Web Services samples.
*=info:com.ibm.wsspi.wssecurity.*=all:com.ibm.ws.webservices.wssecurity.*=all:
com.ibm.ws.wssecurity.*=all: com.ibm.xml.soapsec.*=all: com.ibm.ws.webservices.trace.*=all:
com.ibm.ws.websvcs.trace.*=all:com.ibm.ws.wssecurity.platform.audit.*=off:
About this task
This procedure explains the actions that you need to complete to configure a WS-Security policy set to use the asymmetric XML-Digital Signature and Encryption WS-Security constraints. This procedure also explains how to create new client and provider general bindings and update them to contain your own keystores and keys for asymmetric XML Digital Signature and Encryption.
Because of the nature of JaxWSServicesSamples to apply the policy set and bindings to this application, in the administrative console click Applications > Application types > WebSphere enterprise applications > JaxWSServicesSamples. When you use your own applications, you can use the following paths as an alternative way to access the provider and client for attachment of the policy set and bindings:
* Services > Service Providers > (AppName)
* Services > Service clients > (AppName)
Procedure
- Create the custom policy set.
- In the administrative console, click Services > Policy sets > Application Policy sets.
- Click New.
- Specify Name=AsignEncPolicy.
- Click Apply.
- Under Policies, click Add > WS-Security.
- Edit the custom policy set.
- In the administrative console, click WS-Security
> Main Policy. By default, the policy now has the following configuration:
- Timestamp sent in outbound messages
- Timestamp required in inbound messages
- Sign the request and the response (Body, WS-Addressing header, and Timestamp)
- Encrypt the request and the response (Body and Signature element in SOAP Security header)
If this is the configuration that you want, click Apply, then Save, and continue to the next step.
If you want to change this configuration, complete one or more of the following substeps.
- Optional: Remove Timestamp from both request
and response. You cannot do one-way Timestamp.
To remove Timestamp from both request and response, clear the Include timestamp in security header setting, and then click Apply.
- Optional: Remove signature or encryption
from request message.
- Under Message level protection, click Request message part protection.
- To remove the request encryption, click app_encparts, and then click Delete.
- To remove the request signature, click app_signparts, and then click Delete.
- Click Done.
- Optional: Remove signature or encryption
from response message.
- Under Message level protection, click Response message part protection.
- To remove the response encryption, click app_encparts, and then click Delete.
- To remove the response signature, click app_signparts, and then click Delete.
- Click Done.
- Optional: View or change parts that are
being signed or encrypted in the request.
- Under Message level protection, click Request message part protection.
- To view or change the request encrypted part, click app_encparts,
and then click Edit.
The Elements in Part page displays with the parts that are encrypted in the request message. You can update the settings on this page to add, change, or remove elements to encrypt. By default, the Body and an XPath expression to the Signature are configured. There are two XPath expressions to the Signature element to handle both SOAP 1.1 and SOAP 2.0.
If you would like to add encryption of a UsernameToken, SAML Assertion, or other elements, see Building XPath expressions for WS-Security.
When you finish making your changes, click OK.
- To view or change the request signed part, click app_signparts,
and then click Edit.
The Elements in Part page displays with the parts that are signed in the request message. You can update the settings on this page to add, change, or remove elements to sign. By default, the Body, the QNames for the WS-Addressing header, and XPath expressions to the Timestamp are configured.
If you are using the STR Dereference Transform (STR-Transform) to sign a security token, add the following XPath expression:/*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/' and local-name()='Envelope'] /*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/' and local-name()='Header'] /*[namespace-uri()='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' and local-name()='Security'] /*[namespace-uri()='https://www.w3.org/2000/09/xmldsig#' and local-name()='Signature'] /*[namespace-uri()='https://www.w3.org/2000/09/xmldsig#' and local-name()='KeyInfo'] /*[namespace-uri()='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' and local-name()='SecurityTokenReference']
If you would like to sign other elements, such as a BinarySecurityToken, see Building XPath expressions for WS-Security.
When you finish making your changes, click OK.
- Click Done.
- Optional: View or change parts that are
being signed or encrypted in the response.
- Under Message level protection, click Response message part protection.
- To view or change the response encrypted part, click app_encparts,
and then click Edit.
The Elements in Part page displays with the parts that are encrypted in the response message. You can update the settings on this page to add, change, or remove elements to encrypt. By default, the Body and an XPath expression to the Signature are configured.
When you finish making your changes, click OK.
- To view or change the response signed part, click app_signparts,
and then click Edit.
The Elements in Part page displays with the parts that are signed in the response message. You can update the settings on this page to add, change, or remove elements to sign. By default, the Body, the QNames for the WS-Addressing header, and XPath expressions to the Timestamp are configured.
When you finish making your changes, click OK.
- Click Done.
- Click Apply.
- Save the configuration.
- In the administrative console, click WS-Security
> Main Policy.
- Create the client general binding.
- In the administrative console, click Services > Policy Sets > General client policy set bindings.
- Check Client sample.
- Click Copy....
- Specify name
name: MyClientGeneralBinding
- Click OK.
- Edit the new client general binding to contain your own
keystores and keys.
- Select MyClientGeneralBinding > WS-Security > Authentication and protection.
- Optional: Configure the client's outbound encrypting
public certificate for the request message. This certificate must
match the private key that the provider uses to decrypt the message.
- Under Protection tokens, select gen_encx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a public encrypting certificate from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name and Alias public encrypting certificate.
- Click OK, OK, OK.
If you are using a public encrypting certificate from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the public encrypting certificate.
- Click OK, OK.
- Optional: Configure the client's outbound
private signing key for the request message.
- Under Protection tokens, select gen_signx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a private signing key from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name, Alias, and password for your private signing key.
- Click OK, OK, OK.
If you are using a private signing key from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the private signing key to use.
- Enter the password for the signing key.
- Click OK, OK.
- Optional: Configure the client's inbound
private decrypting key for the response message. This private key
must match the public certificate that the provider used to encrypt
the message.
- Under Protection tokens, select con_encx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a private decrypting key from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name, Alias, and password for your private decrypting key.
- Click OK, OK, OK.
If you are using a private decrypting key from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the private decrypting key to use.
- Enter the password for the decrypting key.
- Click OK, OK.
- Optional: Configure the client's inbound
signature truststore and certificate store for processing the response
message.
- Under Protection tokens, select con_signx509token.
- Select Callback handler.
- Do one of the following actions:
If you want to trust all certificates, perform the following operations. This is the most common configuration option for clients.
- Under Certificates, select Trust any certificate.
- Click OK, OK.
If you want to only trust requests signed by specific signing certificates, do the following actions:
- Next to Trusted anchor store, click New and then specify Name=MyTrustAnchor
- Either select a centrally managed keystore or under External keystore, enter the full path to your truststore, its type, and password.
- Click OK.
- Next to Trusted anchor store, select MyTrustAnchor.
- Click Apply.
- Do one of the following actions:
If you do not need to configure intermediate certificates or Certificate Revocation Lists (CRLs), perform the following actions:
- Next to Certificate Store, select none.
- Click OK, OK.
If you need to configure intermediate certificates or Certificate Revocation Lists (CRLs), perform the following actions:
- Next to Certificate store, click New and then specify name=MyCertStore
- For each CRL that you need to configure, enter it under Revoked certificates.
- For each intermediate certificate that you need to configure, enter it under Intermediate X.509 certificates.
- Click OK.
- Next to Certificate store, select MyCertStore.
- Click OK, OK.
- Create the provider general binding.
- In the administrative console, click Services > Policy sets > General provider policy set bindings.
- Check Provider sample.
- Click Copy....
- Specify Name=MyProviderGeneralBinding.
- Click OK.
- Edit the new provider general binding to contain your own
keystores and keys.
- Select MyProviderGeneralBinding > WS-Security > Authentication and protection.
- Optional: Configure the provider's outbound encrypting
public certificate for the response message. This certificate must
match the private key that the client uses to decrypt the message.
- Under Protection tokens, select gen_encx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a public encrypting certificate from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name and Alias public encrypting certificate.
- Click OK, OK, OK.
If you are using a public encrypting certificate from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the public encrypting certificate.
- Click OK, OK.
- Optional: Configure the provider's outbound
private signing key for the response message.
- Under Protection tokens, select gen_signx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a private signing key from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name, Alias, and password for your private signing key.
- Click OK, OK, OK.
If you are using a private signing key from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the private signing key to use.
- Enter the password for the signing key.
- Click OK, OK.
- Optional: Configure the provider's inbound
private decrypting key for the request message. This private key
must match the public certificate that the client used to encrypt
the message.
- Under Protection tokens, select con_encx509token.
- Select Callback handler.
- Do one of the following actions:
If you are using a private decrypting key from a named keystore, perform the following operations:
- Under keystore, click Custom keystore configuration.
- Under keystore, enter the full path to your keystore, its type, and password.
- Under Key, enter the Name, Alias, and password for your private decrypting key.
- Click OK, OK, OK.
If you are using a private decrypting key from a centralized keystore perform the following operations:
- Under keystore, select the name of the keystore to use.
- Under key, select the name of the private decrypting key to use.
- Enter the password for the decrypting key.
- Click OK, OK.
- Optional: Configure the provider's inbound
signature truststore and certificate store for processing the request
message.
- Under Protection tokens, select con_signx509token.
- Select Callback handler.
- Do one of the following actions:
If you want to trust all certificates, perform the following operations. This is the most common configuration option for clients.
- Under Certificates, select Trust any certificate.
- Click OK, OK.
If you want to only trust requests signed by specific signing certificates, do the following actions:
- Next to Trusted anchor store, click New and then specify Name=MyTrustAnchor
- Either select a Centrally managed keystore, or under External keystore, enter the full path to your truststore, its type, and password.
- Click OK.
- Next to Trusted anchor store, select MyTrustAnchor.
- Click Apply.
- Do one of the following actions:
If you do not need to configure intermediate certificates or Certificate Revocation Lists (CRLs), perform the following actions:
- Next to Certificate Store, select none.
- Click OK, OK.
If you need to configure intermediate certificates or Certificate Revocation Lists (CRLs), perform the following actions:
- Next to Certificate store, click New and then specify name=MyCertStore
- For each CRL that you need to configure, enter it under Revoked certificates.
- For each intermediate certificate that you need to configure, enter it under Intermediate X.509 certificates.
- Click OK.
- Next to Certificate store, select MyCertStore.
- Click OK, OK.
- Configure the client to use the AsignEncPolicy policy set.
- In the administrative console, click Applications > Application types > WebSphere enterprise applications > JaxWSServicesSamples > Service client policy sets and bindings.
- Select the web services client resource (JaxWSServicesSamples).
- Click Attach Policy Set.
- Select AsignEncPolicy.
- Configure the client to use the MyClientGeneralBinding
client general binding
- Select the web services resource again.
- Click Assign Binding, then select MyClientGeneralBinding.
- Configure the provider to use the AsignEncPolicy policy
set.
- In the administrative console, click Applications > Application types > WebSphere enterprise applications > JaxWSServicesSamples > Service provider policy sets and bindings.
- Select the web services provider resource (JaxWSServicesSamples).
- Click Attach Policy Set.
- Select AsignEncPolicy.
- Configure the provider to use the MyProviderGeneralBinding
provider general binding
- Select the web services resource again.
- Click Assign Binding, then select MyProviderGeneralBinding.
- Click Save to save your configuration changes.
- Restart the client and provider.
- Stop the client and the provider.
- Restart the client and the provider.
- Test the Service.
- Point your web browser at the JaxWSServicesSamples:
http://localhost:9080/wssamplesei/demo
Avoid trouble: Make sure that you provide the correct host name and port if your profile is not on the same machine, or the port is not 9080. - Select Message Type Synchronous Echo.
- Make sure Use SOAP 1.2 is not selected.
- Enter a message and click Send Message.
The sample application reply is JAXWS==>Message. - Point your web browser at the JaxWSServicesSamples:
Results
The JaxWSServicesSamples web services application is configured to use asymmetrical XML Digital Signature and Encryption to protect your SOAP requests and responses by using client and provider named general bindings.