protected boolean isAuth(UserDetails user, Set<String> groupCodes) throws ApsSystemException { if (null == user) { ApsSystemUtils.getLogger().severe("Null user"); return false; } if (groupCodes.contains(Group.FREE_GROUP_NAME)) return true; List<Group> userGroups = this.getAuthorizationManager().getGroupsOfUser(user); if (null != userGroups) { for (int i = 0; i < userGroups.size(); i++) { Group group = userGroups.get(i); if (groupCodes.contains(group.getName())) return true; } } return false; }
private List<String> searchTrashedResources( String resourceTypeCode, String text, UserDetails currentUser) throws ApsSystemException { List<String> allowedGroups = new ArrayList<String>(); List<Group> userGroups = this.getAuthorizationManager().getGroupsOfUser(currentUser); for (int i = 0; i < userGroups.size(); i++) { Group group = userGroups.get(i); if (group.getName().equals(Group.ADMINS_GROUP_NAME)) { allowedGroups.clear(); break; } else { allowedGroups.add(group.getName()); } } List<String> resourcesId = this.getTrashedResourceManager() .searchTrashedResourceIds(resourceTypeCode, text, allowedGroups); return resourcesId; }
private List<String> getAllowedGroupCodes(UserDetails user) { List<Group> groups = new ArrayList<Group>(); List<Group> groupsOfUser = this.getAuthorizationManager().getUserGroups(user); if (this.getAuthorizationManager().isAuthOnGroup(user, Group.ADMINS_GROUP_NAME)) { groups.addAll(this.getGroupManager().getGroups()); } else { groups.addAll(groupsOfUser); } List<String> codes = new ArrayList<String>(); for (int i = 0; i < groups.size(); i++) { Group group = groups.get(i); if (null != group) { codes.add(group.getName()); } } if (!codes.contains(Group.FREE_GROUP_NAME)) { codes.add(Group.FREE_GROUP_NAME); } return codes; }