Using interceptors to enforce security

While security is an important aspect of many applications, the use of programmatic security can clutter up business logic. The use of declarative annotations has come a long way in making security easier to use and less intrusive. However, there are still times when programmatic security is necessary. When it is, then the use of interceptors can help remove the security code from the business logic.

Getting ready

The process for using an interceptor to enforce security involves:

  1. Configuring and enabling security for the application server
  2. Adding a @DeclareRoles to the target class and the interceptor class
  3. Creating a security interceptor

How to do it...

Configure the application to handle security as detailed ...

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.