<?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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd"> 
	<description>Tigon Shiro Configuration</description>

    <!-- shiro -->
    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
        depends-on="lifecycleBeanPostProcessor" 
        p:proxyTargetClass="true" />
    <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"
        p:securityManager-ref="securityManager" />
	<!-- /shiro -->

    <bean id="securityManager" class="me.chyxion.tigon.shiro.DefaultWebSecurityManagerExt">
        <property name="sessionManager">
            <bean class="me.chyxion.tigon.shiro.DefaultWebSessionManagerExt">
                <property name="globalSessionTimeout"
                      value="${shiro.session.timeout:1800000}"/>
                <property name="sessionValidationSchedulerEnabled"
                      value="${shiro.session.validation.scheduler.enabled:false}" />
                <property name="sessionValidationInterval"
                      value="${shiro.session.validation.interval:3600000}" />
                <property name="sessionDAO">
                    <bean class="me.chyxion.tigon.shiro.SessionDAOSupport" />
                </property>
                <property name="sessionIdCookieEnabled" value="${shiro.session.id.cookie.enabled:true}" />
                <property name="sessionIdUrlRewritingEnabled" value="${shiro.session.id.url.rewriting.enabled:true}" />
                <property name="sessionIdCookie">
                    <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
                        <constructor-arg value="${shiro.session.id.cookie.name:SID}" />
                        <property name="domain" value="${shiro.cookie.domain:}" />
                        <property name="path" value="${shiro.cookie.path:/}" />
                        <property name="maxAge" value="${shiro.cookie.max.age:-1}" />
                        <property name="version" value="${shiro.cookie.version:-1}" />
                        <property name="secure" value="${shiro.cookie.secure:false}" />
                        <property name="httpOnly" value="${shiro.cookie.http.only:true}" />
                        <property name="comment" value="${shiro.cookie.comment:}" />
                    </bean>
                </property>
            </bean>
        </property>
        <property name="realm">
            <bean class="me.chyxion.tigon.shiro.AuthorizingRealmSupport" />
        </property>
    </bean>
	<!-- Shiro Filter -->
    <bean id="authConfigFactory" class="me.chyxion.tigon.shiro.AuthConfigFactory" />
    <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
        <property name="securityManager" ref="securityManager" />
        <property name="filters">    
            <bean factory-bean="authConfigFactory" factory-method="filters" />
        </property>
        <property name="filterChainDefinitionMap">
            <bean factory-bean="authConfigFactory" factory-method="filterRoutings" />
        </property>
    </bean>
    <bean class="me.chyxion.tigon.shiro.AuthExceptionResolver" />
    <bean class="me.chyxion.tigon.shiro.service.support.AuthServiceSupport" />
</beans>
