// if user is not an admin user, allow the request only if the user is
// requesting for privileges for themselves or a role they belong to
switch (principal.getType()) {
case USER:
if (!principal.getName().equals(currentUserName)) {
throw new HiveAccessControlException("User : " + currentUserName + " is not"
+ " allowed check privileges of another user : " + principal.getName() + ". "
+ ADMIN_ONLY_MSG);
}
break;
case ROLE:
if (!userBelongsToRole(principal.getName())) {
throw new HiveAccessControlException("User : " + currentUserName + " is not"
+ " allowed check privileges of a role it does not belong to : "
+ principal.getName() + ". " + ADMIN_ONLY_MSG);
}
break;
default: