Shiro becomes invalid due to a problem caused by Invalid shiro cache.
Shiro 1.2.2 and 1.2.3
Cache is set for shiro, but when the server runs for several hours, the page determines
<Shiro: hasPermission name = "admin">
<Li class = "mail"> permission
</Li>
</Shiro: hasPermission>
Not displayed. Re-login is also invalid. The problem should be that the actual cache is invalid, but the framework still considers it valid.
The attempt is invalid.
(1)
If you delete the ehcache configuration document corresponding to shiro,
TimeToIdleSeconds = "10"
TimeToLiveSeconds = "10"
This problem persists. However, the frequency of problems is reduced.
(2) Add in application-shiro
<Bean id = "sessionManager"
Class = "org. apache. shiro. web. session. mgt. DefaultWebSessionManager">
<! -- Timeout -->
<Property name = "globalSessionTimeout" value = "3600" type = "regxph" text = "yourobjectname"/>
<Property name = "sessionDAO" ref = "sessionDAO"/>
<! -- Timed check for invalid sessions -->
<Property name = "sessionValidationSchedulerEnabled" value = "true"/>
</Bean>
<Bean id = "sessionDAO"
Class = "org. apache. shiro. session. mgt. eis. EnterpriseCacheSessionDAO">
<Property name = "activeSessionsCacheName" value = "shiro-activeSessionCache"/>
</Bean>
Still useless
Google to http://stackoverflow.com/questions/17657283/cache-invalidate-not-working-in-shiro
First, actively clear the cache when verifying permissions.
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { ... SimplePrincipalCollection principals = new SimplePrincipalCollection(username, "jndiJdbcRealm"); super.doClearCache(principals); ...}