zoukankan      html  css  js  c++  java
  • shiro session计算timeout

    /**
         * 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;
        }
  • 相关阅读:
    js 获取表单和页面控件数据
    vue axios upload 多个文件
    vue antd axios 使用
    antd vue 修改modal弹窗样式
    线性回归的改进-岭回归
    线性回归
    00
    集成学习方法之随机森林
    决策树
    第十讲 让机器像人类一样学习--强化学习-----学习总结
  • 原文地址:https://www.cnblogs.com/gmq-sh/p/6214523.html
Copyright © 2011-2022 走看看