Using deployment descriptors for security

Several of the security-related annotations can be overridden in a deployment descriptor. This recipe examines how this is done. This can be useful when access to a method may differ depending on the server it is deployed to. Configuring access in a deployment descriptor will provide this type of flexibility.

Getting ready

The process for creating a deployment descriptor for security configuration includes:

  • Creating an ejb-jar.xml file for the EJB module
  • Using the<enterprise-beans> element to define the EJB
  • Using the<assembly-descriptor> to declare security roles and the method permissions
  • Deploying the application

Each security role is granted access to a set of classes and methods. This can be achieved through ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.