Skip to main content

skip to main content

developerWorks  >  WebSphere | SOA and Web services | Rational  >

Message-level security with JAX-WS on WebSphere Application Server v7

Using Rational Application Developer 7.5.2 to build secure JAX-WS Web services

developerWorks
Go to the previous pagePage 6 of 12 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
2742 KB (58 pages)

Get Adobe® Reader®

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Section 6. Consuming a secure service

At this point in the tutorial, you should have the service provider running on WebSphere Application Server v7 with the customized HelloWorldPolicySet and bindings attached. If you were to rerun the service consumer as developed above, the service provider would reply with a SOAP fault indicating that the consumer does not adhere to the policy set attached to this provider. Therefore, you need to attach a policy set to the consumer (i.e. client-side) and customize the consumer bindings to match up with the expectations of the service provider.

One way to ensure the consumer adheres to the policy of the service provider is to use the same policy set, which is what we’ll do in this tutorial. Since you imported the HelloWorldPolicySet into Rational Application Developer to attach it to the service provider, it is also available to be attached to our service consumer.

Attaching a policy set

In a similar fashion to attaching the policy set to the service provider, you do the same thing with the service consumer. The following sections describe this process.

To configure the consumer-side binding for signatures:

  1. Drill down to HelloWorldConsumer > Services > Clients > {http://dwexample.ibm.com}HelloWorldProviderService. Right-click and choose Manage policy set attachment…

  2. Click the Next button followed by the Add… button of the Application section, which presents the dialog box shown in Figure 40.

    Figure 40. Attaching policy set
    Screen shot of End Point Definition Dialog

  3. Select HelloWorldPolicySet for the policy set drop-down.

  4. Type HelloWorldConsumerBinding in the drop-down binding field and click OK.

  5. Select the WSSecurity policy type in the bindings configuration section. Click the Configure… button, which presents the WSSecurity Binding Configuration dialog as shown in Figure 41.

    Figure 41. WSSecurity Binding Configuration (see enlarged Figure 41)
    Screen shot of WSSecurity Binding Configuration

  6. Select the Digital Signature Configuration tab, and then click the Key Store Settings… button of the Outbound Message Security Configuration section.

  7. Enter the values in the following table for the Key Store Settings dialog shown in Figure 42.


    Field Value
    Keystore path C:\Program Files\IBM\SDP
    \myclientKeys.jks
    Keystore password g00ber
    Keystore type JKS
    Key alias myclient
    Key Password p@ssword




    Figure 42. Outbound signature key settings
    Screen shot of Key Store Settings Dialog of outboand signature key     settings

    Notice that you are specifying that you want to sign the outbound (i.e. service request) message using the private key of the myclient alias.

  8. Click the OK button.

  9. In the Inbound Message Security Configuration section, uncheck the Trust Any Certificate, because we only want to trust the signature if the response is from the server.

  10. Click the Key Store Settings… button, then enter the values in the following table:

    Field Value
    Keystore path C:\Program Files\IBM\SDP
    \myclientKeys.jks
    Keystore password g00ber
    Keystore type JKS


  11. Click the OK button.
  12. Enter C:\temp\server1.cert as the value for the Certificate Path field.

Now you have configured the consumer-side binding for signatures. Next, you will configure the keys to use for encryption.

To configure the keys to use for encryption:

  1. Select the XML Encryption Configuration tab, and then click the Key Store Settings… button of the Outbound Message Security Configuration section.

  2. Enter the values from the following table for the Key Store Settings dialog shown in Figure 43.

    Field Value
    Keystore path C:\Program Files\IBM\SDP
    \myclientKeys.jks
    Keystore password g00ber
    Keystore type JKS
    Key alias server1





    Figure 43. Outbound encryption key settings
    Screen shot of Key Store Settings Dialog for outbound encryption

    Since you are encrypting the service request for the service provider, which is associated with the server1 certificate, you specify the public key of server1 in Figure 44.

  3. Click the OK button.

To configure how to decrypt the inbound message (i.e. the response):

  1. On the XML Encryption Configuration tab, click the Key Store Settings… button in the Inbound Message Security Configuration section.
  2. Enter the values from the following table for the Key Store Settings dialog shown in Figure 44.

    Field Value
    Keystore path C:\Program Files\IBM\SDP
    \myclientKeys.jks
    Keystore password g00ber
    Keystore type JKS
    Key alias myclient
    Key password p@ssword




    Figure 44. Inbound encryption key settings
    Screen shot showing Key Store Settings Dialog for inbound encryption

    When the provider’s response comes back, it will be encrypted with the client’s public key. Therefore, you need to decrypt the message using the client’s private key, which is what we have specified in Figure 44.

  3. Click the OK button.

    Recall that the Username WSSecurity default policy set that you copied included authentication using a username token. Somehow you need to get a valid username token in the SOAP header for the server to verify that you are authenticated before executing the service provider Web service. The Token Authentication tab provides two such methods. You will choose the UNTGenerateCallbackHandler.

  4. Select the Token Authentication tab then choose the com.ibm.websphere.wssecurity.callbackhandler.UNTGenerateCallbackHandler as the callback handler, as Figure 45 shows.

  5. Enter a valid user name and password that matches the user repository of your WebSphere Application Server (e.g. admin/admin).

  6. Click the Add Timestamp checkbox.

  7. Click the Add Nonce checkbox.

  8. Click the OK button, and then click the Finish button.

    Figure 45. Token authentication (see enlarged Figure 45)
    Screen shoot of WSSecurity Binding Configuration

    If the dialog box as shown in Figure 45 does not include checkboxes for Add Timestamp and Add Nonce, you will need to ensure you are using Rational Application Developer 7.5.2 .



Back to top



Go to the previous pagePage 6 of 12 Go to the next page