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.

Restricting Access to <strong>Java</strong>Server Faces Components<br />

In addition to identifying the FacesServlet instance and providing a mapping to it, you should<br />

also ensure that all applications use FacesServlet to process <strong>Java</strong>Server Faces components.<br />

You do this by setting a security constraint.<br />

To set a security constraint using NetBeans IDE, do the following:<br />

1. Expand the node of your project in the Projects pane.<br />

2. Expand the Web Pages and WEB-INF nodes that are under the project node.<br />

3. Double-click web.xml.<br />

4. After the web.xml file appears in the editor pane, click Security at the top of the editor pane.<br />

5. Click Add Security Constraint.<br />

6. Enter a name for the constraint in the Display Name field.<br />

7. Click Add to add a web resource collection.<br />

8. In the Add Web Resource dialog:<br />

a. Enter a name for the web resource collection in the Resource Name field.<br />

b. In the URL pattern field, enter the path to a JSP page to which you want to restrict access,<br />

such as /response.jsp. Use commas to separate multiple patterns.<br />

c. Click OK.<br />

To set a security constraint by editing the deployment descriptor directly, add a<br />

security-constraint element, and inside the security-constraint element, add the<br />

following:<br />

1. Add a display-name element to identify the name of the constraint.<br />

2. Add a web-resource-collection element.<br />

3. Inside the web-resource-collection element, add a web-resource-name element that<br />

identifies the purpose of the collection.<br />

4. Add a url-pattern element inside the web-resource-collection element and enter the<br />

path to a JSP page to which you want to restrict access, such as /response.jsp.<br />

5. Continue to add URL patterns for all the JSP pages to which you want to restrict access.<br />

Turning OnValidation of XML Files<br />

Basic Requirements of a <strong>Java</strong>Server Faces Application<br />

Your application contains one or more application configuration resource files written in XML.<br />

You can force the <strong>Java</strong>Server Faces implementation to validate the XML of these files by setting<br />

the validateXML flag to true.<br />

To set the flag using NetBeans IDE, do the following:<br />

1. Expand the node of your project in the Projects pane.<br />

2. Expand the Web Pages and WEB-INF nodes that are under the project node.<br />

Chapter 14 • Configuring <strong>Java</strong>Server Faces Applications 461

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

Saved successfully!

Ooh no, something went wrong!