记住我的春天安全

时间:2011-03-17 21:14:43

标签: spring-security remember-me

我目前正在尝试在我的网站中记住我的功能。以下是我配置的一部分

<security:remember-me services-ref="rememberMeServices" />  
<bean id="rememberMeServices" class="com.entertainment.ecom.web.auth.EcomRemembe rMeServices">  
<property name="userDetailsService" ref="ecomUserDetailsService"/>  
<property name="key" value="a23eef6dfd1514cb885f47070380ff18"/>  
<property name="cookieName" value="ENTC"/>  
<property name="tokenValiditySeconds" value="80000"/>  
</bean>

我的EcomRememberMeServices延长了AbstractRememberMeServices&amp;我已经覆盖了onLoginFail&amp; onLoginSuccess方法。我的问题是,我的onLoginSuccess()方法将从何处被调用?

我试图运行以上配置&amp;我们看到onLoginFail通过RememberMeAuthenticationFilter(rememberMeServices.loginFail(request, response))被调用,但当我检查此过滤器的源代码时,我找不到onLoginSuccess()loginSuccess()方法的任何调用。所以我需要明确地调用它吗?

BasicAuthenticationFilter中,需要调用此方法。所以我尝试使用它,但我仍然无法工作。(<http-basic/>)。那么有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

还有一个方法logout(),由logout过滤器调用。我想你必须将rememberMeServices注入Login和Logout Filter(我不确定它是否可以在xml的http元素中完成):

    <bean id="logoutFilter"   class="org.springframework.security.web.authentication.logout.LogoutFilter">
    <constructor-arg index="0" type="org.springframework.security.web.authentication.logout.LogoutSuccessHandler" ref="logoutSuccessHandler" />
    <constructor-arg index="1">
        <list value-type="org.springframework.security.web.authentication.logout.LogoutHandler">
            <ref local="rememberMeServices"/>
        </list>
    </constructor-arg>
</bean>

<bean id="formLoginFilter"   class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
     ...

     <property name="rememberMeServices">
            <ref local="rememberMeServices" />
     </property> 
</bean>