public static void checkSuperuserPrivilege ( UserGroupInformation owner , String supergroup ) throws AccessControlException { PermissionChecker checker = new PermissionChecker ( owner . getUserName ( ) , supergroup ) ; if ( ! checker . isSuper ) { throw new AccessControlException ( "Access denied for user " + checker . user + ". Superuser privilege is required" ) ; } }
Verify if the caller has the required permission . This will result into an exception if the caller is not allowed to access the resource .