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);
}
}
Aggregations