/** * Check if the user belongs to the group or not. * * @param user user name. * @param group group name. * @return if the user belongs to the group or not. * @throws AuthorizationException thrown if the authorization query can not be performed. */ protected boolean isUserInGroup(String user, String group) throws AuthorizationException { GroupsService groupsService = Services.get().get(GroupsService.class); try { return groupsService.getGroups(user).contains(group); } catch (IOException ex) { throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex); } }
private boolean isUserInAcl(String user, String aclStr) throws IOException { boolean userInAcl = false; if (aclStr != null && aclStr.trim().length() > 0) { GroupsService groupsService = Services.get().get(GroupsService.class); String[] acl = aclStr.split(","); for (int i = 0; !userInAcl && i < acl.length; i++) { String aclItem = acl[i].trim(); userInAcl = aclItem.equals(user) || groupsService.getGroups(user).equals(aclItem); } } return userInAcl; }