Câu 22: GSSP-Java: GIAC Secure Software Programmer-Java
Mark works as a Programmer for InfoTech Inc. He develops a class named Data that imports all the required packages. The class Data uses a method named PrintData(), which uses a method that checks whether the caller has a BeanUser security role. Which of the following code of the method PrintData() will satisfy the req…
Nội dung câu hỏi
Mark works as a Programmer for InfoTech Inc. He develops a class named Data that imports all the required packages. The class Data uses a method named PrintData(), which uses a method that checks whether the caller has a BeanUser security role. Which of the following code of the method PrintData() will satisfy the requirement?
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. public void PrintData(){@DeclareRoles("BeanUser")@Resource SessionContext ctx;@RolesAllowed("BeanUser")Principal caller = ctx.getCallerPrincipal();if (ctx.getCallerIdentity("BeanUser")) {System.out.println("It is the correct user");}else{System.out.println("It is the incorrect user");}//more code}
- B. public void PrintData(){@DeclareRoles("BeanUser")@Resource SessionContext ctx;@RolesAllowed("BeanUser")Principal caller = ctx.getEJBHome();if (!isCallerInRole(ctx)) {System.out.println("It is the correct user");} else{System.out.println("It is the incorrect user");}//more code}
- C. public void PrintData(){@DeclareRoles("BeanUser")@Resource SessionContext ctx;@RolesAllowed("BeanUser")Principal caller = ctx.getCallerPrincipal();if (ctx.isCallerInRole("BeanUser")) {System.out.println("It is the correct user");}else{System.out.println("It is the incorrect user");}//more code} — đáp án hiện tại
- D. public void PrintData(){@DeclareRoles("BeanUser")@Resource SessionContext ctx;@RolesAllowed("BeanUser")Principal caller = ctx.getCallerPrincipal();if (ctx.getStatus("BeanUser")) {System.out.println("It is the correct user");} else{System.out.println("It is the incorrect user");}//more code}
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.