@Test public void testAddUser() { secureGraphUserRepository.addUser("12345", "testUser", null, "testPassword", new String[]{"auth1", "auth2"}); SecureGraphUser secureGraphUser = (SecureGraphUser) secureGraphUserRepository.findByUsername("12345"); assertEquals("testUser", secureGraphUser.getDisplayName()); }
@Override public User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); User existingUser = findByUsername(username); if (existingUser != null) { throw new LumifyException("duplicate username"); } String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = "USER_" + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); LumifyProperties.CONCEPT_TYPE.setProperty(userBuilder, userConceptId, VISIBILITY.getVisibility()); UserLumifyProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserLumifyProperties.DISPLAY_NAME.setProperty(userBuilder, displayName, VISIBILITY.getVisibility()); UserLumifyProperties.CREATE_DATE.setProperty(userBuilder, new Date(), VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_HASH.setProperty(userBuilder, passwordHash, VISIBILITY.getVisibility()); UserLumifyProperties.STATUS.setProperty(userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserLumifyProperties.AUTHORIZATIONS.setProperty(userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserLumifyProperties.PRIVILEGES.setProperty(userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserLumifyProperties.EMAIL_ADDRESS.setProperty(userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); userListenerUtil.fireNewUserAddedEvent(user); return user; }
SecureGraphUserRepository extends UserRepository { @Override public User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); User existingUser = findByUsername(username); if (existingUser != null) { throw new LumifyException("duplicate username"); } String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = "USER_" + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); LumifyProperties.CONCEPT_TYPE.setProperty(userBuilder, userConceptId, VISIBILITY.getVisibility()); UserLumifyProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserLumifyProperties.DISPLAY_NAME.setProperty(userBuilder, displayName, VISIBILITY.getVisibility()); UserLumifyProperties.CREATE_DATE.setProperty(userBuilder, new Date(), VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_HASH.setProperty(userBuilder, passwordHash, VISIBILITY.getVisibility()); UserLumifyProperties.STATUS.setProperty(userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserLumifyProperties.AUTHORIZATIONS.setProperty(userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserLumifyProperties.PRIVILEGES.setProperty(userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserLumifyProperties.EMAIL_ADDRESS.setProperty(userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); userListenerUtil.fireNewUserAddedEvent(user); return user; } }
SecureGraphUserRepository extends UserRepository { @Override public User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); User existingUser = findByUsername(username); if (existingUser != null) { throw new LumifyException("duplicate username"); } String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = "USER_" + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); LumifyProperties.CONCEPT_TYPE.setProperty(userBuilder, userConceptId, VISIBILITY.getVisibility()); UserLumifyProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserLumifyProperties.DISPLAY_NAME.setProperty(userBuilder, displayName, VISIBILITY.getVisibility()); UserLumifyProperties.CREATE_DATE.setProperty(userBuilder, new Date(), VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_HASH.setProperty(userBuilder, passwordHash, VISIBILITY.getVisibility()); UserLumifyProperties.STATUS.setProperty(userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserLumifyProperties.AUTHORIZATIONS.setProperty(userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserLumifyProperties.PRIVILEGES.setProperty(userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserLumifyProperties.EMAIL_ADDRESS.setProperty(userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); userListenerUtil.fireNewUserAddedEvent(user); return user; } @Inject  SecureGraphUserRepository(
            final Configuration configuration,
            final AuthorizationRepository authorizationRepository,
            final Graph graph,
            final OntologyRepository ontologyRepository,
            final UserListenerUtil userListenerUtil); }
SecureGraphUserRepository extends UserRepository { @Override public User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); User existingUser = findByUsername(username); if (existingUser != null) { throw new LumifyException("duplicate username"); } String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = "USER_" + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); LumifyProperties.CONCEPT_TYPE.setProperty(userBuilder, userConceptId, VISIBILITY.getVisibility()); UserLumifyProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserLumifyProperties.DISPLAY_NAME.setProperty(userBuilder, displayName, VISIBILITY.getVisibility()); UserLumifyProperties.CREATE_DATE.setProperty(userBuilder, new Date(), VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_HASH.setProperty(userBuilder, passwordHash, VISIBILITY.getVisibility()); UserLumifyProperties.STATUS.setProperty(userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserLumifyProperties.AUTHORIZATIONS.setProperty(userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserLumifyProperties.PRIVILEGES.setProperty(userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserLumifyProperties.EMAIL_ADDRESS.setProperty(userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); userListenerUtil.fireNewUserAddedEvent(user); return user; } @Inject  SecureGraphUserRepository(
            final Configuration configuration,
            final AuthorizationRepository authorizationRepository,
            final Graph graph,
            final OntologyRepository ontologyRepository,
            final UserListenerUtil userListenerUtil); @Override User findByUsername(String username); @Override Iterable<User> find(int skip, int limit); @Override Iterable<User> findByStatus(int skip, int limit, UserStatus status); @Override User findById(String userId); Vertex findByIdUserVertex(String userId); @Override User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations); @Override void setPassword(User user, String password); @Override boolean isPasswordValid(User user, String password); @Override void recordLogin(User user, String remoteAddr); @Override User setCurrentWorkspace(String userId, String workspaceId); @Override String getCurrentWorkspaceId(String userId); @Override void setUiPreferences(User user, JSONObject preferences); @Override User setStatus(String userId, UserStatus status); @Override void addAuthorization(User user, String auth); @Override void removeAuthorization(User user, String auth); @Override org.securegraph.Authorizations getAuthorizations(User user, String... additionalAuthorizations); static Set<String> getAuthorizations(Vertex userVertex); @Override void setDisplayName(User user, String displayName); @Override void setEmailAddress(User user, String emailAddress); @Override Set<Privilege> getPrivileges(User user); @Override void delete(User user); @Override void setPrivileges(User user, Set<Privilege> privileges); @Override User findByPasswordResetToken(String token); @Override void setPasswordResetTokenAndExpirationDate(User user, String token, Date expirationDate); @Override void clearPasswordResetTokenAndExpirationDate(User user); }
SecureGraphUserRepository extends UserRepository { @Override public User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations) { username = formatUsername(username); displayName = displayName.trim(); User existingUser = findByUsername(username); if (existingUser != null) { throw new LumifyException("duplicate username"); } String authorizationsString = StringUtils.join(userAuthorizations, ","); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); String id = "USER_" + graph.getIdGenerator().nextId(); VertexBuilder userBuilder = graph.prepareVertex(id, VISIBILITY.getVisibility()); LumifyProperties.CONCEPT_TYPE.setProperty(userBuilder, userConceptId, VISIBILITY.getVisibility()); UserLumifyProperties.USERNAME.setProperty(userBuilder, username, VISIBILITY.getVisibility()); UserLumifyProperties.DISPLAY_NAME.setProperty(userBuilder, displayName, VISIBILITY.getVisibility()); UserLumifyProperties.CREATE_DATE.setProperty(userBuilder, new Date(), VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_SALT.setProperty(userBuilder, salt, VISIBILITY.getVisibility()); UserLumifyProperties.PASSWORD_HASH.setProperty(userBuilder, passwordHash, VISIBILITY.getVisibility()); UserLumifyProperties.STATUS.setProperty(userBuilder, UserStatus.OFFLINE.toString(), VISIBILITY.getVisibility()); UserLumifyProperties.AUTHORIZATIONS.setProperty(userBuilder, authorizationsString, VISIBILITY.getVisibility()); UserLumifyProperties.PRIVILEGES.setProperty(userBuilder, Privilege.toString(getDefaultPrivileges()), VISIBILITY.getVisibility()); if (emailAddress != null) { UserLumifyProperties.EMAIL_ADDRESS.setProperty(userBuilder, emailAddress, VISIBILITY.getVisibility()); } User user = createFromVertex(userBuilder.save(this.authorizations)); graph.flush(); userListenerUtil.fireNewUserAddedEvent(user); return user; } @Inject  SecureGraphUserRepository(
            final Configuration configuration,
            final AuthorizationRepository authorizationRepository,
            final Graph graph,
            final OntologyRepository ontologyRepository,
            final UserListenerUtil userListenerUtil); @Override User findByUsername(String username); @Override Iterable<User> find(int skip, int limit); @Override Iterable<User> findByStatus(int skip, int limit, UserStatus status); @Override User findById(String userId); Vertex findByIdUserVertex(String userId); @Override User addUser(String username, String displayName, String emailAddress, String password, String[] userAuthorizations); @Override void setPassword(User user, String password); @Override boolean isPasswordValid(User user, String password); @Override void recordLogin(User user, String remoteAddr); @Override User setCurrentWorkspace(String userId, String workspaceId); @Override String getCurrentWorkspaceId(String userId); @Override void setUiPreferences(User user, JSONObject preferences); @Override User setStatus(String userId, UserStatus status); @Override void addAuthorization(User user, String auth); @Override void removeAuthorization(User user, String auth); @Override org.securegraph.Authorizations getAuthorizations(User user, String... additionalAuthorizations); static Set<String> getAuthorizations(Vertex userVertex); @Override void setDisplayName(User user, String displayName); @Override void setEmailAddress(User user, String emailAddress); @Override Set<Privilege> getPrivileges(User user); @Override void delete(User user); @Override void setPrivileges(User user, Set<Privilege> privileges); @Override User findByPasswordResetToken(String token); @Override void setPasswordResetTokenAndExpirationDate(User user, String token, Date expirationDate); @Override void clearPasswordResetTokenAndExpirationDate(User user);  }