Exemple #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;
 }
Exemple #2
0
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 public boolean changePassword(Customer customer, String password)
     throws NoProperPasswordException {
   boolean change = false;
   customer.setPassword(password);
   checkPassword(password);
   change = customerJpaDao.updateCustomer(customer);
   return change;
 }
Exemple #3
0
 public Customer retrieveCustomer(String tckn) {
   return customerJpaDao.retrieveCustomer(tckn);
 }
Exemple #4
0
 @Interceptors(PerformanceInterceptor.class)
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 public boolean createCustomer(Customer customer) throws CustomerAlreadyExistsException {
   return customerJpaDao.createCustomer(customer);
 }
Exemple #5
0
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 public boolean logout(Customer customer) {
   customer.setLoggedIn(false);
   customerJpaDao.updateCustomer(customer);
   return true;
 }
Exemple #6
0
 public Customer refreshCustomer(Customer customer) {
   return customerJpaDao.refreshCustomer(customer);
 }