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

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

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

A.
httpServletRequest.isUserInRole(“MANAGER”);

B.
httpServletRequest.isCallerInRole(“MANAGER”);

C.
httpServletRequest.isPrincipalInRole(“MANAGER”);

D.
httpServletRequest.isAuthnticatedUserInRole(“MANAGER”);

Explanation:
isUserInRole
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.
Parameters:
role – a String specifying the name of the role
Returns:
a boolean indicating whether the user making this request belongs to a given role; false if the user
has not been authenticated
Incorrect:
Not B: isCallerInRole is depreciated.



Leave a Reply 2

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