public String performBill() { sender.setCheckingaccount(sender.getCheckingaccount() - amount); recipient.setCheckingaccount(recipient.getCheckingaccount() + amount); em.merge(sender); em.merge(recipient); return sender.getCheckingaccount().toString(); }
@Override public List<String> getBeneficiary() { List<String> res = new LinkedList(); res.add(recipient.getUsername()); res.add(recipient.getFirstname()); res.add(recipient.getSecondname()); return res; }
public static Boolean Login(String userName, String password) { if (StringHelper.IsNullOrWhitespace(userName) || StringHelper.IsNullOrWhitespace(password)) return false; userName = userName.toLowerCase(); String passwordHash = DigestUtils.md5Hex(password); UserEntity user = UserEntityHelper.GetUserByUserName(userName); if (user == null) return false; if (!user.getPassword().equals(passwordHash)) return false; if (user.getIsEnabled() == false) return false; SessionManager.getInstance().createSession(user); return true; }
public void checkRecipient() throws InvalidCustomerAccountException { try { em.createNamedQuery("UserEntity.findByUsername") .setParameter("username", recipient.getUsername()) .getSingleResult(); } catch (NoResultException nre) { System.out.println("No recipient found"); throw new InvalidCustomerAccountException("Error: the recipient does not exist anymore."); } }
@Override public boolean setAmount(Long amount, String username) { sender = (UserEntity) em.createNamedQuery("UserEntity.findByUsername") .setParameter("username", username) .getSingleResult(); if (amount > sender.getCheckingaccount()) { System.out.println("You don't have enough money"); return false; } else { this.amount = amount; return true; } }
public void checkBillDetails() throws IncorrectBillDetailsException { Long sendAmount = sender.getCheckingaccount(); if ((sendAmount - amount) < 0) throw new IncorrectBillDetailsException( "Error: Bill details not correct. Check the amount of the transaction"); }
public void checkCredentials(String user, String pwd) throws InvalidCustomerAccountException { if (!(sender.getUsername().equals(user) && sender.getPassword().equals(pwd))) { throw new InvalidCustomerAccountException("Error: Username or password not correct"); } }