Package edu.asu.securebanking.model

Examples of edu.asu.securebanking.model.Pki


           fileName= fileName.substring(12,19);
          
       
        //Query the Database and get the blob
          
            Pki publicKey =  pkiBO.findPKI(fileName);
       
           
        //Verifying THe certificate using public key
          CertificateFactory cf = null;
          try {
            cf = CertificateFactory.getInstance("X.509");
          } catch (CertificateException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
          }
              X509Certificate cert = null;
          try {
            cert = (X509Certificate)cf.generateCertificate(multipartFile.getInputStream());
          } catch (CertificateException | IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
             
               try{
                     String algorithm = "RSA";
                     KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
                     EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKey.getCert().getBytes(1,(int) publicKey.getCert().length() ));
                     PublicKey regenerateThePublicKey = keyFactory.generatePublic(publicKeySpec);
                     cert.verify(regenerateThePublicKey)
                    
                     //get the merchant name
                       if(publicKey!=null)
                       {
                         String merchantName = publicKey.getMerchant();
                        
                         if(!merchantName.isEmpty())
                         {
                        // query the database get merchant record
                          
                          ExternalAccount merchant =  externalAccountBO.findAccountByName(merchantName);
                          
                           double currentBalance = merchant.getCurrentBalance();
                          
                           currentBalance = currentBalance + publicKey.getAmountInvolved();
                          
                           merchant.setCurrentBalance(currentBalance);
                              
                           externalAccountBO.update(merchant);
                          
                            modelAndView = new ModelAndView("MerchantFileUploadSuccess");
                          
                           modelAndView.addObject("message",currentBalance);
                          
                           pkiBO.delete(publicKey);
                          
                      
                          // 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(merchant.getUserid());
                             externalTransactionBO.save(external);

                         }
View Full Code Here


  static X509Certificate certificate;
 
  @RequestMapping(method = RequestMethod.GET)
  public String initForm(ModelMap model)
  {
    Pki pki = new Pki();
    model.addAttribute("pkisubmit",pki);
    return "pkiform";
  }
View Full Code Here

        } 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());
View Full Code Here

         fileName= fileName.substring(12,19);
        
     
      //Query the Database and get the blob
        
          Pki publicKey =  pkiBO.findPKI(fileName);
     
         
      //Verifying THe certificate using public key
        CertificateFactory cf = null;
        try {
          cf = CertificateFactory.getInstance("X.509");
        } catch (CertificateException e2) {
          // TODO Auto-generated catch block
          e2.printStackTrace();
        }
            X509Certificate cert = null;
        try {
          cert = (X509Certificate)cf.generateCertificate(multipartFile.getInputStream());
        } catch (CertificateException | IOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
           
             try{
                   String algorithm = "RSA";
                   KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
                   EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKey.getCert().getBytes(1,(int) publicKey.getCert().length() ));
                   PublicKey regenerateThePublicKey = keyFactory.generatePublic(publicKeySpec);
                   cert.verify(regenerateThePublicKey)
                  
                   //get the merchant name
                     if(publicKey!=null)
                     {
                       String userName = publicKey.getUserName();
                      
                       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

      } 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());
View Full Code Here

TOP

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

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.