This subsection describes the applicability of annotations included in the javax.annotation.security package. The following sections describe the annotations that you can code in each component:
The following table lists the annotations that you can code in a WAR file.
Table 2-6 Annotations (javax.annotation.security package) that can be coded in WAR file (Servlet 3.0 compliant).
Annotation name | Servlet specifications | JSP specifications | Exception class | ManagedBean(JSF) | Other class | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Servlet | Servlet (API) | Servlet filter | Servlet filter (API) | Event listener | Event listener (API) | JSP file | Tag handler | Tag library event listener | |||||
Classic tag handler | Simple tag handler | ||||||||||||
@DeclareRoles | Y | Y | Y | -- | Y | -- | -- | -- | -- | -- | -- | -- | -- |
@RunAs | Y | N | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
The following table lists the annotations that you can code in a WAR file:
Table 2-7 Annotations (javax.annotation.security package) that can be coded in a WAR file (Supported by Servlet 2.5)
Annotation name | Servlet specifications | JSP specifications | Other class | |||||
---|---|---|---|---|---|---|---|---|
Servlet | Servlet filter | Event listener | JSP file | Tag handler | Tag library event listener | |||
Classic tag handler | Simple tag handler | |||||||
@DeclareRoles | Y | -- | -- | -- | -- | -- | -- | -- |
@RunAs | Y | Y | Y | -- | -- | -- | -- | -- |
The following table lists the annotations that you can code in an EJB-JAR file:
Table 2-8 Annotations (javax.annotation.security package) that can be coded in an EJB-JAR file (EJB3.1/EJB3.0 compliant)
Annotation name | Enterprise Bean | Exception class | Other class | |||||
---|---|---|---|---|---|---|---|---|
Interface | Session Bean | Entity Bean | Message-driven Bean | Interceptor | ||||
Other than the default interceptor | Default interceptor | |||||||
@DeclareRoles | -- | Y | -- | N | -- | -- | -- | -- |
@DenyAll | -- | Y | -- | N | -- | -- | -- | -- |
@PermitAll | -- | Y | -- | N | -- | -- | -- | -- |
@RolesAllowed | -- | Y | -- | N | -- | -- | -- | -- |
@RunAs | -- | Y | -- | N | -- | -- | -- | -- |
The following table lists the annotations that you can code in a servlet or JSP of a library JAR file:
Table 2-9 Annotations (javax.annotation.security package) that can be coded in a library JAR file (Servlets or JSPs)
Annotation name | Servlet specifications | JSP specifications | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Servlet | Servlet (API) | Servlet filter | Servlet filter (API) | Event listener | Event listener (API) | JSP file | Tag handler | Tag library event listener | ||
Classic tag handler | Simple tag handler | |||||||||
@DeclareRoles | -- | -- | Y | -- | Y | -- | -- | -- | -- | -- |
You cannot use the annotations in the Enterprise beans, exception classes, or the other classes of a library JAR file.