Package edu.asu.securebanking.model

Examples of edu.asu.securebanking.model.ExternalAccount


      modelAndView.addObject("extpiireqs", extpiireqs);
   
   
    for(int i=0; i<extpiireqs.size(); i++)
    {
      ExternalAccount temp = (ExternalAccount) extpiireqs.get(i);
      System.out.println("User SSN: "+ temp.getSsn());
     
      String passphrase = "HelloEncyption";
      MessageDigest digest = MessageDigest.getInstance("SHA");
      digest.update(passphrase.getBytes());
      SecretKeySpec key = new SecretKeySpec(digest.digest(), 0, 16, "AES");
     
      byte[] ciphertext = Base64.decodeBase64(temp.getSsn().getBytes());   
      String cleartext = decrypt(ciphertext, key);     
      System.out.println("\nAfter Decryption: "+cleartext);
     
      temp.setSsn(cleartext);
     
    }
    }
   
    List<PiiAuth> piiAuths = piiAuthBo.getallPiiAuth();
    System.out.println("size of piiAuth list is: "+piiAuths.size());
    modelAndView.addObject("piiAuths", piiAuths);
   
    ExternalAccount user = new ExternalAccount();
    modelAndView.addObject("user", user);
   
    return modelAndView;
  }
View Full Code Here


 
  @RequestMapping(value="/finduser", method = RequestMethod.POST)
  public synchronized ModelAndView finduserbyid(@ModelAttribute("user") ExternalAccount user,
      BindingResult result) throws InternalException {
    ModelAndView modelAndView = new ModelAndView("findExternalUser");
    ExternalAccount userbyid = extBo.findUserByid(user.getUserid());
    if(userbyid == null){
      ModelAndView modelAndView1 = new ModelAndView("genericsuccess");
      modelAndView1.addObject("message", "User ID not found!");
      return modelAndView1;
    }
    System.out.println(userbyid.getUsername());
    modelAndView.addObject("userbyid", userbyid);
    return modelAndView;
  }
View Full Code Here

          double currentBalance = 0.0;

          int userId = externalUserTransaction.getUserId();

          ExternalAccount externalAccount = externalAccountBO.findUserByid(userId);

          if(externalAccount != null)
          {
            currentBalance = externalAccount.getCurrentBalance();
          } else{
            errors = errors + "User ID not found;";
            ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
            modelAndView.addObject("exttrans", externalUserTransaction);
            modelAndView.addObject("currentuser", currentuser);
            modelAndView.addObject("errors", errors);

            return modelAndView;
          }
          // Check the current Balance  if not return error

          if(currentBalance<amount)
          {
            errors = errors + "No sufficient balance;";
            ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
            modelAndView.addObject("exttrans", externalUserTransaction);
            modelAndView.addObject("currentuser", currentuser);
            modelAndView.addObject("errors", errors);

            return modelAndView;
          }

          //else process the transaction.
          else
          {
            //Update the current Balance
            amount=amount*-1;

            currentBalance =  currentBalance + amount;

            externalAccount.setCurrentBalance(currentBalance);

            externalAccountBO.update(externalAccount);

            // Create New Transaction
            externalUserTransaction.setAmountInvolved(amount);

            externalTransactionBO.save(externalUserTransaction);

            ModelAndView modelAndView = new ModelAndView("genericsuccess");

            String message = "Transaction created successfully!";
            modelAndView.addObject("message", message);

            return modelAndView;
          }
        }
        else if(externalUserTransaction.getTransType().matches("Credit")){

          double amount = externalUserTransaction.getAmountInvolved();

          double currentBalance = 0.0;

          int userId = externalUserTransaction.getUserId();

          ExternalAccount externalAccount = externalAccountBO.findUserByid(userId);

          if(externalAccount != null)
          {
            currentBalance = externalAccount.getCurrentBalance();

            currentBalance += amount;

          }else{
            errors = errors + "User ID not found;";
            ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
            modelAndView.addObject("exttrans", externalUserTransaction);
            modelAndView.addObject("currentuser", currentuser);
            modelAndView.addObject("errors", errors);

            return modelAndView;
          }

          externalAccount.setCurrentBalance(currentBalance);

          externalAccountBO.update(externalAccount);

          // Create New Transaction
          externalUserTransaction.setAmountInvolved(amount);

          externalTransactionBO.save(externalUserTransaction);

          ModelAndView modelAndView = new ModelAndView("genericsuccess");

          String message = "Transaction created successfully!";
          modelAndView.addObject("message", message);

          return modelAndView;

        }
        else {
          double amountToTransfer = externalUserTransaction.getAmountInvolved();

          double currentSourceBalance = 0.0;

          int userId = externalUserTransaction.getUserId();

          ExternalAccount sourceExternalAccount = externalAccountBO.findUserByid(userId);

          if(sourceExternalAccount != null)
          {
            currentSourceBalance = sourceExternalAccount.getCurrentBalance();
          }else{
            errors = errors + "User ID not found;";
            ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
            modelAndView.addObject("exttrans", externalUserTransaction);
            modelAndView.addObject("currentuser", currentuser);
            modelAndView.addObject("errors", errors);

            return modelAndView;
          }
          // Check the current Balance  if not return error

          if(currentSourceBalance<amountToTransfer)
          {
            errors = errors + "No sufficient balance;";
            ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
            modelAndView.addObject("exttrans", externalUserTransaction);
            modelAndView.addObject("currentuser", currentuser);
            modelAndView.addObject("errors", errors);

            return modelAndView;
          }

          //else process the transaction.
          else
          {

            // Find the account from database where money needs to be transfered.

            String accountNumber = externalUserTransaction.getTransDetail();


            ExternalAccount destinationExternalAccount = individualUserBO.getAccountByAccountNumber(accountNumber);

            if(destinationExternalAccount == null ||(sourceExternalAccount.getAccountNo().equals(destinationExternalAccount.getAccountNo())))
            {
              errors = errors + "Please enter valid Account Number;";
              ModelAndView modelAndView = new ModelAndView("ExternalUserTransactionCreation");
              modelAndView.addObject("exttrans", externalUserTransaction);
              modelAndView.addObject("currentuser", currentuser);
              modelAndView.addObject("errors", errors);

              return modelAndView;

            }

            // Update Source Account Balance
            sourceExternalAccount.setCurrentBalance(currentSourceBalance-amountToTransfer);

            externalAccountBO.update(sourceExternalAccount);

            // Create Transaction For Source Account

            externalUserTransaction.setTransDetail("Transfer To A/C" + accountNumber);

            externalUserTransaction.setAmountInvolved(amountToTransfer*-1);

            externalTransactionBO.save(externalUserTransaction);

            //   Update Destination Account Balance

            double destinationBalance = destinationExternalAccount.getCurrentBalance();

            destinationBalance+=amountToTransfer;

            destinationExternalAccount.setCurrentBalance(destinationBalance);

            externalAccountBO.update(destinationExternalAccount);

            //Create Transaction for Destination Balance    

            externalUserTransaction.setUserId(destinationExternalAccount.getUserid());

            externalUserTransaction.setTransDetail("Transfer From A/C" + sourceExternalAccount.getAccountNo());

            externalUserTransaction.setAmountInvolved(amountToTransfer);

View Full Code Here

  }

  @Override
  public ExternalAccount findAccountByNameExternal(String username) {
    // TODO Auto-generated method stub
    ExternalAccount ea = LoginAttemptDao.findAccountByNameExternal(username);
    if(ea != null){
      return ea;
    }
    return null;
  }
View Full Code Here

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "telephone", "required.telephone", "Field name is required.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gender", "required.gender", "Field name is required.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "securityquestion", "required.securityquestion", "Field name is required.");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "securityanswer", "required.securityanswer","Field name is required.");
   
    ExternalAccount user = (ExternalAccount)target;
    Boolean result;
   
    result = StringValidator.inputvalidation(user.getUsername(), "username");
    if(!result){
      errors.rejectValue("username","regex.username");
    }
   
    result = StringValidator.inputvalidation(user.getPassword(), "password");
    if(!result){
      errors.rejectValue("password","regex.password");
    }
   
    result = StringValidator.inputvalidation(user.getFirstname(), "general");
    if(!result){
      errors.rejectValue("firstname","regex.general");
    }
   
    result = StringValidator.inputvalidation(user.getLastname(), "general");
    if(!result){
      errors.rejectValue("lastname","regex.general");
    }
   
    result = StringValidator.inputvalidation(user.getDob(), "date");
    if(!result){
      errors.rejectValue("dob","regex.date");
    }
   
    result = StringValidator.inputvalidation(user.getSecurityanswer(), "general");
    if(!result){
      errors.rejectValue("securityanswer","regex.general");
    }
   
    result = StringValidator.inputvalidation(user.getAddress(), "address");
    if(!result){
      errors.rejectValue("address","regex.address");
    }
   
    result = StringValidator.inputvalidation(user.getSsn(), "number");
    if(!result){
      errors.rejectValue("ssn","regex.number");
    }
   
    result = StringValidator.inputvalidation(user.getTelephone(), "number");
    if(!result){
      errors.rejectValue("telephone","regex.number");
    }
   
    result = StringValidator.inputvalidation(user.getEmail(), "email");
    if(!result){
      errors.rejectValue("email","regex.email");
    }
   
    if(!(user.getPassword().equals(user.getVpassword()))){
      errors.rejectValue("password", "notmatch.password");
    }

    if("NONE".equals(user.getSecurityquestion())){
      errors.rejectValue("securityquestion", "required.securityquestion");
    }
  }
View Full Code Here

  public synchronized ModelAndView listOflTransactions(Principal principal) {

    ModelAndView modelAndView = new ModelAndView("IndividualUserTransactions");

    String name = principal.getName();
    ExternalAccount currentuser = extBo.findAccountByName(name);

    List<ExternalUserTransaction> transactions = individualUserBO.getAllUserTransactions(currentuser.getUserid());

    modelAndView.addObject("transactions", transactions);

    return modelAndView;
  }
View Full Code Here

    System.out.println("step0");
    String name = principal.getName();
    System.out.println(name);
    ModelAndView modelAndView = new ModelAndView("InternalUserAccountManagementHomePage");
    System.out.println("step1");
    ExternalAccount currentuser = extBo.findAccountByName(name);
    System.out.println(name);

    modelAndView.addObject("accountbyname", currentuser);

    return modelAndView;
View Full Code Here

  @RequestMapping(value="/debit")

  public synchronized ModelAndView debitMoney(Principal principal) {

    String name = principal.getName();
    ExternalAccount currentuser = extBo.findAccountByName(name);

    ExternalUserTransaction debit = new ExternalUserTransaction();

    debit.setUserId(currentuser.getUserid());

    debit.setAccessGranted(1);

    debit.setStatus("Pending");
View Full Code Here

    double currentBalance = 0.0;

    int userId = externalUserTransaction.getUserId();

    ExternalAccount externalAccount = externalAccountBO.findUserByid(userId);

    if(externalAccount != null)
    {
      currentBalance = externalAccount.getCurrentBalance();
    }
    // Check the current Balance  if not return error

    if(currentBalance<amount)
    {
 
      errors = errors + "No sufficient balance;";

      model.addAttribute("debit", externalUserTransaction);

      model.addAttribute("errors", errors);

      return "IndividualUserDebit";

      //return modelAndView;
    }

    //else process the transaction.
    else
    {
      //Update the current Balance
     
     
      amount=amount*-1;
     
      if((amount*-1)>1000)
      {
       
       
        long randomNumber = (long) Math.floor(Math.random() * 9000000) + 1000000L;
       
        // GENERATE CERTIFICATE FOR THE TRANSACTION
        KeyPair keyPair = null;
        try {
          keyPair = generateCertificate(principal.getName(),randomNumber);
        } catch (Exception e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        
        Pki pki = new Pki();
        pki.setUserName(principal.getName());
        pki.setTransId(Long.toString(randomNumber));
        pki.setMerchant("");
        pki.setAmountInvolved(amount);
        pki.setTransDetail("Transfer From Individual " + principal.getName());
          //get a blob out of the keypair
          Blob blob = pkiBO.createKeyBlob(keyPair);
         
        //UPDATING THE ENTRY IN DATABASE
          pki.setCert(blob);
          pkiBO.save(pki);
         
          //EMAILING THE MERCHANT
          sendMail(principal.getName()," ","Transfer From Individual " ,Long.toString(randomNumber),amount,externalAccount.getEmail());

        return "redirect:/IndividualUser/FileUpload";
       
      }

      currentBalance =  currentBalance + amount;

      externalAccount.setCurrentBalance(currentBalance);

      externalAccountBO.update(externalAccount);

      // Create New Transaction
      externalUserTransaction.setAmountInvolved(amount);
View Full Code Here

                      
                       if(!userName.isEmpty())
                       {
                      // query the database get merchant record
                        
                        ExternalAccount user =  externalAccountBO.findAccountByName(userName);
                        
                         double currentBalance = user.getCurrentBalance();
                        
                         currentBalance = currentBalance + publicKey.getAmountInvolved();
                        
                         user.setCurrentBalance(currentBalance);
                            
                         externalAccountBO.update(user);
                        
                          modelAndView = new ModelAndView("IndividualFileUploadSuccess");
                        
                         modelAndView.addObject("message",currentBalance);
                        
                         // Create an External Transaction
                        
                         ExternalUserTransaction external = new ExternalUserTransaction();
                        
                         external.setAccessGranted(1);
                         external.setAmountInvolved(publicKey.getAmountInvolved());
                         external.setStatus("Approved");
                         external.setTransDetail(publicKey.getTransDetail());
                         external.setTransType("Debit");
                         external.setUserId(user.getUserid());
                         externalTransactionBO.save(external);
                         pkiBO.delete(publicKey);
                        
                    
View Full Code Here

TOP

Related Classes of edu.asu.securebanking.model.ExternalAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.