@Override public void internalRemoveAuthorization(User user, String auth, User authUser) { Vertex userVertex = findByIdUserVertex(user.getUserId()); Set<String> authorizationSet = getAuthorizations(userVertex); if (!authorizationSet.contains(auth)) { return; } authorizationSet.remove(auth); String authorizationsString = StringUtils.join(authorizationSet, ","); UserVisalloProperties.AUTHORIZATIONS.setProperty( userVertex, authorizationsString, VISIBILITY.getVisibility(), authorizations); graph.flush(); userVertexCache.invalidate(user.getUserId()); }
@Override protected User addUser( String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = GRAPH_USER_ID_PREFIX + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); VisalloProperties.CONCEPT_TYPE.setProperty( userBuilder, userConceptId, VISIBILITY.getVisibility()); UserVisalloProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserVisalloProperties.DISPLAY_NAME.setProperty( userBuilder, displayName, VISIBILITY.getVisibility()); UserVisalloProperties.CREATE_DATE.setProperty( userBuilder, new Date(), VISIBILITY.getVisibility()); UserVisalloProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserVisalloProperties.PASSWORD_HASH.setProperty( userBuilder, passwordHash, VISIBILITY.getVisibility()); UserVisalloProperties.STATUS.setProperty( userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserVisalloProperties.AUTHORIZATIONS.setProperty( userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserVisalloProperties.PRIVILEGES.setProperty( userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserVisalloProperties.EMAIL_ADDRESS.setProperty( userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); afterNewUserAdded(user); return user; }