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.

Mapping Application Roles to Application Server Groups<br />

Map the role of loginUser defined in the application to the group of user defined on the<br />

Application Server by adding a security-role-mapping element to the sun-web.xml runtime<br />

deployment descriptor file. To deploy a WAR on the Application Server, the WAR file must<br />

contain a runtime deployment descriptor. <strong>The</strong> runtime deployment descriptor is an XML file<br />

that contains information such as the context root of the web application and the mapping of<br />

the portable names of an application’s resources to the Application Server’s resources.<br />

<strong>The</strong> runtime deployment descriptor for this example,<br />

tut-install/javaeetutorial5/examples/web/hello1_formauth/web/WEB-INF/sun-web.xml,<br />

looks like this:<br />

<br />

<br />

<br />

/hello1_formauth<br />

<br />

<br />

loginUser<br />

user<br />

<br />

<br />

Examples: SecuringWeb Applications<br />

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

Example Using NetBeans IDE<br />

To build, package, and deploy this application using NetBeans IDE, 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. Open the project in NetBeans IDE by selecting File→Open Project.<br />

4. Browse to the tut-install/javaeetutorial5/examples/web/hello1_formauth/ directory.<br />

5. Make sure that Open as Main Project is selected.<br />

6. Select Open Project.<br />

7. If you are prompted to regenerate the build-impl.xml file, select the Regenerate button.<br />

8. Right-click hello1_formauth in the Projects pane, then select Clean and Build.<br />

9. Right-click hello1_formauth in the Projects pane, then select Undeploy and Deploy.<br />

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

Chapter 30 • SecuringWeb Applications 869

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

Saved successfully!

Ooh no, something went wrong!