@Test(expected = LumifyException.class) public void testSetPasswordWithNullUser() { sqlUserRepository.setPassword(null, "1u201"); }
@Override public void setPassword(User user, String password) { checkNotNull(password); Session session = sessionManager.getSession(); if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) { throw new LumifyException("User is not valid"); } Transaction transaction = null; try { transaction = session.beginTransaction(); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); ((SqlUser) user).setPassword(salt, passwordHash); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while setting password", e); } }
SqlUserRepository extends UserRepository { @Override public void setPassword(User user, String password) { checkNotNull(password); Session session = sessionManager.getSession(); if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) { throw new LumifyException("User is not valid"); } Transaction transaction = null; try { transaction = session.beginTransaction(); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); ((SqlUser) user).setPassword(salt, passwordHash); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while setting password", e); } } }
SqlUserRepository extends UserRepository { @Override public void setPassword(User user, String password) { checkNotNull(password); Session session = sessionManager.getSession(); if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) { throw new LumifyException("User is not valid"); } Transaction transaction = null; try { transaction = session.beginTransaction(); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); ((SqlUser) user).setPassword(salt, passwordHash); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while setting password", e); } } @Inject  SqlUserRepository(final Configuration configuration,
                             final HibernateSessionManager sessionManager,
                             final AuthorizationRepository authorizationRepository,
                             final UserListenerUtil userListenerUtil,
                             final Graph graph); }
SqlUserRepository extends UserRepository { @Override public void setPassword(User user, String password) { checkNotNull(password); Session session = sessionManager.getSession(); if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) { throw new LumifyException("User is not valid"); } Transaction transaction = null; try { transaction = session.beginTransaction(); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); ((SqlUser) user).setPassword(salt, passwordHash); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while setting password", e); } } @Inject  SqlUserRepository(final Configuration configuration,
                             final HibernateSessionManager sessionManager,
                             final AuthorizationRepository authorizationRepository,
                             final UserListenerUtil userListenerUtil,
                             final Graph graph); @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); @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 userUser, String auth); @Override void removeAuthorization(User userUser, String auth); @Override org.securegraph.Authorizations getAuthorizations(User user, String... additionalAuthorizations); @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); }
SqlUserRepository extends UserRepository { @Override public void setPassword(User user, String password) { checkNotNull(password); Session session = sessionManager.getSession(); if (user == null || user.getUserId() == null || findById(user.getUserId()) == null) { throw new LumifyException("User is not valid"); } Transaction transaction = null; try { transaction = session.beginTransaction(); byte[] salt = UserPasswordUtil.getSalt(); byte[] passwordHash = UserPasswordUtil.hashPassword(password, salt); ((SqlUser) user).setPassword(salt, passwordHash); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while setting password", e); } } @Inject  SqlUserRepository(final Configuration configuration,
                             final HibernateSessionManager sessionManager,
                             final AuthorizationRepository authorizationRepository,
                             final UserListenerUtil userListenerUtil,
                             final Graph graph); @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); @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 userUser, String auth); @Override void removeAuthorization(User userUser, String auth); @Override org.securegraph.Authorizations getAuthorizations(User user, String... additionalAuthorizations); @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);  }