shiro—安全配置
来源:互联网 发布:网络食品安全新规 新闻 编辑:程序博客网 时间:2024/06/05 15:31
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<description>Shiro安全配置</description>
<!-- Shiro的默认安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"
p:realm-ref="shiroDbRealm"
p:cacheManager-ref="shiroEhcacheManager" /> //注入缓存管理器
<!-- 项目自定义的Realm -->
<bean id="shiroDbRealm" class="com.coamctech.sample.demo.web.security.ShiroDbRealm" />
<!-- 自定义验证拦截器 -->
<bean id="redirectSuccessUrlFormAuthenticationFilter"
class="com.coamctech.sample.demo.web.security.RedirectSuccessUrlFormAuthenticationFilter" />
<!-- Shiro Filter -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"
p:securityManager-ref="securityManager"
p:loginUrl="/login"
p:successUrl="/login/success"
p:filters-ref="filters"
p:filterChainDefinitionMap-ref="filterChainDefinitionMap" />
<!-- 认证过滤器默认为FormAuthenticationFilter, 这里指定了自定义的FormAuthenticationFilter子类 -->
<util:map id="filters">
<entry key="authc" value-ref="redirectSuccessUrlFormAuthenticationFilter" />
</util:map>
<!-- Shiro的过滤器链, 过滤时会顺次执行 -->
<util:map id="filterChainDefinitionMap">
<entry key="/login" value="authc" />
<entry key="/logout" value="logout" />
<entry key="/static/**" value="anon" />
<entry key="/admin/**" value="roles[admin]" />
<entry key="/**" value="user" />
</util:map>
<!-- 用户授权信息Cache, 采用EhCache -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager"
p:cacheManagerConfigFile="classpath:ehcache-shiro.xml" />
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
</beans>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<description>Shiro安全配置</description>
<!-- Shiro的默认安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"
p:realm-ref="shiroDbRealm"
p:cacheManager-ref="shiroEhcacheManager" /> //注入缓存管理器
<!-- 项目自定义的Realm -->
<bean id="shiroDbRealm" class="com.coamctech.sample.demo.web.security.ShiroDbRealm" />
<!-- 自定义验证拦截器 -->
<bean id="redirectSuccessUrlFormAuthenticationFilter"
class="com.coamctech.sample.demo.web.security.RedirectSuccessUrlFormAuthenticationFilter" />
<!-- Shiro Filter -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"
p:securityManager-ref="securityManager"
p:loginUrl="/login"
p:successUrl="/login/success"
p:filters-ref="filters"
p:filterChainDefinitionMap-ref="filterChainDefinitionMap" />
<!-- 认证过滤器默认为FormAuthenticationFilter, 这里指定了自定义的FormAuthenticationFilter子类 -->
<util:map id="filters">
<entry key="authc" value-ref="redirectSuccessUrlFormAuthenticationFilter" />
</util:map>
<!-- Shiro的过滤器链, 过滤时会顺次执行 -->
<util:map id="filterChainDefinitionMap">
<entry key="/login" value="authc" />
<entry key="/logout" value="logout" />
<entry key="/static/**" value="anon" />
<entry key="/admin/**" value="roles[admin]" />
<entry key="/**" value="user" />
</util:map>
<!-- 用户授权信息Cache, 采用EhCache -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager"
p:cacheManagerConfigFile="classpath:ehcache-shiro.xml" />
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
</beans>
0 0
- shiro—安全配置
- Shiro安全框架相关配置
- Spring配置数据库和shiro安全机制
- shiro安全框架的简单配置
- Shiro安全框架配置之身份验证
- Java安全框架—Shiro
- shiro安全
- JAVA安全控制框架 —— Shiro
- 安全框架——Apache Shiro
- 权限控制器——Shiro安全框架
- JEECMS——安全框架Shiro
- Shiro 配置
- shiro配置
- shiro配置
- Shiro配置
- shiro配置
- shiro配置
- Shiro配置
- Linux内核构成
- 用Eclipse开发JSF时,是标签出现自动提醒
- python学习-类理解
- HDU1009 - FatMouse' Trade (贪心)
- 在JavaScript遇到的坑(二)
- shiro—安全配置
- 这种东西Skype莫名啟動
- Java IO体系中常用的流分类
- 如何使用Struts 2防止表单重复提交?
- Matlab风格的Plot类for opencv
- 18. jQuery - 尺寸
- 21 三个水杯【bfs】
- Codevs 题目1299 切水果 (线段树)
- sqlplus64: error while loading shared libraries: libsqlplus.so 解决