2017年11月30日 星期四

QUESTION 101

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");


Correct Answer: A


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

沒有留言:

張貼留言