public boolean checkPassword(String password) { if (passwordHash == null) { throw new IllegalStateException("User password is not set"); } if (password == null) { throw new IllegalArgumentException("Null password passed to User.checkPassword"); } String hash = Util.hash(password); return hash.equals(passwordHash); }
public void generateActivationKey() { try { SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); byte data[] = new byte[8]; random.nextBytes(data); activationKey = Util.hex(data); } catch (NoSuchAlgorithmException ex) { LOG.error("Error generating activation key", ex); throw new RuntimeException(ex.getMessage()); } }
public void setPassword(String newValue) { passwordHash = Util.hash(newValue); }