protected int checkLastLogin(){
  DateFormat formatter=new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
  Date now=newDate();
  Date loginTime=null;
  String lastLoginEnc=null;
  String lastLogin=null;
  String savedUserName=null;
  int retVal=0;
  if (timeSinceLastLoginAttribute != null) {
    HttpServletRequest req=getHttpServletRequest();
    if (req != null) {
      Cookie cookie=CookieUtils.getCookieFromReq(req,timeSinceLastLoginAttribute);
      if (cookie != null) {
        if (debug.messageEnabled()) {
          debug.message("{}.checkLastLogin: Found Cookie : {}",ADAPTIVE,timeSinceLastLoginAttribute);
        }
        lastLoginEnc=CookieUtils.getCookieValue(cookie);
        lastLogin=AccessController.doPrivileged(new DecodeAction(lastLoginEnc));
      }
      if (lastLogin != null) {
        String[] tokens=lastLogin.split("\\|");
        if (tokens.length == 3) {
          lastLogin=tokens[1];
          savedUserName=tokens[2];
        }
        if (!userName.equalsIgnoreCase(savedUserName)) {
          lastLogin=null;
        }
        if (lastLogin != null) {
          try {
            loginTime=formatter.parse(lastLogin);
            if ((now.getTime() - loginTime.getTime()) < timeSinceLastLoginValue * 1000 * 60* 60* 24L) {
              retVal=timeSinceLastLoginScore;
            }
          }
 catch (          ParseException pe) {
            if (debug.messageEnabled()) {
              debug.message("{}.checkLastLogin: lastLogin '{}' can't be parsed",ADAPTIVE,lastLogin,pe);
            }
          }
        }
      }
    }
    if (timeSinceLastLoginSave) {
      postAuthNMap.put("LOGINNAME",timeSinceLastLoginAttribute);
      lastLogin=formatter.format(now);
      lastLogin=UUID.randomUUID() + "|" + lastLogin+ "|"+ userName;
      lastLoginEnc=AccessController.doPrivileged(new EncodeAction(lastLogin));
      postAuthNMap.put("LOGINVALUE",lastLoginEnc);
    }
  }
  if (!timeSinceLastLoginInvert) {
    retVal=timeSinceLastLoginScore - retVal;
  }
  return retVal;
}

protected int checkLastLogin ( ) { DateFormat formatter = new SimpleDateFormat ( "yyyy.MM.dd.HH.mm.ss" ) ; Date now = newDate ( ) ; Date loginTime = null ; String lastLoginEnc = null ; String lastLogin = null ; String savedUserName = null ; int retVal = 0 ; if ( timeSinceLastLoginAttribute != null ) { HttpServletRequest req = getHttpServletRequest ( ) ; if ( req != null ) { Cookie cookie = CookieUtils . getCookieFromReq ( req , timeSinceLastLoginAttribute ) ; if ( cookie != null ) { if ( debug . messageEnabled ( ) ) { debug . message ( "{}.checkLastLogin: Found Cookie : {}" , ADAPTIVE , timeSinceLastLoginAttribute ) ; } lastLoginEnc = CookieUtils . getCookieValue ( cookie ) ; lastLogin = AccessController . doPrivileged ( new DecodeAction ( lastLoginEnc ) ) ; } if ( lastLogin != null ) { String [ ] tokens = lastLogin . split ( "\\|" ) ; if ( tokens . length == 3 ) { lastLogin = tokens [ 1 ] ; savedUserName = tokens [ 2 ] ; } if ( ! userName . equalsIgnoreCase ( savedUserName ) ) { lastLogin = null ; } if ( lastLogin != null ) { try { loginTime = formatter . parse ( lastLogin ) ; if ( ( now . getTime ( ) - loginTime . getTime ( ) ) < timeSinceLastLoginValue * 1000 * 60 * 60 * 24L ) { retVal = timeSinceLastLoginScore ; } } catch ( ParseException pe ) { if ( debug . messageEnabled ( ) ) { debug . message ( "{}.checkLastLogin: lastLogin '{}' can't be parsed" , ADAPTIVE , lastLogin , pe ) ; } } } } } if ( timeSinceLastLoginSave ) { postAuthNMap . put ( "LOGINNAME" , timeSinceLastLoginAttribute ) ; lastLogin = formatter . format ( now ) ; lastLogin = UUID . randomUUID ( ) + "|" + lastLogin + "|" + userName ; lastLoginEnc = AccessController . doPrivileged ( new EncodeAction ( lastLogin ) ) ; postAuthNMap . put ( "LOGINVALUE" , lastLoginEnc ) ; } } if ( ! timeSinceLastLoginInvert ) { retVal = timeSinceLastLoginScore - retVal ; } return retVal ; }
check to see if the last login is within the allowed range last login is stored in a cookie in encrypted format
