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 />

Declaring Roles Using Deployment Descriptor Elements<br />

An example of declaring roles referenced in an application using deployment descriptor<br />

elements is shown in the following web.xml deployment descriptor snippet:<br />

<br />

...<br />

<br />

cust<br />

bankCustomer<br />

<br />

...<br />

<br />

When you use the isUserInRole(String role) method, the String role is mapped to the role<br />

name defined in the element nested within the element.<br />

<strong>The</strong> element in the web.xml deployment descriptor must match a <br />

defined in the element of the web.xml deployment descriptor, as shown here:<br />

<br />

bankCustomer<br />

<br />

Defining Security Requirements forWeb Applications<br />

844<br />

Web applications are created by application developers who give, sell, or otherwise transfer the<br />

application to an application deployer for installation into a runtime environment. Application<br />

developers communicate how the security is to be set up for the deployed application<br />

declaratively by use of the deployment descriptor mechanism or programmatically by use of<br />

annotations. When this information is passed on to the deployer, the deployer uses this<br />

information to define method permissions for security roles, set up user authentication, and<br />

whether or not to use HTTPS for transport. If you don’t define security requirements, the<br />

deployer will have to determine the security requirements independently.<br />

If you specify a value in an annotation, and then explicitly specify the same value in the<br />

deployment descriptor, the value in the deployment descriptor overrides any values specified in<br />

annotations. If a value for a servlet has not been specified in the deployment descriptor, and a<br />

value has been specified for that servlet by means of the use of annotations, the value specified in<br />

annotations will apply. <strong>The</strong> granularity of overriding is on the per-servlet basis.<br />

<strong>The</strong> web application deployment descriptor may contain an attribute of metadata-complete<br />

on the web-app element. <strong>The</strong> metadata-complete attribute defines whether the web application<br />

deployment descriptor is complete, or whether the class files of the JAR file should be examined<br />

for annotations that specify deployment information. When the metadata-complete attribute<br />

is not specified, or is set to false, the deployment descriptors examine the class files of<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!