Ejemplo n.º 1
0
 @Override
 public void setPassword(User user, String password) {
   byte[] salt = UserPasswordUtil.getSalt();
   byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt);
   Vertex userVertex = findByIdUserVertex(user.getUserId());
   UserVisalloProperties.PASSWORD_SALT.setProperty(
       userVertex, salt, VISIBILITY.getVisibility(), authorizations);
   UserVisalloProperties.PASSWORD_HASH.setProperty(
       userVertex, passwordHash, VISIBILITY.getVisibility(), authorizations);
   graph.flush();
 }
Ejemplo n.º 2
0
  @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;
  }