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.

Securing Enterprise Beans<br />

806<br />

An example that uses annotations to specify method permissions is described in “Example:<br />

Securing an Enterprise Bean” on page 818.<br />

Specifying Method Permissions Using Deployment Descriptors<br />

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

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

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

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

You define the method permissions in the deployment descriptor using the<br />

method-permission elements, as discussed below:<br />

■ Each method-permission element includes a list of one or more security roles and a list of<br />

one or more methods. All the listed security roles are allowed to invoke all the listed<br />

methods. Each security role in the list is identified by the role-name element. Each method<br />

(or set of methods) is identified by the method element.<br />

■ <strong>The</strong> method permissions relation is defined as the union of all the method permissions<br />

defined in the individual method-permission elements.<br />

■ A security role or a method can appear in multiple method-permission elements.<br />

Here is some other useful information about setting method permissions using deployment<br />

descriptors:<br />

■ You can specify that all roles are permitted to execute one or more specified methods,<br />

which, in effect, indicates that the methods should not be checked for authorization prior to<br />

invocation by the container. To specify that all roles are permitted, use the unchecked<br />

element instead of a role name in a method permission.<br />

If a method permission specifies both the unchecked element for a given method and one or<br />

more security roles, all roles are permitted for the specified methods.<br />

■ <strong>The</strong> exclude-list element can be used to indicate the set of methods that should not be<br />

called. At deployment time, the deployer will know that no access is permitted to any<br />

method contained in this list.<br />

If a given method is specified in both the exclude-list element and in a method<br />

permission, the deployer should exclude access to this method.<br />

■ It is possible that some methods are not assigned to any security roles nor contained in the<br />

exclude-list element. In this case, the deployer should assign method permissions for all<br />

of the unspecified methods, either by assigning them to security roles, or by marking them<br />

as unchecked. If the deployer does not assign method permissions to the unspecified<br />

methods, those methods must be treated by the container as unchecked.<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!