Java Code Examples for org.apache.shiro.session.Session#getLastAccessTime()
The following examples show how to use
org.apache.shiro.session.Session#getLastAccessTime() .
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: IamSecurityHolder.java From super-cloudops with Apache License 2.0 | 5 votes |
/** * Gets session remaining expire time * * @param session * Shiro session * @return Current remaining expired milliseconds of the session */ public static long getSessionRemainingTime(Session session) { notNullOf(session, "session"); long now = currentTimeMillis(); Date startDate = session.getStartTimestamp(); Date lastADate = session.getLastAccessTime(); Long startTime = isNull(startDate) ? null : startDate.getTime(); Long lastTime = isNull(lastADate) ? startTime : lastADate.getTime(); notNull(lastTime, "Could't be here, session: '%s' startTime and lastTime is null!", session.getId()); return session.getTimeout() - (now - lastTime); }
Example 2
Source File: GuicedCassandraSessionDAO.java From arcusplatform with Apache License 2.0 | 4 votes |
private boolean isExpired(Session session) { if(session.getLastAccessTime() == null) { return false; } return System.currentTimeMillis() > (session.getLastAccessTime().getTime() + session.getTimeout()); }