예제 #1
0
 private void validateListIsFree(OneTimePasswordList passwordList)
     throws OneTimePasswordListNotFreeException {
   if (!passwordList.isFree()) {
     throw new OneTimePasswordListNotFreeException(
         "Otp list with id " + passwordList.getId() + " is no longer free.");
   }
 }
예제 #2
0
 /**
  * Associates an otp list with a user.
  *
  * @return associated otp list
  */
 @Override
 public OneTimePasswordList associateOtpListWithUser(OneTimePasswordList passwordList, User user)
     throws OneTimePasswordListNotFreeException {
   validateListIsFree(passwordList);
   passwordList.setUser(user);
   passwordList.setStatus(statusDao.getByValue("associated"));
   passwordListDao.update(passwordList);
   return passwordList;
 }
예제 #3
0
 /**
  * Generates a list of one time passwords.
  *
  * @return list of one time passwords
  */
 @Override
 public OneTimePasswordList generatePasswordList(Date expiryDate) {
   OneTimePasswordList passwordList = new OneTimePasswordList();
   passwordList.setPasswords(generatePasswords());
   passwordList.setStatus(statusDao.getByValue("free"));
   passwordList.setSize(LIST_SIZE);
   passwordList.setExpires(expiryDate);
   passwordListDao.save(passwordList);
   return passwordList;
 }