10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples: SecuringWeb Applications<br />

870<br />

Building, Packaging, and Deploying the Form-Based Authentication<br />

Example Using Ant<br />

To build, package, and deploy this application using the Ant tool, follow these steps:<br />

1. Follow the instructions in “Building the Examples” on page 69 if you have not already done<br />

so. This step is necessary to provide the Ant targets with the location of your tutorial and<br />

Application Server installations.<br />

2. Add users to the file realm of the Application Server as described in “Adding Authorized<br />

Roles and Users” on page 868 if you have not already done so.<br />

3. From a terminal window or command prompt, change to the<br />

tut-install/javaeetutorial5/examples/web/hello1_formauth/ directory.<br />

4. Enter the following command at the terminal window or command prompt:<br />

ant<br />

This target will spawn any necessary compilations, copy files to the<br />

tut-install/javaeetutorial5/examples/web/hello1_formauth/build/ directory, create<br />

the WAR file, and copy it to the<br />

tut-installjavaeetutorial5/examples/web/hello1_formauth/dist/ directory.<br />

5. Deploy the WAR named hello1_formauth.war onto the Application Server using Ant by<br />

entering the following command at the terminal window or command prompt:<br />

ant deploy<br />

6. Follow the steps in “Testing the Form-Based Authentication Web Client” on page 870.<br />

Testing the Form-Based AuthenticationWeb Client<br />

To run the web client, follow these steps:<br />

1. Open a web browser.<br />

2. Enter the following URL in your web browser:<br />

http://localhost:8080/hello1_formauth<br />

Note – If you set the transport guarantee to CONFIDENTIAL as discussed in “Protecting<br />

Passwords with SSL” on page 867, you must load the application in a web browser using<br />

https for the protocol, the HTTPS port that you specified during installation for the port<br />

(by default this port is 8181), and the context name for the application you wish to run. For<br />

the form-based authentication example, you could run the example using the following<br />

URL: https://localhost:8181/hello1_formauth.<br />

<strong>The</strong> login form displays in the browser, as shown in Figure 30–6.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!