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.

Checking Caller Identity Programmatically<br />

842<br />

<br />

<br />

<br />

<br />

<br />

} else {<br />

<br />

}<br />

String role = request.getParameter("role");<br />

if (role == null)<br />

role = "";<br />

if (role.length() > 0) {<br />

if (request.isUserInRole(role)) {<br />

}<br />

<br />

} else {<br />

}<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Declaring and Linking Role References<br />

A security role is an application-specific logical grouping of users, classified by common traits<br />

such as customer profile or job title. When an application is deployed, these roles are mapped to<br />

security identities, such as principals (identities assigned to users as a result of authentication)<br />

or groups, in the runtime environment. Based on this mapping, a user with a certain security<br />

role has associated access rights to a web application.<br />

<strong>The</strong> value passed to the isUserInRole method is a String representing the role name of the<br />

user. A security role reference defines a mapping between the name of a role that is called from a<br />

web component using isUserInRole(String role) and the name of a security role that has<br />

been defined for the application. If a element is not declared in a<br />

deployment descriptor, and the isUserInRole method is called, the container defaults to<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!