Next Question

Which java code snippet roles “MANAGER” and “EMPLOYEE” in a given application?

A.
@DeclareRoles({ “MANAGER”, “EMPLOYEE” })
public class MyServlet extends HttpServlet {}

B.
@SecurityRoles({ “MANAGER”, “EMPLOYEE” })
public class MyServlet extends HttpServlet {}

C.
@DeclareRoles(“MANAGER”)
@DeclareRoles(“EMPLOYEE”)
public class MyServlet extends HttpServlet {}

D.
@DeclareRole(“MANAGER”)
@DeclareRole(“EMPLOYEE”)
public class MyServlet extends HttpServlet {}

Explanation:
* The syntax for declaring more than one role is as shown in the following example:
@DeclareRoles({“Administrator”, “Manager”, “Employee”})
* @DeclareRoles
This annotation declares the security roles defined by the application.
* javax.annotation.security
Annotation Type DeclareRoles
@Documented
@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface DeclareRoles
Used by application to declare roles. It can be specified on a class.

Next Question

Leave a Reply

Your email address will not be published. Required fields are marked *