private void removeIncludedPrivileges(List<String> privileges, Map<String, Group> groups) { for (String privilege : new ArrayList<String>(privileges)) { for (Group group : groups.values()) { if (group.hasPrivilege(privilege)) { privileges.remove(privilege); } } } }
private void removeIncludedPrivileges(List<String> privileges, Map<String, Group> groups) { for (String privilege : new ArrayList<String>(privileges)) { for (Group group : groups.values()) { if (group.hasPrivilege(privilege)) { privileges.remove(privilege); } } } }
@Override public boolean hasPrivilege(String privilege) { for (Privilege auth : privileges) { if (auth.getName().equals(privilege)) { return true; } if (auth instanceof Group) { if (((Group) auth).hasPrivilege(privilege)) { return true; } } } return false; }
@Override public boolean hasPrivilege(String privilege) { for (Privilege auth : privileges) { if (auth.getName().equals(privilege)) { return true; } if (auth instanceof Group) { if (((Group) auth).hasPrivilege(privilege)) { return true; } } } return false; }
private void removeIncludedGroups(Group group, Map<String, Group> groups) { Set<String> groupNames = new HashSet<String>(groups.keySet()); for (String checkGroupName : groupNames) { if (!group.getName().equals(checkGroupName) && group.hasPrivilege(checkGroupName)) { Group includedGroup = groups.get(checkGroupName); if (includedGroup != null) { removeIncludedGroups(includedGroup, groups); groups.remove(checkGroupName); } } } }
private void removeIncludedGroups(Group group, Map<String, Group> groups) { Set<String> groupNames = new HashSet<String>(groups.keySet()); for (String checkGroupName : groupNames) { if (!group.getName().equals(checkGroupName) && group.hasPrivilege(checkGroupName)) { Group includedGroup = groups.get(checkGroupName); if (includedGroup != null) { removeIncludedGroups(includedGroup, groups); groups.remove(checkGroupName); } } } }
private void removeIncludedGroups(Group group, Map<String, Group> groups) { Set<String> groupNames = new HashSet<String>(groups.keySet()); for (String checkGroupName : groupNames) { if (!group.getName().equals(checkGroupName) && group.hasPrivilege(checkGroupName)) { Group includedGroup = groups.get(checkGroupName); if (includedGroup != null) { removeIncludedGroups(includedGroup, groups); groups.remove(checkGroupName); } } } }
private void removeIncludedGroups(Group group, Map<String, Group> groups) { Set<String> groupNames = new HashSet<String>(groups.keySet()); for (String checkGroupName : groupNames) { if (!group.getName().equals(checkGroupName) && group.hasPrivilege(checkGroupName)) { Group includedGroup = groups.get(checkGroupName); if (includedGroup != null) { removeIncludedGroups(includedGroup, groups); groups.remove(checkGroupName); } } } }
public boolean isOnlyAdmin(Group objGroup) { if (!objGroup.hasPrivilege(Privileges.ADMIN.name())) { return false; } List<Group> groups = getGroups(); int i = 0; for (Group group : groups) { if (group.hasPrivilege(Privileges.ADMIN.name())) { i++; } } return i <= 1; }
public boolean isOnlyAdmin(Group objGroup) { if (!objGroup.hasPrivilege(Privileges.ADMIN.name())) { return false; } List<Group> groups = getGroups(); int i = 0; for (Group group : groups) { if (group.hasPrivilege(Privileges.ADMIN.name())) { i++; } } return i <= 1; }
public String[] getOnlyAdminGroups(Object objUser) { if (!isOnlyAdmin(objUser)) { return new String[0]; } String adminPrivilege = Privileges.ADMIN.name(); List<String> groups = new ArrayList<String>(); @SuppressWarnings("unchecked") Collection<Privilege> authorities = (Collection<Privilege>) ((User) objUser).getAuthorities(); for (Privilege authority : authorities) { if (authority instanceof Group) { Group group = (Group) authority; if (group.hasPrivilege(adminPrivilege)) { groups.add(group.getAuthority()); } } } return groups.toArray(new String[groups.size()]); }
public String[] getOnlyAdminGroups(Object objUser) { if (!isOnlyAdmin(objUser)) { return new String[0]; } String adminPrivilege = Privileges.ADMIN.name(); List<String> groups = new ArrayList<String>(); @SuppressWarnings("unchecked") Collection<Privilege> authorities = (Collection<Privilege>) ((User) objUser).getAuthorities(); for (Privilege authority : authorities) { if (authority instanceof Group) { Group group = (Group) authority; if (group.hasPrivilege(adminPrivilege)) { groups.add(group.getAuthority()); } } } return groups.toArray(new String[groups.size()]); }
Group group = (Group) grantedAuthority; if (group.hasPrivilege(Privileges.ADMIN.name())) { return ACCESS_GRANTED; if (group.hasPrivilege(neededAuthority)) { return ACCESS_GRANTED;