码迷,mamicode.com
首页 > 其他好文 > 详细

shiro 实现 用户 a 操作b 的权限 ,用户 b 能够及时获知。b不需要退出登陆 。 关闭鉴权缓存,或者不配置缓存

时间:2015-04-17 17:29:44      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

<bean id="myRealm" class="com.diancai.util.MyRealm">
        <property name="userService" ref="userService"/>
        <property name="credentialsMatcher" ref="credentialsMatcher"/>
        <!-- <property name="cachingEnabled" value="true"/>
        <property name="authenticationCachingEnabled" value="true"/>
        <property name="authenticationCacheName" value="authenticationCache"/>
        <property name="authorizationCacheName" value="authorizationCache"/> -->
        <property name="authorizationCachingEnabled" value="false"/>
        <!-- 如果设置成false,关闭鉴权缓存。那么每次验证权限的时候由于默认读取缓存中的权限信息,
            如果读取不到信息就会再次请求realm中的doGetAuthrizationInfo方法获得权限.
            需求:以此实现 权限的动态读取,而不是一次读取一直有效。保证管理员操作用户权限,用户能及时更新
            (也可以不配置缓存机制,自然实现上述需求)-->
    </bean>




<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <property name="realm" ref="myRealm"></property>
        <property name="rememberMeManager" ref="rememberMeManager"></property>
        <property name="cacheManager" ref="shiroEhcacheManager" />
    </bean>
    <!-- 用户授权信息Cache, 采用EhCache -->
    <bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="classpath:security/ehcache-shiro.xml"/>
    </bean>

 


<ehcache updateCheck="false" name="shiroCache">

    <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="false"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            />
</ehcache>

 



 

shiro 实现 用户 a 操作b 的权限 ,用户 b 能够及时获知。b不需要退出登陆 。 关闭鉴权缓存,或者不配置缓存

标签:

原文地址:http://www.cnblogs.com/zhangchenglzhao/p/4435282.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!