<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<description>Shiro 配置</description>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!--设置自定义realm -->
<property name="realm" ref="monitorRealm" />
<!-- 需要使用cache的话加上这句 -->
<property name="cacheManager" ref="shiroEhcacheManager" />
</bean>
<!--自定义Realm 继承自AuthorizingRealm -->
<bean id="monitorRealm" class="org.seven.MonitorRealm.MonitorRealm"></bean>
<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager" />
<!-- 要求登录时的链接,非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面 -->
<property name="loginUrl" value="/" />
<!-- 用户访问未对其授权的资源时,所显示的连接 -->
<property name="unauthorizedUrl" value="/error/error.jsp" />
<property name="filterChainDefinitions">
<value>
<!--
Anon:不指定过滤器
Authc:验证,这些页面必须验证后才能访问,也就是我们说的登录后才能访问。
-->
/login.action=anon
/seven/** = authc, perms[seven:select]
/list*=anon
/**=authc
</value>
</property>
</bean>
<!-- shiro的缓存管理器,然后需要将缓存管理器注入到安全管理其中 -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<!--classpath是缓存属性的配置文件 -->
<property name="cacheManagerConfigFile" value="classpath:ehcache .xml" />
</bean>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<description>Shiro 配置</description>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!--设置自定义realm -->
<property name="realm" ref="monitorRealm" />
<!-- 需要使用cache的话加上这句 -->
<property name="cacheManager" ref="shiroEhcacheManager" />
</bean>
<!--自定义Realm 继承自AuthorizingRealm -->
<bean id="monitorRealm" class="org.seven.MonitorRealm.MonitorRealm"></bean>
<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager" />
<!-- 要求登录时的链接,非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面 -->
<property name="loginUrl" value="/" />
<!-- 用户访问未对其授权的资源时,所显示的连接 -->
<property name="unauthorizedUrl" value="/error/error.jsp" />
<property name="filterChainDefinitions">
<value>
<!--
Anon:不指定过滤器
Authc:验证,这些页面必须验证后才能访问,也就是我们说的登录后才能访问。
-->
/login.action=anon
/seven/** = authc, perms[seven:select]
/list*=anon
/**=authc
</value>
</property>
</bean>
<!-- shiro的缓存管理器,然后需要将缓存管理器注入到安全管理其中 -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<!--classpath是缓存属性的配置文件 -->
<property name="cacheManagerConfigFile" value="classpath:ehcache .xml" />
</bean>
</beans>