/**
* Determines if this session is expired.
*
* @return true if the specified session has expired, false otherwise.
*/
protected boolean isTimedOut() { if (isExpired()) {
return true;
} long timeout = getTimeout(); if (timeout >= 0l) { Date lastAccessTime = getLastAccessTime(); if (lastAccessTime == null) {
String msg = "session.lastAccessTime for session with id [" +
getId() + "] is null. This value must be set at " +
"least once, preferably at least upon instantiation. Please check the " +
getClass().getName() + " implementation and ensure " +
"this value will be set (perhaps in the constructor?)";
throw new IllegalStateException(msg);
} // Calculate at what time a session would have been last accessed
// for it to be expired at this point. In other words, subtract
// from the current time the amount of time that a session can
// be inactive before expiring. If the session was last accessed
// before this time, it is expired.
long expireTimeMillis = System.currentTimeMillis() - timeout;
Date expireTime = new Date(expireTimeMillis);
return lastAccessTime.before(expireTime);
} else {
if (log.isTraceEnabled()) {
log.trace("No timeout for session with id [" + getId() +
"]. Session is not considered expired.");
}
} return false;
}

shiro session计算timeout的更多相关文章

  1. 修改记录-优化后(springboot+shiro+session+redis+ngnix共享)

    1.普通用户实现redis共享session 1.配置 #cache指定缓存类型 spring.cache.type=REDIS #data-redis spring.redis.database=1 ...

  2. shiro session管理

    http://shiro.apache.org/session-management.html Using Sessions The SessionManager Session Timeout Pe ...

  3. 【Shiro】六、Apache Shiro Session管理

    1.Session的介绍 关于Session 会话:从启动一个Session到关闭这个Session作为一个会话,是对客户端和服务器端交互的一种封装,带有时效性 会话的产生: 一般从容器中产生 Web ...

  4. 解决org.apache.shiro.session.UnknownSessionException: There is no session with id的问题

    一.背景 最近在整合了Spring+Shiro+Redis实现tomcat集群session共享的问题之后,发布以后运行以后发现老是会出现:org.apache.shiro.session.Unkno ...

  5. org.apache.shiro.session.InvalidSessionException: java.lang.IllegalStateException: getAttribute: Session already invalidated] with root cause

    1.遇到以下异常,找了好长时间,终于解决,报的异常如下: 七月 07, 2017 3:02:16 下午 org.apache.catalina.core.StandardWrapperValve in ...

  6. Shiro session和Spring session一样吗?

    出自:https://yq.aliyun.com/articles/114167?t=t1 1. 疑问 我们在项目中使用了spring mvc作为MVC框架,shiro作为权限控制框架,在使用过程中慢 ...

  7. nginx 、tomcat 集群配置、shiro Session 共享

    一.nginx.config 配置 #user nobody; worker_processes ; #error_log logs/error.log; #error_log logs/error. ...

  8. org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案

    org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案 背景描述 Sprin ...

  9. 集群环境下Shiro Session的管理

    问题引入 紧接上篇连接 在多台tomcat集群中,shiro管理的session需要放在Redis中,我们只需要增加redisSessionDAO的配置就行 <!-- 定义会话管理器的操作 表示 ...

随机推荐

  1. SQLSERVER 获取datetime日期的查询语句

    SELECT varchar(10:57AM SELECT varchar(CONVERT(100), GETDATE(), 2): 11.05.16 SELECT varchar(CONVERT(1 ...

  2. python 补漏计划

    从今天开始把python的细枝末节都梳理下 争取 每星期 两篇博文

  3. Bootstrap JavaScript插件

      在bs3.X中,提供了12种JavaScript插件,分别是:动画过渡(Transition).模态弹窗(Modal).下拉菜单(Dropdown).滚动侦测(Scrollspy).选项卡(Tab ...

  4. BFC的布局规则以及触发条件

          1   .BFC的含义 :          Block Formatting Contexts(BFC)                                      块级元 ...

  5. wpf ListBox删除

    绑定一个GUID对象 重绑定的数组中移除改对象,重新绑定.

  6. Javascript格式化json返回的时间(/Date(1482747413000)/)

    //时间处理,类似/Date(1482747413000)/的形式,得到xxx年xx月xx日 11:11:11 function ChangeDateFormat(jsondate) { jsonda ...

  7. MYSQL远程登录权限设置 ,可以让Navicat远程连接服务器的数据库

    Mysql默认关闭远程登录权限,如下操作允许用户在任意地点登录: 1. 进入mysql,GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ...

  8. HTTP Cache

    最近在学习HTTP协议,看的书籍是<HTTP权威指南>,这本书讲的很不错,细节都讲的很透彻,虽然书本比较厚,因为讲的通俗易懂,所以比较有意思并不觉得枯燥.下面是读书后做的读书笔记. [图片 ...

  9. NOIP2016题解

    D1T1:把方向和朝向异或一下,在mod n意义下+1s或-1s. #include<cstdio> const int N=1e5+5; int n,m,j,k,v,s[N]; char ...

  10. JEECG 社区开源项目下载(总览)

    反馈问题板块:http://www.jeecg.org/forum.php?mod=forumdisplay&fid=153 资源1: JEECG 微云快速开发平台( JEECG 3.6.5  ...