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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>The</strong> following is a listing of annotations that address security, can be used in an enterprise bean,<br />

and are discussed in this tutorial:<br />

■ <strong>The</strong> @DeclareRoles annotation declares each security role referenced in the code. Use of<br />

this annotation is discussed in “Declaring Security Roles Using Annotations” on page 799.<br />

■ <strong>The</strong> @RolesAllowed, @PermitAll, and @DenyAll annotations are used to specify method<br />

permissions. Use of these annotations is discussed in “Specifying Method Permissions<br />

Using Annotations” on page 805.<br />

■ <strong>The</strong> @RunAs metadata annotation is used to configure a component’s propagated security<br />

identity. Use of this annotation is discussed in “Configuring a Component’s Propagated<br />

Security Identity” on page 811.<br />

Using Enterprise Bean Security Deployment<br />

Descriptor Elements<br />

Securing Enterprise Beans<br />

Enterprise <strong>Java</strong>Beans components use an EJB deployment descriptor that must be named<br />

META-INF/ejb-jar.xml and must be contained in the EJB JAR file. <strong>The</strong> role of the deployment<br />

descriptor is to relay information to the deployer about security and other aspects of the<br />

application. Specifying this information in annotations or in the deployment descriptor helps<br />

the deployer set up the appropriate security policy for the enterprise bean application. More<br />

detail about the elements contained in deployment descriptors is available in the <strong>Oracle</strong><br />

GlassFish Server 2.1.2 Application Deployment Guide.<br />

Note – Using annotations is the recommended method for adding security to enterprise bean<br />

applications.<br />

Any values explicitly specified in the deployment descriptor override any values specified in<br />

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

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

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

<strong>The</strong> following is a listing of deployment descriptor elements that address security, can be used<br />

in an enterprise bean, and are discussed in this tutorial:<br />

■ <strong>The</strong> security-role-ref element declares each security role referenced in the code. Use of<br />

this element is discussed in “Declaring Security Roles Using Deployment Descriptor<br />

Elements” on page 800.<br />

■ <strong>The</strong> security-role element defines broad categories of users, and is used to provide access<br />

to protected methods. Use of this element is discussed in “Defining Security Roles” on<br />

page 802.<br />

Chapter 29 • Securing <strong>Java</strong> <strong>EE</strong> Applications 813

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

Saved successfully!

Ooh no, something went wrong!