1.配置二级缓存

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

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

2.配置shiro框架

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true"> <description>Shiro</description> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!-- Single realm app. If you have multiple realms, use the 'realms' property instead. -->
<property name="realm" ref="authRealm"/>
<!-- 二级缓存 -->
<property name="cacheManager" ref="shiroEhcacheManager"/>
</bean> <!-- 自定义权限认证 -->
<bean id="authRealm" class="cn.xxxx.jk.shiro.AuthRealm">
<property name="userService" ref="userService"/>
<property name="credentialsMatcher" ref="passwordMatcher"/>
</bean> <!-- 自定义加密策略 -->
<bean id="passwordMatcher" class="cn.xxxx.jk.shiro.CustomCredentialsMatcher"/> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/index.jsp"></property>
<!-- 没有权限或者失败后跳转的页面 -->
<property name="successUrl" value="/home.action"></property>
<property name="filterChainDefinitions">
<!-- , roles[admin], perms[document:read]-->
<value>
/index.jsp* = anon
/home* = anon
/sysadmin/login/login.jsp* = anon
/sysadmin/login/logout.jsp* = anon
/login* = anon
/logout* = anon /*.* = authc
/resource/** = anon
</value>
</property>
</bean> <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManagerConfigFile" value="classpath:ehcache-shiro.xml"/>
</bean> <!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> <!-- 生成代理,通过代理进行控制 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor">
<property name="proxyTargetClass" value="true"/>
</bean> <!-- 安全管理器 -->
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
</bean> </beans>

  

最新文章

  1. svn 提交代码报错
  2. 发布一个开源极致的javascript模板引擎tpl.js
  3. 转载--How to Install VMware Tools on CentOS 6.3
  4. Linux内核简介
  5. C#中如何利用操作符重载和转换操作符
  6. Android基础之用Eclipse搭建Android开发环境和创建第一个Android项目(Windows平台)
  7. Node.js之【express 安装问题】
  8. git clone之后自动checkout文件处理
  9. webstrom的注释
  10. ajax 简单操作
  11. 项目检出JRE问题(Unbound classpath container: &#39;JRE System Library [JavaSE-1.7]&#39; in project &#39;idweb&#39;)
  12. SpringMVC 前端获得定义JSON对象的方法
  13. 计算机 计算机语言 常见的DOS命令
  14. 基于vue2.0+vuex+localStorage开发的本地记事本
  15. poptest老李谈动态口令原理
  16. react - 解刨组件的多种写法
  17. 第四次作业 四则运算器在C++层面上的进一步思考
  18. 四、删除 Delete
  19. 云计算openstack共享组件(2)——Memcache 缓存系统
  20. B+树和B-树的区别

热门文章

  1. 关于cookie使用的一些问题
  2. A* k短路 学习笔记
  3. JSON 序列化与弱类型
  4. ubuntu 安装自启动管理
  5. C++11学习笔记(5) —— override and final (转)
  6. consul UI用127可以访问,指定ip无法访问
  7. hdu 1065(推公式)
  8. Codeforces 321D Ciel and Flipboard(结论题+枚举)
  9. Xamarin XAML语言教程使用Visual Studio创建XAML
  10. 1.搭建maven,eclipse创建maven项目