Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Using EJB 3.0 Security Annotations

In an EJB 3.0 application, you can use the javax.annotation.security annotations defined in JSR250 to configure security options on EJB 3.0 session beans.

Table 22-2 summarizes the security annotations that OC4J supports. For an example of how to use these annotations, see "Using Annotations".

Table 22-2 Security Annotations

Annotation Description Applicable To

@RunAs

Defines the role of the application during execution in a Java EE container. The role must map to the user/group information in the container's security realm. For more information, see "Specifying the runAs Security Identity".

Class

@RolesAllowed

Specifies the security roles permitted to access methods in an application. For more information, see "Specifying a Role for an EJB Method".

Class, method, or both.

Method specification overrides class specification if present.

@PermitAll

Specifies that all security roles are allowed to invoke the specified methods. For more information, see "Specifying Unchecked Security for EJB Methods".

Class or method.

Class specification applies to all methods.

Method specification applies only to that method.

@DenyAll

Specifies that no security roles are allowed to invoke the specified methods.

Class or method.

Class specification applies to all methods.

Method specification applies only to that method.

@DeclareRoles

Specifies the security roles used by the application.

Class


When using @PermitAll, @DenyAll and @RolesAllowed annotations, observe the following restrictions:

Using Annotations

Example 22-9 shows how to use the @RolesAllowed annotation. For more information and examples, see the JSR250 specification.

Example 22-9 @RolesAllowed

@RolesAllowed("Users")
public class Calculator {

    @RolesAllowed("Administrator")
    public void setNewRate(int rate) {
    ...
    }
}