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" 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.2.xsd  
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.2.xsd" default-autowire="byName" default-lazy-init="true">
 <description>Shiro 配置</description>

 <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
  <property name="securityManager" ref="securityManager" />
  <property name="loginUrl" value="/login" />
  <property name="successUrl" value="/index" />
  <property name="unauthorizedUrl" value="/error/noperms.jsp" />
  <property name="filterChainDefinitions">
   <value>
    /error/** = anon
    /resource/** = anon
    /attached/** = anon
    /login* = anon
    /validateCode* = anon
    /tmp_upload/** = anon
    /index.jsp* = anon
    /tchtml/** = anon
    /dfhtml/** = anon
    /fzhtml/** = anon
    /tc/** = anon
    /df/** = anon
    /fz/** = anon
    /activity/** = anon
    /as/** = anon
    /ashtml/** = anon
    /zs/** = anon
    /zshtml/** = anon
    /lt/** = anon
    /lthtml/** = anon

    /WEB-INF/** = authc
    /*.jsp* = authc
    /** = authc
   </value>
  </property>
 </bean>

 <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
  <!--设置自定义realm -->
  <property name="realm" ref="monitorRealm" />
  <property name="cacheManager" ref="cacheManager" />
 </bean>

 <!-- securityManager -->
 <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
  <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager" />
  <property name="arguments" ref="securityManager" />
 </bean>

 <!--自定义Realm 继承自AuthorizingRealm -->
 <bean id="monitorRealm" class="org.cxm.wolf.interceptor.MonitorRealm" />

 <!-- 用户授权信息Cache -->
 <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />

</beans>

你可能感兴趣的:(Shiro 配置)