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.

Defining Security Requirements forWeb Applications<br />

As shown in the preceding example, the element is the root element for web<br />

applications. <strong>The</strong> element contains the following elements that are used for<br />

specifying security for a web application:<br />

■ <br />

<strong>The</strong> security role reference element contains the declaration of a security role reference in the<br />

web application’s code. <strong>The</strong> declaration consists of an optional description, the security role<br />

name used in the code, and an optional link to a security role.<br />

<strong>The</strong> security role name specified here is the security role name used in the code. <strong>The</strong> value of<br />

the role-name element must be the String used as the parameter to the<br />

HttpServletRequest.isUserInRole(String role) method. <strong>The</strong> container uses the<br />

mapping of security-role-ref to security-role when determining the return value of<br />

the call.<br />

<strong>The</strong> security role link specified here contains the value of the name of the security role that<br />

the user may be mapped into. <strong>The</strong> role-link element is used to link a security role<br />

reference to a defined security role. <strong>The</strong> role-link element must contain the name of one of<br />

the security roles defined in the security-role elements.<br />

For more information about security roles, read “Working with Security Roles” on page 837.<br />

■ <br />

A security role is an abstract name for the permission to access a particular set of resources in<br />

an application. A security role can be compared to a key that can open a lock. Many people<br />

might have a copy of the key. <strong>The</strong> lock doesn’t care who you are, only that you have the right<br />

key.<br />

<strong>The</strong> security-role element is used with the security-role-ref element to map roles<br />

defined in code to roles defined for the web application. For more information about<br />

security roles, read “Working with Security Roles” on page 837.<br />

■ <br />

A security constraint is used to define the access privileges to a collection of resources using<br />

their URL mapping. Read “Specifying Security Constraints” on page 850 for more detail on<br />

this element. <strong>The</strong> following elements can be part of a security constraint:<br />

■ element: Web resource collections describe a URL pattern<br />

and HTTP method pair that identify resources that need to be protected.<br />

■ element: Authorization constraints indicate which users in specified<br />

roles are permitted access to this resource collection. <strong>The</strong> role name specified here must<br />

either correspond to the role name of one of the elements defined for<br />

this web application, or be the specially reserved role name *, which is a compact syntax<br />

for indicating all roles in the web application. Role names are case sensitive. <strong>The</strong> roles<br />

defined for the application must be mapped to users and groups defined on the server.<br />

For more information about security roles, read “Working with Security Roles” on<br />

page 837.<br />

Chapter 30 • SecuringWeb Applications 849

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

Saved successfully!

Ooh no, something went wrong!