public boolean hasGroupPermission(User user, Type type) { for (String group : user.getGroups()) { Permission perm = groupPermissionMap.get(group); if (perm != null) { if (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(type)) { return true; } } } return false; }
public Permission getCollectivePermission(User user) { Permission permissions = new Permission(); Permission perm = userPermissionMap.get(user.getUserId()); if (perm != null) { permissions.addPermissions(perm); } for (String group : user.getGroups()) { perm = groupPermissionMap.get(group); if (perm != null) { permissions.addPermissions(perm); } } return permissions; }