<?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
		http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.2.xsd"
	default-lazy-init="true">
 <description>apache shiro配置</description>
<context:property-placeholder ignore-unresolvable="true" location="classpath*:/application.properties" />
 <!-- 加载配置属性文件 -->  
	<bean class="com.cftech.core.util.SpringContextHolder" />

 	<bean id="springContextHolder" class="com.cftech.core.util.SpringContextHolder" />
    <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
        <property name="securityManager" ref="securityManager"/>
        <property name="loginUrl" value="/page/login"/>
        <property name="successUrl" value="/a/index"/>
       <property name="unauthorizedUrl" value="/page/401"/> 
        <property name="filterChainDefinitions">
            <value>
                /app/** = anon
                /swagger-ui.html = anon
                /assets/** = anon<!-- 后台静态资源允许访问 -->
                /mobile/** = anon<!-- 手机端接口 -->
                /api/** = anon<!-- 开放对外接口 -->
                /static/** = anon <!-- 前端静态资源 -->
                /ws/** = anon   <!-- WebService -->
                /test/** = anon
                /*.html = anon
                /weixin/** = anon
                <!-- 登录页允许访问 -->
                /page/** = anon
                /a/logout = logout
                <!-- 其他资源需要认证 -->
                /a/** = authc
                /** = authc
            </value>
        </property>
    </bean>

    <!-- 缓存管理器 使用Ehcache实现 -->
    <bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="classpath:ehcache-shiro.xml"/>
    </bean>

    <!-- 会话DAO -->
    <bean id="sessionDAO" class="org.apache.shiro.session.mgt.eis.MemorySessionDAO"/>

    <!-- 会话管理器 -->
    <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
        <property name="sessionDAO" ref="sessionDAO"/>
    </bean>
    <!-- 安全管理器 -->
    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <!--单个realm使用realm,如果有多个realm，使用realms属性代替-->
		<property name="realm" ref="securityRealm" />
        <!-- <property name="realms">
            <list>
                <ref bean="securityRealm"/>
            </list>
        </property> -->
        <!-- cacheManager,集合spring缓存工厂 -->
       <property name="cacheManager" ref="shiroEhcacheManager" /> 
      <!--    <property name="sessionManager" ref="sessionManager" />  -->
    </bean>
	
    <!-- Shiro生命周期处理器 -->
    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
	<bean id="securityRealm" class="com.cftech.sys.security.SecurityRealm"></bean>
</beans>