/** * Test for role membership. * * Use Principal.getName() to get the username from the principal object. * * @param principal Principal object representing a user * @param rolename name of a role to test for membership * * @return true if the user is in the role, false otherwise */ public boolean isUserInRole(Principal principal, String rolename) { String username = null; if (principal != null) { username = principal.getName(); } return isUserInRole(username, rolename); } }