2017年11月30日 星期四

QUESTION 97

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 {}

Correct Answer: A

Explanation/Reference:
* 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.

沒有留言:

張貼留言