Sun Java logo     Previous      Contents      Next     

Sun logo
Sun Java System Application Server Enterprise Edition 8 2004Q4 XML and Web Services Security Guide 


Setting Up For Web Services Security

Most of the steps for setting up the Application Server and your applications for using WSS can be accomplished using the Admin Console, the asadmin command-line tool, or by manually editing system files. In general, editing system files is discouraged due to the possibility of making unintended changes that prevent the Application Server from running properly, therefore, where possible, steps for configuring the Application Server using the Admin Console are shown first, with the asadmin tool command shown after. Steps for manually editing system files are shown only when there is no Admin Console or asadmin equivalent.

Follow these steps to setup your system to create, run, and deploy WSS applications.

  1. When using encryption and running on J2SE 1.4.2, configure a JCE provider as described in Configuring a JCE Provider.
  2. If you are using different keystore and/or truststore files from those that ship with the Application Server, point the Application Server to these files as described in Setting Up the Keystore and TrustStore Files in the Application Server.
  3. When using a username token, configure a user database as described in Configuring a User Database for Username Tokens.

Configuring a JCE Provider

The Java Cryptography Extension (JCE) provider included with J2SE 1.4.x does not support RSA encryption. Because most WSS applications use RSA encryption, you must download and install a JCE provider that does support RSA encryption in order to run WSS applications that use encryption.

Note: RSA is public-key encryption technology developed by RSA Data Security, Inc. The acronym stands for Rivest, Shamir, and Adelman, the inventors of the technology.

Follow these steps to add a JCE provider statically as part of your JDK environment:

  1. Download and install a JCE provider JAR (Java ARchive) file. The following URL provides a list of JCE providers that support RSA encryption:
  1. Copy the JCE provider JAR file to <JAVA_HOME>/jre/lib/ext/.
  2. Stop the Application Server. If the Application Server is not stopped and then restarted later in this process, the JCE provider will not be recognized by the Application Server.
  3. Edit the <JAVA_HOME>/jre/lib/security/java.security properties file in any text editor. Add the JCE provider you’ve just downloaded to this file. The java.security file contains detailed instructions for adding this provider. Basically, you need to add a line of the following format in a location with similar properties:
  4. security.provider.<n>=<provider class name>

  1. Save and close the file.
  2. Restart the Application Server.

Setting Up the Keystore and TrustStore Files in the Application Server

Installation of the Application Server generates a digital certificate suitable for internal testing. By default, the Application Server stores its certificate information in two files in the install_dir/domains/domain_name/config directory:

By default, the Application Server is configured with a keystore and truststore that will work with the example applications and for development purposes. For production purposes, you may wish to change the certificate alias, add other certificates to the truststore, or change the name and/or location of the keystore and trust-store files.

In the Enterprise Edition, you can use Network Security Services (NSS) to manage keystore and truststore files. For more information on NSS, go to http://www.mozilla.org/projects/security/pki/nss/. The tools for managing security include the following:

If you use NSS for managing keystore and truststore files, you would modify the property com.sun.appserv.nss.db in place of the javax.net.ssl.keyStore and javax.net.ssl.trustStore properties mentioned in the steps below. For more information on using certutil, pk12util, and other NSS security tools, see NSS Security Tools at http://www.mozilla.org/projects/security/pki/nss/.

Steps for changing the certificate alias and adding certificates to the truststore are discussed in the Security chapter of the J2EE 1.4 Tutorial. Steps for changing the location of the keystore and truststore files are described here.

To change the location of the keystore and truststore files, follow these steps.

  1. Start the Application Server.
  2. Start the Admin Console by entering the following URL in a browser window:
  1. In the Admin Console tree, expand Configurations.
  2. Expand the server-config (Admin Config) node.
  3. Select the JVM Settings node.
  4. Click the JVM Options tab.
  5. On the JVM Options page, add or modify the following values in the Value field to reflect the new location of the certificate files:
  6. -Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/path/ks_name
    -Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/path/ts_name

    where ks_name is the keystore file name and ts_name is the trust-store file name.

  7. Click Save.

Note: There is a convention in SSL that keystore and key password(s) should be the same. But for the sake of completeness, the Application Server’s security environment looks for the system property com.sun.xml.wss.KeyPassword. If this property is explicitly set, the Application Server assumes that this property contains the password for all the keys of the keystore.

  1. In the default certificates, the alias is s1as. If you are using certificates other than the default certificates, edit the following files to change the certificate alias:
    1. In a text editor, open the file install_dir/lib/appclient/wss-client-config.xml.
    2. Edit the following lines, changing s1as to the value of your certificate alias:
    3.     <xwss:Encrypt receiverCertificateAlias="s1as"/>
          <xwss:Sign senderCertificateAlias="s1as"/>

    4. Save and close the file.
    5. In a text editor, open the file install_dir/domains/domain_name/config/wss-server-config.xml.
    6. Edit the following lines, changing s1as to the value of your certificate alias:
    7.     <xwss:Encrypt receiverCertificateAlias="s1as"/>
          <xwss:Sign senderCertificateAlias="s1as"/>

    8. Save and close the file.
  2. Restart the Application Server if Restart Required displays in the console or if you changed the certificate alias.

Configuring a User Database for Username Tokens

By default, the Application Server is configured with a User Database that can be used for Username Tokens. This database is sufficient for running the example applications and for development. In the production environment, you may wish to create another user database. If you want to configure a new user database for username tokens, follow the steps in this section. You can also use NSS to manage users. Refer to Managing Users with Network Security Services (NSS) for more information on configuring users using NSS.

Set up a username database if you are doing password-based authentication. You may be using such authentication in the servlet or EJB containers (independent of your use for message layer security), and the same database could, in many cases, sustain both forms of use. In the case of message layer security, you only need to configure such a database when you are enforcing policies where the authenticate source is sender.

In order to run applications that demonstrate username/password-based authentication, you must configure the username database on the server. In a file-type security realm, the server maintains all user, group, and password information in a text file. The first step to create the simple user database is to create a new file realm specifically for WSS applications, then add users to the realm. For more information on realms, refer to the Configuring Security chapter of the Administration Guide.

  1. Start the Application Server.
  2. Start the Admin Console by entering the following URL in a browser window:
  1. In the Admin Console tree component, expand the Configurations node.
  2. Select the instance you want to configure:
    1. To configure a particular instance, select the instance’s config node. For example, the default instance, server, select the server-config node.
    2. To configure the default settings for all instances, select the default-config node.
  3. Expand the Security node.
  4. Select the Realms node.
  5. On the Realms page, click New.
  6. The Create Realm page is displayed.

  7. Enter a name for the realm in the Name field, for example, wss-realm.
  8. Specify the class name for the realm you want to create. To create a file realm, enter com.sun.enterprise.security.auth.realm.file.FileRealm.
  9. Select Add Property to specify the name and location of the text file that will hold the user information. Add the properties specified in the following table:

    Table 1-3  Required properties for file realms

    Property name

    Description

    Example Value

    file

    Full path and name to the file to which user name and password data should be written.

    install_dir/domains/domain-name/
    config/wss-keyfile

    jaas-context

    Type of login module to use for this realm.

    fileRealm is the only valid value

The next step in configuring a user database is entering the user names, passwords, and the groups to which the users belong. For more discussion on users, realms, and groups, and how these entities match up with roles defined in applications, read the Security chapter of the J2EE 1.4 Tutorial at the following URL:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html

To add users to the database, follow these steps:

  1. Click the Manage Users button from the Edit Realm page.
  2. Click New to add a new user to the wss-realm.
  3. Enter the following information on the File Users page:
    • User ID (required) - The name of the user.
    • Password (required) - The user’s password.
    • Confirm Password (required) - The user’s password again, for verification.
    • Group List (optional) - a comma-separated list of the groups to which the user belongs. These groups do not need to be defined elsewhere.
  4. Click OK to add this user to the list of users in the wss-realm. Click Cancel to quit without saving.

Managing Users with Network Security Services (NSS)

In the Enterprise Edition, you can manage users using the Admin Console or you can manage users using NSS tools. Network Security Services (NSS) is a set of libraries designed to support cross-platform development of security-enabled client and server applications. Applications built with NSS can support SSL v2 and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other security standards. For detailed information, link to the following URLs:



Previous      Contents      Next     


Copyright 2004 Sun Microsystems, Inc. All rights reserved.