Shiro becomes invalid due to a problem caused by Invalid shiro cache.

Source: Internet
Author: User

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);    ...}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.