nerdexam
Oracle

1Z0-899 · Question #189

Which java code snippet checks whether the user is of the role "MANAGER" for a given HttpServRequest, httpServletRequest?

The correct answer is A. httpServletRequest.isUserInRole("MANAGER"). public boolean isUserInRole(java.lang.String role) Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method…

Security

Question

Which java code snippet checks whether the user is of the role "MANAGER" for a given HttpServRequest, httpServletRequest?

Options

  • AhttpServletRequest.isUserInRole("MANAGER");
  • BhttpServletRequest.isCallerInRole("MANAGER");
  • ChttpServletRequest.isPrincipalInRole("MANAGER");
  • DhttpServletRequest.isAuthnticatedUserInRole("MANAGER");

How the community answered

(53 responses)
  • A
    77% (41)
  • B
    15% (8)
  • C
    6% (3)
  • D
    2% (1)

Explanation

public boolean isUserInRole(java.lang.String role) Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false. role - a String specifying the name of the role a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated Not B: isCallerInRole is depreciated.

Topics

#isUserInRole#role-based authorization#HttpServletRequest#programmatic security

Community Discussion

No community discussion yet for this question.

Full 1Z0-899 Practice