private List<String> extractUserGroupNames(UserDetails user) throws ApsSystemException { List<IApsAuthority> authorities = this.getGroupManager().getAuthorizationsByUser(user); List<String> groupNames = new ArrayList<String>(authorities.size()); for (IApsAuthority authority : authorities) { groupNames.add(authority.getAuthority()); } return groupNames; }
/** * Verify the validity of the Authority. * * @param authority The authority to verify. * @return True if the authority is valid, else false. */ protected boolean checkAuthority(IApsAuthority authority) { if (null == authority) { ApsSystemUtils.getLogger().severe("Invalid authority detected"); // "Required Users by null authority"; return false; } IApsAuthority authForCheck = this.getAuthority(authority.getAuthority()); if (null == authForCheck) { ApsSystemUtils.getLogger() .severe("The authority with code " + authority.getAuthority() + " does not exist"); // "Required Users by not existing authority : code " + authority.getAuthority()); return false; } if (!authForCheck.getClass().equals(authority.getClass())) { ApsSystemUtils.getLogger() .severe( "Mismatching authority classes detected; code " + authority.getAuthority() + " - Class " + authority.getClass() + " is different by " + authForCheck.getClass()); // "Required Users by invalid authority: code " + authority.getAuthority() + " - Class " + // authority.getClass()); return false; } return true; }