Example #1
0
 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);
 }
Example #2
0
 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());
   }
 }
Example #3
0
 public void setPassword(String newValue) {
   passwordHash = Util.hash(newValue);
 }