Esempio n. 1
0
 public String performBill() {
   sender.setCheckingaccount(sender.getCheckingaccount() - amount);
   recipient.setCheckingaccount(recipient.getCheckingaccount() + amount);
   em.merge(sender);
   em.merge(recipient);
   return sender.getCheckingaccount().toString();
 }
Esempio n. 2
0
 @Override
 public List<String> getBeneficiary() {
   List<String> res = new LinkedList();
   res.add(recipient.getUsername());
   res.add(recipient.getFirstname());
   res.add(recipient.getSecondname());
   return res;
 }
Esempio n. 3
0
  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;
  }
Esempio n. 4
0
 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.");
   }
 }
Esempio n. 5
0
 @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;
   }
 }
Esempio n. 6
0
 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");
 }
Esempio n. 7
0
 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");
   }
 }