Sun ONE logo     
Client Certificate Authentication Sample Application



Client Certificate Authentication Sample Application


This document describes how to utilize the Client Certificate Authentication sample application in conjunction with Sun ONE Application Server version 7.

This sample application document contains the following sections:



Overview

The Client Certificate Authentication sample application is a collection of simple applications that demonstrate the usage of the Java Servlet and Java Server Pages (JSP) specification. Assembling this application and deploying it to the Sun ONE Application Server introduces you to the Sun ONE Application Server Administration Tool.

The following instructions describe how to manually deploy the application. You may want to experiment by modifying and redeploying the sample.


Precompilation Tasks

Before you begin to compile and deploy the code, there are some housekeeping tasks that need to be done.

  1. Open an https listener on the server as described in Sun ONE Application Server Administrator's Guide to Security.

  2. Login to the admin server and from the left hand frame click on the Security option. From the General tab on the right hand side from the drop down list in the Default Realm select certificate. Enable the log level to Finest if you want to see the detailed activity of the server in the server.out log file.

  3. Check whether the signer of the certificate you installed on the server is one of the approved signers on the browser.

    • To check this on the Netscape browser:

    • Click on the security button.

    • A new window should pop up from the left hand column.

    • Click on the signers.

      This should display all the approved signers on the right hand side.

    • To check this on IE:

    • Click on Tools -> Internet Options.

      Click on the Content tab.

    • Click on the Trusted Root Certification Authorities and check whether the CA exists from where you obtained the server certificate.

  4. Edit the sun-application.xml file and enter the values exactly as they appear in the certificate that you installed in your browser.



Compiling and Assembling the Sample Application

This section contains instructions to build and assemble the Client Certificate Authentication sample application using a Command Line Interface (CLI).

To rebuild the entire application from scratch, follow these steps:

  1. Compile and Assemble Web Application. For example:

    Execute asant under <s1as_install_dir>/samples/webapps/security/client-cert/src/.

    The default target core will be executed to rebuild the WAR and EAR files.

  2. Deploy the application.

    Once you have re-created the sample application from scratch proceed to Deploying the Sample Application.

  3. Clean the web application project area. For example:

    Execute asant clean

    This will remove the sample application assemble and build directories.

You are now ready to use this ear file for deployment.



Deploying the Sample Application



In this section, you will learn how to deploy the Client Certificate Authentication sample application.

Select one of the following approaches to deploying the application:

  • Command Line-based Deployment describes how to manually register the application in Sun ONE Application Server using a Command Line Interface (CLI). This is the fastest means of deploying the sample application.

  • GUI-based Deployment describes how to use the Sun ONE Application Server Deployment Tool to import and deploy the sample application.


Command Line-based Deployment

Since a complete EAR file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section.

The pre-built ClientCertApp.ear file is a. Enterprise Archive file that contains the XML deployment descriptor files, application class files, JSPs, and other content required by the application.

Deploying the pre-built ClientCertApp.ear file is simple. Deploy either by Using the asant script or by Using the asadmin command.


Using the asant script

  1. Go to the src directory of the sample. For example:

    <s1as_install_dir>/samples/webapps/security/client-cert/src

  2. Run asant using deploy task. For example:

    %asant deploy


Using the asadmin command

  1. Go to the root of the sample directory. For example:

    <s1as_install_dir>/samples/webapps/security/client-cert

  2. Execute asadmin to deploy application to the local application server instance. For example:

    asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name> ClientCertApp.ear

The deployment process involves the following operations:

  • Authenticates against the local application server's administrative server

  • The EAR file is transferred to the administrative server

  • The administrative server begins the registration process:

    • Parses the EAR file and embedded WAR file

    • Explodes the bits into repository

    • Registers the J2EE application "WebBasicAuth" by updating server.xml

If you would like to verify the registration of the application, you may proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.


GUI-based Deployment

Since a pre-built Enterprise Archive (EAR) file for the sample application is included with the application server, you can use the Sun ONE Application Server Administration Tool to quickly read in the .ear file and deploy it to the application server.

To deploy the EAR file, follow these steps:

  1. Open the pre-existing sample EAR file.

  2. Start the admin server if not already started. For example, in UNIX, execute the following: <s1as_install_dir>/domains/domain1/admin-server/startserv

  3. Open the EAR file.

    1. Navigate to the browser based admin server page [http://<server-host>:<admin-port>/index.html].

    2. Enter your <username> and <password> to access the admin server.

    3. Click on App Server Instances>server1>Applications>Enterprise Apps

    4. In the right hand pane, click on Deploy to deploy an application.

      Choose the file (from disk) to be deployed (ClientCertApp.ear) and Click OK.

    5. You will be asked for the application name. Enter ClientCertApp and Click OK.

      If the deployment goes through fine, you will see the original pane with ClientCertApp application as deployed. In the startup dialog, select Browse for more applications to find the ClientCertApp.ear file.


Verifying Deployment

As an optional step, you can use the Sun ONE Application Server Administration Tool to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.

To verify the registration of the application, follow these steps:

  1. Execute the command asadmin list-components to look at applications deployed with a server instance. For example:

    asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>

    You will see WebBasicAuth listed.

  2. Alternately, you may navigate the Admin tool GUI to the following:

    App Server Instances>server1>Applications.

  3. On the left frame, Click on Enterprise Apps to display list of applications deployed on server.

    You will see WebBasicAuth listed.



Running the Sample Application

You can run the application through the following URL:

https://<hostname>:<port>/cert/index.jsp



Troubleshooting



  • Although the war, ear, context-root and servlet alias names in this sample are all "ClientCertApp", it is not necessary that it be so. The application will work as expected if the names of each of these attributes is unique. Rebuild the app after changing the context-root (in application.xml), the servlet alias (in web.xml) and the war and ear names (in the asant build.xml), redeploy and test the sample to confirm this.

  • If you encounter problems when running the application, review the log files at <s1as-install-dir>/domains/domain1/<server-instance>/logs/server.log to learn what exactly went wrong.



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

Last Updated August 20, 2002