@Test public void entryptPassword() { User user = UserData.randomNewUser(); userService.entryptPassword(user, "admin"); System.out.println(user.getLoginName()); System.out.println("salt: " + user.getSalt()); System.out.println("entrypt password: " + user.getPassword()); }
void entryptPassword(User user, String plainPassword) { byte[] salt = Digests.generateSalt(SALT_SIZE); user.setSalt(Encodes.encodeHex(salt)); byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); user.setPassword(Encodes.encodeHex(hashPassword)); }
UserService extends BaseService { void entryptPassword(User user, String plainPassword) { byte[] salt = Digests.generateSalt(SALT_SIZE); user.setSalt(Encodes.encodeHex(salt)); byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); user.setPassword(Encodes.encodeHex(hashPassword)); } }
UserService extends BaseService { void entryptPassword(User user, String plainPassword) { byte[] salt = Digests.generateSalt(SALT_SIZE); user.setSalt(Encodes.encodeHex(salt)); byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); user.setPassword(Encodes.encodeHex(hashPassword)); }  }
UserService extends BaseService { void entryptPassword(User user, String plainPassword) { byte[] salt = Digests.generateSalt(SALT_SIZE); user.setSalt(Encodes.encodeHex(salt)); byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); user.setPassword(Encodes.encodeHex(hashPassword)); }  User getUser(Long id); User findUserByLoginName(String loginName); User findUserByEmail(String email); @Transactional(readOnly = false) void registerUser(User user, String plainPassword); @Transactional(readOnly = false) void createUser(User user, String plainPassword); @Transactional(readOnly = false) void updateUser(User user, String plainPassword); @Transactional(readOnly = false) void updatePassword(User user, String plainPassword); @Transactional(readOnly = false) void deleteUser(Long id); @Transactional(readOnly = false) void activeUser(Long id); @Transactional(readOnly = false) void deactiveUser(Long id); Page<User> getUsers(Map<String, Object> searchParams, int pageNumber, int pageSize, String sortType); @Transactional(readOnly = false) void activeUser(String key); void sendResetPwdEmail(User user); @Transactional(readOnly = false) void resetPassword(String key); }
UserService extends BaseService { void entryptPassword(User user, String plainPassword) { byte[] salt = Digests.generateSalt(SALT_SIZE); user.setSalt(Encodes.encodeHex(salt)); byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); user.setPassword(Encodes.encodeHex(hashPassword)); }  User getUser(Long id); User findUserByLoginName(String loginName); User findUserByEmail(String email); @Transactional(readOnly = false) void registerUser(User user, String plainPassword); @Transactional(readOnly = false) void createUser(User user, String plainPassword); @Transactional(readOnly = false) void updateUser(User user, String plainPassword); @Transactional(readOnly = false) void updatePassword(User user, String plainPassword); @Transactional(readOnly = false) void deleteUser(Long id); @Transactional(readOnly = false) void activeUser(Long id); @Transactional(readOnly = false) void deactiveUser(Long id); Page<User> getUsers(Map<String, Object> searchParams, int pageNumber, int pageSize, String sortType); @Transactional(readOnly = false) void activeUser(String key); void sendResetPwdEmail(User user); @Transactional(readOnly = false) void resetPassword(String key); static final String HASH_ALGORITHM; static final int HASH_INTERATIONS; }