Shiro的校验Session是否过期处理的过程
⾸先开启定时扫描活跃的ssion进⾏校验
<!-- shiro会话管理 -->
<!-- 即⽤户登录后就是⼀次会话,在没有退出之前,它的所有信息都在会话中;会话可以是普通 JavaSE 环境的,也可以是如 Web 环境的 -->
水池用英语怎么说<bean id="ssionManager" class="org.apache.shiro.DefaultWebSessionManager">
<property name="cacheManager" ref="redisCacheManager"/>
<property name="ssionDAO" ref="redisSessionDAO"/>
<property name="ssionIdCookie" ref="simpleCookie"/>
<!-- 全局的会话信息时间,,单位为毫秒 -->
<property name="globalSessionTimeout" value="60000"/>
<!-- 检测扫描信息时间间隔,单位为毫秒-->
<property name="ssionValidationInterval" value="60000"/>
<!-- 是否开启扫描 -->
<property name="ssionValidationSchedulerEnabled" value="true"/>
<!-- 去掉URL中的JSESSIONID -->
<property name="ssionIdUrlRewritingEnabled" value="fal"/>
</bean>一到十的英语单词
然后看源代码
AbstractValidatingSessionManager类中的validateSessions()
public void validateSessions() {
if (log.isInfoEnabled()) {
log.info("Validating all ");
}
鸡内金能治结石吗int invalidCount = 0;
Collection<Session> activeSessions = getActiveSessions();
通讯补贴if (activeSessions != null && !activeSessions.isEmpty()) {
for (Session s : activeSessions) {
try {
//simulate a lookup key to satisfy the method signature.
//this could probably stand to be cleaned up in future versions:
SessionKey key = new Id());
validate(s, key);
} catch (InvalidSessionException e) {
if (log.isDebugEnabled()) {
boolean expired = (e instanceof ExpiredSessionException);
String msg = "Invalidated ssion with id [" + s.getId() + "]" +
(expired ? " (expired)" : " (stopped)");
log.debug(msg);
}
invalidCount++;
}
}
}
if (log.isInfoEnabled()) {
String msg = "Finished ssion validation.";
考if (invalidCount > 0) {
msg += " [" + invalidCount + "] ssions were stopped.";
} el {人才素质测评报告
msg += " No ssions were stopped.";
滑稽列传
}
log.info(msg);
}
}
做校验的⽅法是validate(s, key);
protected void validate(Session ssion, SessionKey key) throws InvalidSessionException {
try {青少年科技创新
doValidate(ssion);
} catch (ExpiredSessionException e) {
onExpiration(ssion, e, key);
throw e;
} catch (InvalidSessionException i) {
onInvalidation(ssion, i, key);
throw i;
}
}
validate(ssion, key)说明:
AbstractValidatingSessionManager.validate(Session ssion, SessionKey key)⽅法中,如果是ssion有效期过期了,这会调⽤onExpiration(Session s, ExpiredSessionException e, SessionKey key)⽅法,该⽅法中onExpiration(s)调⽤ShiroCache类,删除shiro_redis_ssion:shiro-activeSessionCache:的ssion信息;afterExpired(s)调⽤RedisSessionDAO类,删除shiro_redis_ssion:的
ssion信息