Package edu.asu.securebanking.model

Examples of edu.asu.securebanking.model.ExternalAccount


    int userid=0;
    int empid=0;
    InternalAccount ia = null;
    String name = principal.getName();
   
    ExternalAccount ea = loginAttemptBO.findAccountByNameExternal(name);
    if(ea == null){
      ia = loginAttemptBO.findAccountByNameInternal(name);
      if(ia != null){
        userid = 0;
        empid = ia.getEmployeeId();
       
      }
    }else{
      //external use case
      userid = ea.getUserid();
      empid = 0;   
    }
    OTP indatabase = otpBO.findAccountByName(userid,empid);
   
    //suppose user provided valid one-time-password
     
        java.util.Date current_date = new java.util.Date();
        java.sql.Timestamp current_timestamp = new java.sql.Timestamp(current_date.getTime());
        long current_time = current_timestamp.getTime();
        long db_time = indatabase.gettime().getTime();
        long time_diff = current_time - db_time; //5 minutes = 5 * 60 * 1000 (ms) =300,000
        // Need to be modified!!!
        if(oneTimePassword.equals(indatabase.getotp()) && time_diff < 300000){
          System.out.println("Ok!!!");
         
          // delete the one time login entry
          otpBO.delete(indatabase);
          //set first time login to false
          if(ea != null)
          {
            ea.setFirstTimeLogin(false);
            externalAccountBO.update(ea);
          }
          if(ia != null)
          {
            ia.setFirstTimeLogin(false);
View Full Code Here


     
    }
    else if(userType == "EXTERNAL")
    {
      //external use case
      ExternalAccount ea = loginAttemptBO.findAccountByNameExternal(forgot_user.getUsername());
      if(ea != null)
      {
        try{
          MessageDigest digest = MessageDigest.getInstance("SHA-256");
          byte[] hash = digest.digest(otp_pwd.getBytes("UTF-8"));
          StringBuffer hexString = new StringBuffer();

          for (int i = 0; i < hash.length; i++) {
            String hex = Integer.toHexString(0xff & hash[i]);
            if(hex.length() == 1) hexString.append('0');
            hexString.append(hex);
          }
          this.sendPwdRecoveryEmail(ea.getEmail(), ea.getUsername(), otp_pwd);
          ea.setPassword(hexString.toString());
          //ea.setPassword(otp_pwd);
          createExternalAccountBO.update(ea);
        } catch(Exception ex){
          throw new RuntimeException(ex);
        }
View Full Code Here

  @RequestMapping(value="/credit")

  public synchronized ModelAndView creditMoney(Principal principal) {

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

    ExternalUserTransaction credit = new ExternalUserTransaction();

    credit.setUserId(currentuser.getUserid());

    credit.setAccessGranted(1);

    credit.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();

      currentBalance += amount;

    }

    externalAccount.setCurrentBalance(currentBalance);

    externalAccountBO.update(externalAccount);

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

 
  public synchronized ModelAndView IndividualUserCreditSuccess(Principal principal) {
   
    ModelAndView modelAndView = new ModelAndView("IndividualUserCreditSuccess");
   
    ExternalAccount externalAccount =  externalAccountBO.findAccountByName(principal.getName());

    modelAndView.addObject("message", externalAccount.getCurrentBalance());

    return modelAndView;
  }
View Full Code Here

  @RequestMapping(value="/transfer")

  public synchronized ModelAndView transferMoney(Principal principal) {

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

    ExternalUserTransaction transfer = new ExternalUserTransaction();

    transfer.setUserId(currentuser.getUserid());

    transfer.setAccessGranted(1);

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

 
  @RequestMapping(value="/transferToMerchant")
  public synchronized ModelAndView transferToMerchant(Principal principal) {

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

    transfer.setUserId(currentuser.getUserid());

    transfer.setAccessGranted(1);

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

    double currentSourceBalance = 0.0;

    int userId = externalUserTransaction.getUserId();

    ExternalAccount sourceExternalAccount = externalAccountBO.findUserByid(userId);

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

    if(currentSourceBalance<amountToTransfer)
    {
      return "redirect:/IndividualUser/IndividualUserLessFunds";
    }

    //else process the transaction.
    else
    {

      // Find the account from database where money needs to be transfered.
     
      ExternalAccount destinationExternalAccount = individualUserBO.getAccountByUsername(merchantUserName);

      if(destinationExternalAccount == null)
      {
        return "redirect:/IndividualUser/MerchantUserNameIncorrect";

      }
      else if(sourceExternalAccount.getUsername().equals(destinationExternalAccount.getUsername()))
      {
        return "redirect:/IndividualUser/MerchantUserNameIncorrect";
      }

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

      externalAccountBO.update(sourceExternalAccount);

      // Create Transaction For Source Account

      externalUserTransaction.setTransDetail("Transfer To Merchant " + merchantUserName);

      externalUserTransaction.setAmountInvolved(amountToTransfer*-1);

      externalTransactionBO.save(externalUserTransaction);


      //Create Transaction for Destination Balance    

/*      externalUserTransaction.setUserId(destinationExternalAccount.getUserid());

      externalUserTransaction.setTransType("debitFromUser");
      externalUserTransaction.setTransDetail("Transfer From Individual " + sourceExternalAccount.getUsername());

      externalUserTransaction.setAmountInvolved(amountToTransfer);

      externalTransactionBO.save(externalUserTransaction);*/
     
      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(merchantUserName);
      pki.setAmountInvolved(amountToTransfer);
      pki.setTransDetail("Transfer From Individual " + sourceExternalAccount.getUsername());
        //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(merchantUserName,principal.getName(),"Transfer From Individual " + sourceExternalAccount.getUsername(),Long.toString(randomNumber),amountToTransfer,destinationExternalAccount.getEmail());

    
      return "redirect:/IndividualUser/MerchantUserTransferSuccess";

    }
View Full Code Here

      double currentSourceBalance = 0.0;

      int userId = externalUserTransaction.getUserId();

      ExternalAccount sourceExternalAccount = externalAccountBO.findUserByid(userId);

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

      if(currentSourceBalance<amountToTransfer)
      {
        return "redirect:/IndividualUser/IndividualUserCreditSuccess";
      }

      //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;";
          model.addAttribute("transfer", externalUserTransaction);

          model.addAttribute("errors", errors);

          return "IndividualUserTransfer";

        }

        // 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

 
  public synchronized ModelAndView IndividualUserTransferSuccess(Principal principal) {
   
    ModelAndView modelAndView = new ModelAndView("IndividualUserTransferSuccess");
   
    ExternalAccount externalAccount =  externalAccountBO.findAccountByName(principal.getName());

    modelAndView.addObject("message", externalAccount.getCurrentBalance());

    return modelAndView;
  }
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.