SAAJ Security

This document explains how to set up authentication in the SAAJ reference implementation, and how to set up HTTPS for secure message exchange.

Authentication

For basic authentication, the SAAJ reference implementation uses the userInfo part of the URL specification.

Secure Transport

Note: Secure transport applies only to request/response messages (those sent using the SOAPConnection.call method).

Setting up HTTPS is a bit more difficult. The critical part is setting up the server certificates, required by Java Secure Socket Extension (JSSE) in order to communicate with the server. Use the following commands:

keytool -genkey -alias saaj-test -dname "cn=localhost" -keyalg RSA -storepass changeit
keytool -export -alias saaj-test -storepass changeit -file server.cer
keytool -import -v -trustcacerts -alias saaj-test -file server.cer
   -keystore $JAVA_HOME/jre/lib/security/cacerts
   -keypass changeit -storepass changeit

The first command will generate a server certificate in your $HOME/.keystore. The dname should be localhost (if you use localhost in the URLs) or your hostname (where you run the server).

The second command will export the certificate in a file, and the third will import the certificate into the list of certificates the client knows about.

An alternative is to use the server.cer and get it signed by one of the certificate authorities; it will then work with any client, without your having to import the certificate into each client VM.

The next step is to get the Web container to work with JSSE:

Start the Web container and try a simple URL using HTTPS (for example, https://host:1043/index.html). The browser should ask you to accept a certificate and then display the page. If this works, the server is running correctly.

From the SAAJ side, all you need to do is use URLs with HTTPS as the protocol. This will work only if the certificate was successfully imported into <JAVA_HOME>/jre/lib/security/cacerts; otherwise JSSE will not allow the connection.


Copyright © 2004 Sun Microsystems, Inc. All rights reserved.