Package edu.asu.securebanking.businessobject

Examples of edu.asu.securebanking.businessobject.OTPBO


    String name = principal.getName();

    ApplicationContext appContext = new ClassPathXmlApplicationContext("spring/config/BeanLocations.xml");
    LoginAttemptBO loginAttemptBO = (LoginAttemptBO)appContext.getBean("loginAttemptBO");
    OTPBO otpBO = (OTPBO)appContext.getBean("OTPBO");

   


    int userid = 0;
    int empid = 0;
    String email = null;
    String username = name;
    boolean ftl = false;
    InternalAccount ia=null;
    ExternalAccount ea = loginAttemptBO.findAccountByNameExternal(name);
    if(ea == null){
      ia = loginAttemptBO.findAccountByNameInternal(name);
      if(ia != null){
        userid = 0;
        empid = ia.getEmployeeId();
        email = ia.getEmail();
        ftl = ia.getFirstTimeLogin();
      }
    }else{
      //external use case
      userid = ea.getUserid();
      empid = 0;
      email = ea.getEmail();
      ftl = ea.isFirstTimeLogin();
    }
    if(ftl == true){
      // First Time Login
      //store OTP data to otp DB
      OTP instance = new OTP();
      instance.setuserid(userid);
      instance.setempid(empid);
      String otp_pwd = generateOTP();
      instance.setotp(otp_pwd);
      java.util.Date date = new java.util.Date();
      java.sql.Timestamp param = new java.sql.Timestamp(date.getTime());
      instance.settime(param);
      //automatically check if we have matching userid & empid (logic is in OTPDaoImpl.java)
      otpBO.save(instance);
     
      this.sendEmail(email, username, instance.getotp());
     
       return "OPTCreationSucess";
            
View Full Code Here


    String oneTimePassword = otp.getotp();
 
    // Get the object from the OTP table
    ApplicationContext appContext = new ClassPathXmlApplicationContext("spring/config/BeanLocations.xml");
    LoginAttemptBO loginAttemptBO = (LoginAttemptBO)appContext.getBean("loginAttemptBO");
    OTPBO otpBO = (OTPBO)appContext.getBean("OTPBO");
   
    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);
View Full Code Here

TOP

Related Classes of edu.asu.securebanking.businessobject.OTPBO

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.