Search in sources :

Example 1 with StoppedSessionException

use of org.apache.shiro.session.StoppedSessionException in project shiro by apache.

the class SimpleSession method validate.

public void validate() throws InvalidSessionException {
    // check for stopped:
    if (isStopped()) {
        // timestamp is set, so the session is considered stopped:
        String msg = "Session with id [" + getId() + "] has been " + "explicitly stopped.  No further interaction under this session is " + "allowed.";
        throw new StoppedSessionException(msg);
    }
    // check for expiration
    if (isTimedOut()) {
        expire();
        // throw an exception explaining details of why it expired:
        Date lastAccessTime = getLastAccessTime();
        long timeout = getTimeout();
        Serializable sessionId = getId();
        DateFormat df = DateFormat.getInstance();
        String msg = "Session with id [" + sessionId + "] has expired. " + "Last access time: " + df.format(lastAccessTime) + ".  Current time: " + df.format(new Date()) + ".  Session timeout is set to " + timeout / MILLIS_PER_SECOND + " seconds (" + timeout / MILLIS_PER_MINUTE + " minutes)";
        if (log.isTraceEnabled()) {
            log.trace(msg);
        }
        throw new ExpiredSessionException(msg);
    }
}
Also used : Serializable(java.io.Serializable) StoppedSessionException(org.apache.shiro.session.StoppedSessionException) DateFormat(java.text.DateFormat) ExpiredSessionException(org.apache.shiro.session.ExpiredSessionException)

Aggregations

Serializable (java.io.Serializable)1 DateFormat (java.text.DateFormat)1 ExpiredSessionException (org.apache.shiro.session.ExpiredSessionException)1 StoppedSessionException (org.apache.shiro.session.StoppedSessionException)1