Java Code Examples for org.apache.catalina.Session#getThisAccessedTime()

The following examples show how to use org.apache.catalina.Session#getThisAccessedTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentValve.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Indicate whether the session has been idle for longer
 * than its expiration date as of the supplied time.
 *
 * FIXME: Probably belongs in the Session class.
 * @param session The session to check
 * @param timeNow The current time to check for
 * @return <code>true</code> if the session is past its expiration
 */
protected boolean isSessionStale(Session session, long timeNow) {

    if (session != null) {
        int maxInactiveInterval = session.getMaxInactiveInterval();
        if (maxInactiveInterval >= 0) {
            int timeIdle = // Truncate, do not round up
                (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
            if (timeIdle >= maxInactiveInterval) {
                return true;
            }
        }
    }

    return false;
}
 
Example 2
Source File: PersistentValve.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Indicate whether the session has been idle for longer
 * than its expiration date as of the supplied time.
 *
 * FIXME: Probably belongs in the Session class.
 */
protected boolean isSessionStale(Session session, long timeNow) {

    if (session != null) {
        int maxInactiveInterval = session.getMaxInactiveInterval();
        if (maxInactiveInterval >= 0) {
            int timeIdle = // Truncate, do not round up
                (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
            if (timeIdle >= maxInactiveInterval) {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Source File: PersistentValve.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Indicate whether the session has been idle for longer
 * than its expiration date as of the supplied time.
 *
 * FIXME: Probably belongs in the Session class.
 */
protected boolean isSessionStale(Session session, long timeNow) {

    if (session != null) {
        int maxInactiveInterval = session.getMaxInactiveInterval();
        if (maxInactiveInterval >= 0) {
            int timeIdle = // Truncate, do not round up
                (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
            if (timeIdle >= maxInactiveInterval) {
                return true;
            }
        }
    }

    return false;
}
 
Example 4
Source File: SessionUtils.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 5
Source File: SessionUtils.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static long getTTLForSession(Session in_session) {
    try {
        long diffMilliSeconds = (1000*in_session.getMaxInactiveInterval()) - (System.currentTimeMillis() - in_session.getThisAccessedTime());
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 6
Source File: SessionUtils.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static long getInactiveTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds =  System.currentTimeMillis() - in_session.getThisAccessedTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 7
Source File: SessionUtils.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 8
Source File: SessionUtils.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static long getTTLForSession(Session in_session) {
    try {
        long diffMilliSeconds = (1000*in_session.getMaxInactiveInterval()) - (System.currentTimeMillis() - in_session.getThisAccessedTime());
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 9
Source File: SessionUtils.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static long getInactiveTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds =  System.currentTimeMillis() - in_session.getThisAccessedTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 10
Source File: SessionUtils.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 11
Source File: SessionUtils.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static long getTTLForSession(Session in_session) {
    try {
        long diffMilliSeconds = (1000*in_session.getMaxInactiveInterval()) - (System.currentTimeMillis() - in_session.getThisAccessedTime());
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 12
Source File: SessionUtils.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static long getInactiveTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds =  System.currentTimeMillis() - in_session.getThisAccessedTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 13
Source File: ManagerBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public long getThisAccessedTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getThisAccessedTime();
}
 
Example 14
Source File: ManagerBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public long getThisAccessedTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getThisAccessedTime();
}
 
Example 15
Source File: ManagerBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public long getThisAccessedTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getThisAccessedTime();
}