Пример #1
0
 public Customer login(String tckn, String password)
     throws CustomerLockedException, CustomerAlreadyLoggedException,
         WrongCustomerCredentialsException, MaxNumberOfFailedLoggingAttemptExceededException {
   boolean login = false;
   Customer customer = customerJpaDao.retrieveCustomer(tckn);
   if (customer.getPassword().equals(password) & !customer.isLocked() & !customer.isLoggedIn()) {
     /*if (ATMProperties.getProperty("customer.logsin").equals("yes")) {
         customer.setLoggedIn(true);
         if (customerJpaDao.updateCustomer(customer)) {
             login = true;
         }
     }
     else {
         login = true;
     }*/
     loginAttemptCount = 0;
   } else if (customer.isLoggedIn()) {
     throw new CustomerAlreadyLoggedException(
         "Customer is already logged in. Please first log out.");
   } else if (customer.isLocked()) {
     throw new CustomerLockedException("Customer is locked. Please consult your admin.");
   } else if (!customer.getPassword().equals(password)) {
     loginAttemptCount++;
     if (loginAttemptCount
         == Integer.parseInt(ATMProperties.getProperty("customer.maxFailedLoginAttempt"))) {
       customer.setLocked(true);
       customerJpaDao.updateCustomer(customer);
       throw new MaxNumberOfFailedLoggingAttemptExceededException(
           "Max number of login attempt reached: " + loginAttemptCount);
     }
     throw new WrongCustomerCredentialsException("TCKN/password is wrong.");
   }
   return customer;
 }
Пример #2
0
 public Customer retrieveCustomer(String tckn) {
   return customerJpaDao.retrieveCustomer(tckn);
 }