![]() |
Form-based Authentication Sample Application |
Form-based Authentication Sample Application
This document describes how to utilize the Form-based Authentication sample application in conjunction with Sun Java (tm) System Application Server 7.This sample application document contains the following sections:
Overview
Compiling and Assembling the Sample Application
Deploying the Sample Application
Overview
The Form-based Authentication sample application is a collection of simple applications that demonstrate the usage of the Java Servlet and Java Server Pages (JSP) specifications. Assembling this application and deploying it to the Sun Java (tm) System Application Server introduces you to the Sun Java (tm) System 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.You will need to add usernames in the keyfile. The procedure is as follows:
Login as administrator through the admin GUI and perform the following steps.
Expand the server instance (server1).
Click New and enter required information.
- Click Ok.
( Create users j2ee, ias, alpha, beta, gamma with password set to secret and groups as staff and eng ).
Apply changes and restart the instance.
Verify that the entry is added in the <install-root>/domains/domain1/server1/config/keyfile
Note Restart the appserver once you update the keyfile.
After all the users are added from command line, make sure you run the reconfig command. For example:
Compiling and Assembling the Sample Application
This section contains instructions to build and assemble the Form-based Authentication sample application using a Command Line Interface (CLI).To rebuild the entire application from scratch, follow these steps:
Compile and Assemble Web Application. For example:
You are now ready to use this ear file for deployment.
Deploy the application.
- Execute asant under <install_root>/samples/webapps/security/form-auth/src/
- The default target core will be executed to rebuild the WAR and EAR files.
Clean the web application project area. For example:
- Once you have re-created the sample application from scratch proceed to Deploying the Sample Application.
Deploying the Sample Application
In this section, you will learn how to deploy the Form-based 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 Java (tm) System 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 Java (tm) System 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 WebFormauthApp.ear file is an 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 WebFormauthApp.ear file is simple. Deploy either by Using the asant script or by Using the asadmin command.
Go to the root of the sample directory. For example:
The deployment process involves the following operations:Execute asadmin to deploy application to the local application server instance. For example:
Authenticates against the local application server's administrative server
If you would like to verify the registration of the application, you may proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.The EAR file is transferred to the administrative server
The administrative server begins the registration process:
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 Java (tm) System 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:
Open the pre-existing sample EAR file.
Start the admin server if not already started. For example, in UNIX, execute the following: <sjsas_install_dir>/domains/domain1/admin-server/startserv
Navigate to the browser based admin server page [http://<server-host>:<admin-port>/index.html].
Enter your <username> and <password> to access the admin server.
Click on App Server Instances>server1>Applications>Enterprise Apps
In the right hand pane, click on Deploy to deploy an application.
You will be asked for the application name. Enter WebFormauth and Click OK.
Verifying Deployment
As an optional step, you can use the Sun Java (tm) System 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:
Execute the command asadmin list-components to look at applications deployed with a server instance. For example:
Alternately, you may navigate the Admin tool GUI to the following:
- asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>
- You will see WebFormauth listed.
On the left frame, Click on Enterprise Apps to display list of applications deployed on server.
Running the Sample Application
You can run the application through the following URL: http://<hostname>:<port>/formauth/index.jspLog on as "j2ee" with password "secret".
Close all the browser instances before you try relogging in again; if you are using Netscape you have to close the email session also. Otherwise, it will pick up the session information from the previous logins and grant you access.
Although the war, ear, context-root and servlet alias names in this sample are all "WebFormauthAuth", 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 <install-root>/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