2011-03-17 116 views
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/>)。那麼任何人都可以幫助我嗎?

回答

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>