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; }
@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; }
public Customer retrieveCustomer(String tckn) { return customerJpaDao.retrieveCustomer(tckn); }
@Interceptors(PerformanceInterceptor.class) @TransactionAttribute(TransactionAttributeType.REQUIRED) public boolean createCustomer(Customer customer) throws CustomerAlreadyExistsException { return customerJpaDao.createCustomer(customer); }
@TransactionAttribute(TransactionAttributeType.REQUIRED) public boolean logout(Customer customer) { customer.setLoggedIn(false); customerJpaDao.updateCustomer(customer); return true; }
public Customer refreshCustomer(Customer customer) { return customerJpaDao.refreshCustomer(customer); }