启用Remember-me认证服务需要做的事情:
1、 在security的配置文件中定义remembermeprocessingfilter
<bean id="rememberMeProcessingFilter"
class="org.acegisecurity.ui.rememberme.RemenberMeProcessingFilte>
<property name="authenticationManager">
<ref local="authenticationManager" />
</property>
<property name="rememberMeServices">
<ref local="rememberMeServices" />
</property>
</bean>
<bean id="rememberMeServices"
class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
<property name="userDetailsService" ref="jdbcDaoImpl" />
<property name="key" value="springrocks" />
<property name="alwaysRemember" value="true" />
</bean>
2、 将上述过滤器定义的名字添加到过滤器链中,即filterChainproxy
3、 定义RememberMeauthenticationProvider认证提供者,并将他添加到认证管理器中
<bean id="rememberMeAuthenticationProvider" class="org.acegisecurity.providers.RememberMeAuthenticationProvider">
<property name="key" value="spring vock" />
</bean>
<bean id="authenticationManager"
class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<ref local="daoAuthenticationProvider" />
<ref local="rememberMeAuthenticationProvider" />
</list>
</property>
</bean>
4、 将上述rememberservices注入到basicprocessingfilter
<bean id="basicProcessingFilter"
class="org.acegisecurity.ui.basicauth.BasicProcessingFilter">
<property name="authenticationManager"
ref="authenticationManager" />
<property name="authenticationEntryPoint"
ref="basicProcessingFilterEntryPoint" />
<property name="rememberMeServices" ref="rememberMeServices" />
</bean>
通过以上四个步骤,我们就可以成功使用rememberme认证服务了。