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)");hard是什么意思
log.debug(msg);
}
invalidCount++;
}
}
}
日翻中
if (log.isInfoEnabled()) {
difficultString msg = "Finished ssion validation.";
if (invalidCount > 0) {
msg += " [" + invalidCount + "] ssions were stopped.";
} el {
msg += " No ssions were stopped.";
}
log.info(msg);
}
}
英语单词mp3
做校验的⽅法是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信息