| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?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:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-
- <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
- <property name="maxIdle" value="100"/>
- <property name="minIdle" value="10"/>
- <property name="testOnBorrow" value="true"/>
- </bean>
-
- <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
- <constructor-arg index="0" ref="jedisPoolConfig" />
- <constructor-arg index="1" value="${jedis.host}" name="host" type="java.lang.String"/>
- <constructor-arg index="2" value="${jedis.port}" name="port" type="int"/>
- <constructor-arg index="3" value="${jedis.timeout}" name="timeout" type="int"/>
- <constructor-arg index="4" value="${jedis.password}" name="password" type="java.lang.String"/>
- </bean>
-
- <bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"/>
-
- <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
- <constructor-arg value="AFT_SID"/>
- <property name="httpOnly" value="true"/>
-
- <property name="maxAge" value="1296000"/>
- <!--
- <property name="domain" value=""/>
- -->
- </bean>
- <!-- custom shiro session listener -->
- <bean id="customSessionListener" class="com.goafanti.core.shiro.listener.CustomSessionListener">
- <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
- </bean>
-
- <!-- custom shiro session listener -->
- <bean id="customShiroSessionDAO" class="com.goafanti.core.shiro.CustomShiroSessionDAO">
- <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
- <property name="sessionIdGenerator" ref="sessionIdGenerator"/>
- </bean>
- <!-- -->
- <bean id="customSessionManager" class="com.goafanti.core.shiro.session.CustomSessionManager">
- <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
- <property name="customShiroSessionDAO" ref="customShiroSessionDAO"/>
- </bean>
-
- <!-- -->
- <bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
- <!-- -->
- <property name="interval" value="${session.validate.timespan}"/>
- <property name="sessionManager" ref="sessionManager"/>
- </bean>
- <!-- -->
- <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
- <property name="realm" ref="userRealm"/>
- <property name="sessionManager" ref="sessionManager"/>
- <property name="cacheManager" ref="customShiroCacheManager"/>
- </bean>
- <!-- -->
- <bean id="customShiroCacheManager" class="com.goafanti.core.shiro.cache.impl.CustomShiroCacheManager">
- <property name="shiroCacheManager" ref="jedisShiroCacheManager"/>
- </bean>
-
- <!-- -->
- <bean id="jedisShiroCacheManager" class="com.goafanti.core.shiro.cache.impl.JedisShiroCacheManager">
- <property name="jedisManager" ref="jedisManager"/>
- </bean>
- <!-- -->
- <bean id="jedisManager" class="com.goafanti.core.shiro.cache.JedisManager">
- <property name="jedisPool" ref="jedisPool"/>
- </bean>
- <!-- SecurityUtils.setSecurityManager(securityManager) -->
- <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
- <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
- <property name="arguments" ref="securityManager"/>
- </bean>
- <!-- credential matcher -->
- <bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
- <property name="hashAlgorithmName" value="${pwd.hash_algorithm_name}"/>
- <property name="hashIterations" value="${pwd.hash_iterations}"/>
- <property name="storedCredentialsHexEncoded" value="true"/>
- </bean>
- <!-- -->
- <bean id="userRealm" class="com.goafanti.core.shiro.token.UserRealm" >
- <property name="credentialsMatcher" ref="credentialsMatcher"/>
- </bean>
-
- <!-- Session Manager -->
- <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
- <!-- -->
- <property name="sessionValidationInterval" value="1800000"/>
- <!-- -->
- <property name="globalSessionTimeout" value="1800000"/>
- <property name="sessionDAO" ref="customShiroSessionDAO"/>
- <!-- session -->
- <property name="sessionListeners">
- <list>
- <ref bean="customSessionListener"/>
- </list>
- </property>
- <!-- -->
- <property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>
- <!-- -->
- <property name="sessionValidationSchedulerEnabled" value="true"/>
- <!-- -->
- <property name="deleteInvalidSessions" value="true"/>
- <!-- -->
- <property name="sessionIdCookie" ref="sessionIdCookie"/>
- </bean>
- <!-- -->
- <bean id="jedisShiroSessionRepository" class="com.goafanti.core.shiro.cache.JedisShiroSessionRepository" >
- <property name="jedisManager" ref="jedisManager"/>
- </bean>
- <!--
-
- -->
-
- <!-- -->
- <bean id="shiroManager" class="com.goafanti.core.shiro.service.impl.ShiroManagerImpl"/>
- <bean id="login" class="com.goafanti.core.shiro.filter.LoginFilter"/>
- <bean id="role" class="com.goafanti.core.shiro.filter.RoleFilter"/>
- <bean id="permission" class="com.goafanti.core.shiro.filter.PermissionFilter"/>
- <bean id="simple" class="com.goafanti.core.shiro.filter.SimpleAuthFilter"/>
-
- <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
- <property name="securityManager" ref="securityManager" />
- <property name="loginUrl" value="/login" />
- <property name="successUrl" value="/main" />
- <property name="unauthorizedUrl" value="/login" />
-
- <!-- -->
- <property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}"/>
- <property name="filters">
- <util:map>
- <entry key="login" value-ref="login"></entry>
- <entry key="role" value-ref="role"></entry>
- <entry key="simple" value-ref="simple"></entry>
- <entry key="permission" value-ref="permission"></entry>
- </util:map>
- </property>
- </bean>
- <!-- -->
- <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
-
- </beans>
|