This document explains how to set up authentication in the SAAJ reference implementation, and how to set up HTTPS for secure message exchange.
For basic authentication, the SAAJ reference implementation uses the
userInfo
part of the URL specification.
asadmin create-file-user --userpassword user_password --groups user_group user_name
For more information, see Realm Configuration in the Sun Java System Application Server Platform Edition 8.1 2005Q1 Developer's Guide.
Tomcat: Edit the file
<TOMCAT_HOME>/conf/tomcat-users.xml
as follows:
<role>
element:
<role rolename="user_group"/>
<user>
element:
<user username="user_name" password="user_password" roles="user_group"/>
Web Server:
http://localhost:8888
.
web.xml
. For example:
<servlet> <servlet-name>saaj.authenticated</servlet-name> <jsp-file>/echo.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>saaj.authenticated</servlet-name> <url-pattern>/authecho.jsp</url-pattern> </servlet-mapping> <security-constraint> <auth-constraint> <role-name>saaj</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config>
http://USER:PASSWORD@HOST:PORT/FILE
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:
Application Server: Edit the file
<install_dir>/domains/domain1/config/domain.xml
:
<iiop-listener>
element, give the
cert-nickname
attributes of the ssl
elements the
value saaj-test
.
<java-config>
element, give the
jvm-option
named javax.net.ssl.keyStore
the value
$HOME/.keystore
.
Tomcat: See the Tomcat documentation. You may need to uncomment the "SSL
Connector" portion of the
<TOMCAT_HOME>/conf/server.xml
file.
Web Server:
http://localhost:8888
.
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 © 2005 Sun Microsystems, Inc. All rights reserved.