Which of the following annotations relate to security in a servlet?
(i) @WebSecurity
(ii) @RolesAllowed
(iii) @WebConstraint
(iv) @HttpConstraint
(v) @Servletsecurity
A.
(i) only
B.
(i) and (iii)
C.
(iv) and (v)
D.
(iii) and (v)
E.
(ii) and (iv)
C
strange… in servlet 3.0 (JEE6) @RolesAllowed is used for security too…
@HttpConstraint
@Servletsecurity
@RolesAllowed is either, see http://docs.oracle.com/javaee/6/api/javax/annotation/security/RolesAllowed.html, BUT @Servletsecurity and @HttpConstraint work together.
C
@WebServlet(“/manage”)
@ServletSecurity(@HttpConstraint(rolesAllowed = “admin”))
public class AdminServlet extends HttpServlet {
// servlet code…
}