1

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

<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& 我已经覆盖了onLoginFail&onLoginSuccess方法。我的问题是,从哪里onLoginSuccess()调用我的方法?

我试图在配置之上运行,并且看到它onLoginFail被调用RememberMeAuthenticationFilter(rememberMeServices.loginFail(request, response))但是当我检查这个过滤器的源代码时,我找不到任何调用onLoginSuccess()loginSuccess()方法。那么我需要明确地调用它吗?

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

4

1 回答 1

0

还有一种方法 logout(),由注销过滤器调用。我想你也必须注入rememberMeServices登录和注销过滤器(我不确定它是否可以在 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>
于 2011-03-18T13:51:31.743 回答