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 JSSE in order to communicate with the server. You'll need to 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 having to import the certificate into each client VM. Make sure you have added JSSE jars into the CLASSPATH, of course. [Note: JWSDP users do not need to set the JSSE jars in their CLASSPATH separately.]

The next step is getting Tomcat in the Java WSDP to work with JSSE. This is documented in the Tomcat documentation that is bundled with the Java WSDP. You may need to uncomment the "SSL Connector" portion from the server.xml file. Please follow the Tomcat documentation.

Start Tomcat and try a simple URL using HTTPS (like https://host:8443/index.html ). The browser should ask you to accept a certificate and then display the page. If you got this to work, the server is running fine.

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.