<!-- 退出过滤器 -->
<bean id="logoutFilter"
class="org.acegisecurity.ui.logout.LogoutFilter">
<constructor-arg
value="/index.jsp" />
<constructor-arg>
<list>
<ref
local="rememberMeServices" />
<ref
local="securityContextLogoutHandler" />
</list>
</constructor-arg>
</bean>
<!-- 安全上下文退出句柄 -->
<bean
id="securityContextLogoutHandler"
class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler">
<property
name="invalidateHttpSession" value="true" />
</bean>
<!-- ================
认证部分
================ -->
<!-- 表单认证过滤器 -->
<bean
id="authenticationProcessingFilter"
class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
<property
name="authenticationManager" ref="authenticationManager"
/>
<property
name="authenticationFailureUrl" value="/login.jsp?error=1"
/>
<property
name="defaultTargetUrl" value="/" />
<property
name="alwaysUseDefaultTargetUrl" value="true" />
<property
name="filterProcessesUrl" value="/j_acegi_security_check"
/>
<property
name="rememberMeServices" ref="rememberMeServices" />
</bean>
<!-- 认证管理器 -->
<bean id="authenticationManager"
class="org.acegisecurity.providers.ProviderManager">
<property
name="providers">
<list>
<ref
local="daoAuthenticationProvider" />
<ref
local="anonymousAuthenticationProvider" />
<ref
local="rememberMeAuthenticationProvider" />
</list>
</property>
</bean>
<!-- DAO认证源提供者 -->
<bean id="daoAuthenticationProvider"
class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
<property
name="userDetailsService" ref="inMemDaoImpl" />
</bean>
<!-- 用户信息源(内存) -->
<bean id="inMemDaoImpl"
class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">
<property
name="userMap">
<value>
admin=password,ROLE_ADMIN,ROLE_USER
user1=password,ROLE_USER
</value>
</property>
</bean>
<!-- 免登录认证过滤器 -->
<bean id="rememberMeProcessingFilter"
class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
<property
name="authenticationManager" ref="authenticationManager"
/>
<property
name="rememberMeServices" ref="rememberMeServices"></property>
</bean>
<!-- 免登录服务 -->
<bean id="rememberMeServices"
class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
<property
name="userDetailsService" ref="inMemDaoImpl" />
<property
name="key" value="springRocks" />
<property
name="tokenValiditySeconds" value="1209600" />
<property
name="parameter" value="_acegi_security_remember_me" />
<property
name="cookieName"
value="ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE" />
<!--
<property
name="alwaysRemember" value="true" />
-->
</bean>
<!-- 免登录认证源提供者 -->
<bean
id="rememberMeAuthenticationProvider"
class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
<property
name="key" value="springRocks" />
</bean>
<!-- 匿名认证过滤器 -->
<bean id="anonymousProcessingFilter"
class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
<property
name="key" value="foobar" />
<property
name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS"
/>
</bean>
<!-- 匿名认证源提供者 -->
<bean id="anonymousAuthenticationProvider"
class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
<property
name="key" value="foobar" />
</bean>
<!-- 异常处理过滤器 -->
<bean id="exceptionTranslationFilter"
class="org.acegisecurity.ui.ExceptionTranslationFilter">
<property
name="authenticationEntryPoint"
ref="authenticationProcessingFilterEntryPoint" />
<property
name="accessDeniedHandler" ref="accessDeniedHandlerImpl"
/>
</bean>
<!-- 表单认证入口点 -->
<bean
id="authenticationProcessingFilterEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<property
name="loginFormUrl" value="/login.jsp" />
<property
name="forceHttps" value="false" />
<property
name="serverSideRedirect" value="false" />
</bean>
<!-- 授权拒绝句柄 -->
<bean id="accessDeniedHandlerImpl"
class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
<property
name="errorPage" value="/accessDenied.jsp" />
</bean>