public void pushUserAccessChange(User user) { JSONObject json = new JSONObject(); json.put("type", "userAccessChange"); json.put("permissions", getPermissionsWithUserIds(user.getUserId())); json.put("data", getUserRepository().toJsonWithAuths(user)); broadcastJson(json); }
@Handle public JSONObject handle( @Required(name = "user-name") String userName, @Required(name = "auth") String auth, User authUser ) throws Exception { User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("User " + userName + " not found"); } if (!(authorizationRepository instanceof UpdatableAuthorizationRepository)) { throw new VisalloAccessDeniedException("Authorization repository does not support updating", authUser, userName); } for (String authStr : auth.split(SEPARATOR)) { ((UpdatableAuthorizationRepository) authorizationRepository).addAuthorization(user, authStr, authUser); } return userRepository.toJsonWithAuths(user); } }
@Handle public JSONObject handle( @Required(name = "user-name") String userName, @Required(name = "privileges") String privilegesParameter, User authUser ) throws Exception { Set<String> privileges = Privilege.stringToPrivileges(privilegesParameter); User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("Could not find user: " + userName); } privilegeRepository.setPrivileges(user, privileges, authUser); return userRepository.toJsonWithAuths(user); } }
@Handle public JSONObject handle( @Required(name = "user-name") String userName, @Required(name = "auth") String auth, User authUser ) throws Exception { User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("Could not find user: " + userName); } if (!(authorizationRepository instanceof UpdatableAuthorizationRepository)) { throw new VisalloAccessDeniedException("Authorization repository does not support updating", authUser, userName); } ((UpdatableAuthorizationRepository) authorizationRepository).removeAuthorization(user, auth, authUser); return userRepository.toJsonWithAuths(user); } }