Web services security encompasses the following key aspects:
- Authentication
- Confidentiality – message encryption
- Integrity – digital signature
This article will describe how authentication is enabled between two services by using the Username token. It will also describe the use of Secure Sockets Layer (SSL) to transport SOAP messages between a client and a web service over HTTP. In WebSphere Process Server V7 (hereafter called Process Server), we use policy sets and binding to standardize the way security and other quality of service parameters are configured. This enables reuse of configuration and an exchange of configuration information in a standardized manner. This also enables policies to be applied dynamically on the server instead of having to define them during development using deployment descriptors.
-
Policy type: This is a single type of Quality of Server (QoS)
defined by a set of assertions. Examples of policy types are:
- WS-Security
- WS-Transaction
- HTTPs
- WS-Addressing
- Policy: This is a named configured instance of a policy.
- Binding: This is a topology-specific configuration of a QoS. It contains environment and system specific configuration parameters, such as persistence store information or key store information.
In Process Server, authentication is supported by the following four mechanisms:
- Username token (1.1 and 1.0)
- X.509 certificates
- LTPA token
- Custom
The use of the WS Security Username token profile is common and enables a user name and password to be encapsulated in a security token.
Setting up the security configuration
For purposes of illustration, we will use two simple web-services called "HelloWS" and "HelloBackend" (Figure 1). The service invocation of HelloBackend by HelloWS is secured by a username token and SSL. When HelloWS invokes HelloBackend, the client policies associated with that invocation are calculated and applied.
Figure 1. Sample scenario
"HelloWS" is a simple Service Component Architecture (SCA) module with a web service export and contains a Java™ component with a method called “helloMethod”. This is the web service client that invokes HelloBackend securely. You will configure the client to generate the Username token headers and insert them in the SOAP message request. The client is deployed on Process Server.
"HelloBackend" is a simple SCA module with a web service export and contains a Java component with a method called “operation1”. The web service is deployed in Process Server. You will configure the web service to accept the SOAP headers and authenticate the identity passed in the UsernameToken. The authentication is done by Process Server using an internal file repository as the user registry, and requires that the SOAP requestor messages contain the user name and password in the SOAP header.
For simplicity, you can deploy HelloWS and HelloBackend into the same Process Server instance that is included in WebSphere Integration Developer.
The sample scenario was tested with WebSphere Process Server V7.0. To run the sample, you need the following:
- WebSphere Integration Developer V7.0. Ensure that the integrated test environment with WebSphere Process Server V7.0 is available.
- WebSphere global security is enabled on Process Server with administrative and application security also enabled.
- The user account repository is set to a federated repository with the default Internal File Repository. Ensure that the user ID “jdoe” with a password of “jdoe” are created in the file registry. Use the administrative console to create this user.
- Download the zip files included in this
article and extract them to your C: drive. This creates a directory
called
WPS7UsernameTokenArticleand places the following files in the directory:- HelloBackendApp.ear
- HelloWSApp.ear
- WSS-UNT-SamplePI.zip
The basic steps required to run our scenario are:
- Deploy the client-side and service-side applications.
-
Configure SSL:
- Create a server-side SSL configuration.
- Create the server-side key store.
- Create the server self-signed certificate.
- Export the signer certificate.
- Create the client-side SSL configuration.
- Create the client-side trust store.
- Import the server’s certificated into the client trust store.
- Create the service-side application policy set for the Username token.
- Attach a policy set and binding to the service.
- Create the client-side application policy set for the Username token.
- Define a client binding.
- Attach a policy set and binding to the client.
- Configure the service end-point on the client side.
- Create a virtual host and enable SSL on the specified port.
- Testing the web services.
Deploying the client-side and service-side applications
- Import the sample project interchange file
included with this article into WebSphere Integration Developer. The
file contains the following projects:
- HelloBackend
- HelloUtil
- HelloWS
- HelloWSLib
- To deploy the applications, use the administrative console and deploy HelloBackendApp.ear and HelloWSApp .ear. No security configuration is required at this stage.
Create a server-side SSL configuration
- Log into Process Server administrative console and click SSL
certificate and key management > SSL configurations >
New. Enter the name of the configuration as
ServerSSLand click OK and save the configuration. All other values are kept as defaults.
Create a server-side key store
- Go to SSL certificate and key management > SSL configurations > ServerSSL > Key stores and certificates and click New.
- Enter the values as shown in Figure 2.
Figure 2. Creating a server key store
Use the WebSphere environment variable, such as CONFIG_ROOT, to indicate the path to the key store. Provide a password for the key store and select the default type as PKCS12.
- Click OK to create the key store and save it the master configuration.
Create a self-signed certificate
- For the demonstration, we will use self-signed certificate for
transferring the key from the server to the client. Go to SSL
certificate and key management > SSL configurations >
ServerSSL > Key stores and certificates >
ServerKeyStore. Click Personal Certificates under
Additional Properties. Click Create > Self-signed
Certificate as shown in Figure 3.
Figure 3. Creating self-signed certifcate
- Enter the values for the self-signed certificate as shown in Figure
4.
Figure 4. Server signed certificate
- Enter the fully qualified host name for the Common name. Click OK and save to the master configuration.
Export the self-signed certificate
- Go to the certificate created in the above step. SSL certificate and key management > SSL configurations > ServerSSL > Key stores and certificates > ServerKeyStore > Personal certificates and click Extract.
- Enter the location where the certificate will be extracted to, as
shown in Figure 5.
Figure 5. Export signed certificate
- Click OK. The self-signed certificated is saved in the indicated location.
Create the client side SSL configuration
- On the client side, log into the Process Server administrative
console and click SSL certificate and key management > SSL
configurations > New. Enter the name of the configuration
as
ClientSSLand click OK and save the configuration. All other values are kept as default.
Create the trust store
- You need to create the trust store into which the extracted self-signed server certificate will be imported. Go to SSL certificate and key management > SSL configurations > ClientSSL > Key stores and certificates and click New.
- Enter the values as shown in Figure 6.
Figure 6. Creating the client trust store
- Enter the path to the trust store. Use WebSphere environment variables and a path specific to your Process Server installation. Provide a password for the trust store. Click OK and save to the master configuration.
Add the server certificate to the client trust store
- Go to SSL certificate and key management > SSL configurations
> ClientSSL > Key stores and certificates >
ClientTrustStore > Signer certificates and click
Add. Enter values as shown in Figure 7.
Figure 7. Adding certificate to client trust store
- Provide the location of the file, which was extracted from the server
in Figure 5. Click OK and save to the
master configuration. Now the client and server can communicate
securely using SSL.
In the following steps, you will configure the Username token and enable the service to authenticate the client.
Creating the service-side application policy set for the Username Token
- Go to Services > Application Policy Sets and click
New. Enter the name for the policy Set as
WSS Username Token Serviceand add a description for the policy set. - Click Add > WS-Security as shown in Figure 8.
Figure 8. Creating the service side application policy set
The WS-Security policy is now added to the policy set as shown in Figure 9.
Figure 9. Setting WS-Security policy
- Click WS-Security and then Main Policy. Uncheck
Message Level Protection as shown in Figure 10. For now,
you will not enable the message level security such as message
encryption or digital signatures (for data integrity).
Figure 10. Main policy definition
- Click OK and save to the master configuration.
- Add the request token policy. Click Man Policy again and
select Request token policies. Select Add Token Type and
Username Token. Provide a token name as shown in Figure 11.
Figure 11. Adding the username token policy to the Main policy
- Click OK and save to the master configuration.
Attaching a policy set and binding to the service
- Before you attach the policy set and binding, create a new binding for the service consumer.
- Go to Services > General provider policy set bindings. Click New.
- Enter the name of the binding as
ServerBinding. Click OK and save. - Go to Services > General provider policy set bindings > ServerBinding.
- Click WS-Security amd then select Authentication and protection.
- Under Authentication tokens, select New Token and then Token Consumer.
- Provide a name for the token consumer as
untconsumer. Select Username Token v1.0 as the token type. - Click Apply and save the changes.
- Again, go to Services > General provider policy set bindings > ServerBinding.
- Click WS-Security and click Caller.
- Click New to enter a new caller. Provide a name for caller as
Calleras shown in Figure 12. - Enter the caller identity local part as:
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile- 1.0#UsernameToken
Figure 12. Adding a caller
- Click OK and save. By defining the caller, you are enabling WebSphere to create the security credential and principal, using the Username token credentials.
- Go to Services > Service providers >
helloBackendExport1_helloBackendHttpService. Select
helloBackendExport1_helloBackendHttpService, click the
Attach button and select WSS Username Token Service
policy set as shown in Figure 13.
Figure 13. Attaching the policy to the service
- Now select helloBackendExport1_helloBackendHttpService again
and click the Assign Binding button and select ServerBinding
as shown in Figure 14.
Figure 14. Assigning the binding to the service
- Save the configuration.
- The policy set attachment for the service provider HelloBackend looks
similar to Figure 15.
Figure 15. Attaching the policy and assigning the binding to the service
Creating the client-side application policy set for the Username token
You will now define a Username policy on the client side as well so that the client can pass the credentials while invoking the service. There are four different scenarios on how a client can obtain the policy while it invokes the web service provider:
- There is no policy.
- Client policy: The policy is calculated based on the policy set, which is a static client policy configuration.
- Provider policy: This policy is based on dynamically acquired provider policy. In this scenario, the policy configuration is based on the provider’s requirements.
- Client and provider policy: In addition to the provider policy, the client can configure the restrictions as to what is applicable.
For our service configuration, we will choose the client policy since we have defined the client policy set.
To define the WS Security policy set for the client side:
- Go to Services > Application Policy Sets and click
New. Enter the name for the policy set as
WSS Username Token Serviceand add a description for the policy set. - Click Add > WS-Security.
- Click WS-Security and then Main Policy. Uncheck Message Level Protection as shown. For the present, you will not be enabling message level security such as message encryption or digital signatures (for data integrity).
- Click OK and save to the master configuration.
- Add the request token policy. Click Man Policy again and
select Request token policies. Select Add Token Type and
Username Token. Provide a token name as
WSS Username Token Clientwith the WS-Security version as 1.0. - Click OK and save to the master configuration.
Bindings provide specific details related to the policy set that is selected at runtime. In the context of the Username token policy, you can provide the specific JAAS Callback Handler to be used.
- Go to Services > General client policy set bindings and
select Client sample. Click the Copy button and provide
a name for the binding as
ClientBinding, as shown in Figure 16. - Now select the newly created ClientBinding. These policies are
already associated with this binding. You will need to configure the
SSL transport and WS-Security policies.
Figure 16. Define client side binding
- Now select WS-Security and then select Authentication and protection.
- Go to Authentication tokens > gen_signunametoken with the
Usage mentioned as Outbound and click it (Figure 17).
Figure 17. Authentication token
- Select the default Token type as Username Token v1.0. Click
Callback Handler at the bottom of the screen. Select Use
custom callback handler class and provide the class name as
com.ibm.raadss.security.UNTCustomCallbackHandler(Figure 18). It is not required to provide the user name and password under the Basic Authentication section.
Figure 18. Defining the custom callback handler on the client side
Note: Using the custom call back handler will provide better features and the ability to pass the username and password dynamically from the client’s session context. Refer to Configuring the custom JAAS callback handler for further details.
- Click OK and save to the master configuration.
- To configure the SSL transport for this client binding, select
General client policy set bindings > ClientBinding > SSL
transport. Under Outbound service requests, select
ClientSSL and under Inbound service responses,
select ClientSSL as shown in Figure 19.
Figure 19. Defining an SSL transport in the client policy set binding
- Click OK and save to the master configuration
Attaching a policy set and binding to client
- Go to Application > Service clients >
helloBackendExport1_helloBackendHttpService. Select
helloBackendExport1_helloBackendHttpService and click the
Attach Client Policy Set button and select WSS Username
Token Client as shown in Figure 20.
Figure 20. Attaching the client policy set
- Now assign the binding associated with this policy set by selecting
the Assign Binding button and select ClientBinding, as
shown in Figure 21.
Figure 21. Assigning the client binding
Configuring the service end-point on the client side
- Go to Applications > SCA Modules >
HelloWS. Under the module components, expand Binding as
shown in Figure 22.
Figure 22. Configuring the service end point
- Select the binding and change the default endpoint of the service.
Click Edit beside Target Endpoint address and enter:
https://localhost:6444/HelloBackendWeb/sca/helloBackendExport1.
In this sample, we have chosen port 6444 as the SSL enabled port where the service will be available. We need to enable port 6444 to accept SSL communication and bind it to our service by defining a new virtual host on that port.
Creating a virtual host and enable SSL on the specified port
- First, you will define a new transport chain on the server. Go to
Servers > Websphere Application Server. Select the
server and go to Web container transport chains under Web
container settings. Click New. Provide a name for the
transport chain as
ServiceInboundSecure, as shown in Figure 23. Select the Transport chain template as WebContainer-Secure and click Next.
Figure 23. Creating a new virtual host for SSL
- Provide the name of the port as
ServiceSecureand the port number as 6444. Click Next and then Finish to create the new transport chain. Save to the master configuration. - Go to Environment > Virtual Hosts and click New.
Provide a name to the new virtual host as
SecureVH. Click OK and save. - Go to Environment > Virtual Hosts > SecureVH > Host
aliases and click New. Enter
6444as the port number. - Now go to Applications > Enterprise Applications > HelloBackendApp and select Virtual hosts under Web Module properties. From the drop down under Virtual Host, select SecureVH . Click OK and save to the master configuration.
You have now completed the configuration steps required for this sample and you are ready to test it. Restart Process Server so that the transport chain and SSL are activated.
Before testing the web services, ensure that the callback handler is available in the Process Server classpath. Refer to Configuring the custom JAAS callback handler for further details. To verify that the message from the client to server is encrypted and not in clear text, the TCP Monitor can intercept and forward the request. You will use TCP as the transport for this.
- In Websphere Integration Developer, start the TCP Monitor. Go to Windows > Preferences > Run/Debug > TCP/IP Monitor.
- Select Add and provide the details as shown in Figure 24.
Click OK.
Figure 24. TCP Monitor selection to monitor SSL
- Click Start to activate the TCP Monitor.
- Change the service endpoint port for the service invocation. Log on
to the Process Server administration console. Navigate to
Application > SCA Modules > HelloWS. Under
Imports, expand Binding and click the binding that
is displayed. Edit the port number and set it to
2444and click OK and save the configuration. - The service request is directed to port 2444 and then forwarded to port 6444 by the TCP Monitor.
- Use a web service testing tool, such as web services explorer or SOAP
UI, to invoke HelloWS. Since you have configured authentication and
SSL between HelloWS and HelloBackend, you will verify the proper
invocation of the HelloBackend service by viewing entries in the log
file indicating this. Enter a value for input1 element as
jdoe. This user ID was registered in the internal file user registry as a prerequisite to this exercise (Figure 25).
Figure 25. Invoking HelloWS web service client
- View the TCP Monitor. It does not show you any text as it is encrypted.
- View the
SystemOut.logfile (Figure 26) on Process Server, indicating the communication between the client and server.
Figure 26. Viewing SystemOut.log file
- Now re-invoke this service with the input1 element set to a user ID not available in the internal file user registry. You will see an error indicating that the service failed to check the given username and password in the user registry.
Configuring the custom JAAS callback handler
WebSphere provides a default username token callback handler that passes the username, password, and the username token properties while a service requestor invokes a web service. However, you can develop a custom callback handler to pass the user ID and password dynamically. This is configured in the client policy set binding for WS-Security in Process Server.
The requirements for the custom callback handler are as follows:
- The callback handler must implement the javax.security.auth.callback.Callback interface.
- This callback handler implements the handle (Callback callbacks[]) method in the interface.
- The handle method needs to support four types of callbacks: NameCallback, PasswordCallback, PropertyCallback, and UNTGenerateCallback
- The callback handle must have a constructor, which takes a Map<Object,Object> object as input.
Download the sample callback implementation. Compile and export the Java class in a JAR file and place it in the Process Server classpath.
The callback handler class has two thread local variables that can store the user ID and password from the client instance. This is referred in the handle method of the callback handler. The client will use the setThreadIdentity to pass the credentials to the callback handler.
Message level security is an important component in SOA. In the sample, you used transport level security because the password would otherwise be in clear text. In addition, you also explored the use of policy sets and bindings in WebSphere Process Server V7.0 to configure WS-Security and transport level security.
The author would like to thank S Saravanan and Naveen Reddy for their valuable comments and reviews.
| Description | Name | Size | Download method |
|---|---|---|---|
| Code sample | HelloWSApp.ear | 15KB | HTTP |
| Code sample | HelloBackendApp.ear | 14KB | HTTP |
| Code sample | WSS-UNT-SamplePI.zip | 26KB | HTTP |
Information about download methods
-
WebSphere Process Server V7.0 Information Center
-
OASIS Standard: Web services security: UsernameToken Profile 1.0
-
IBM Redbook:
WebSphere Application Server V7.0 Web Services Guide





