Exit GSSP-JAVA GIAC Secure Software Programmer - Java
Question 2 of 5
0% complete
Q2 Single choice

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?

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

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