2015-09-02 81 views
0

我已經在我的安全包中實現下面的類我在spring-security.xml文件中如何使用TokenBasedRememberMeServices配置基於spring xml的配置文件?

公共類TokenBasedRememberMeServices擴展AbstractRememberMeServices

但是當我試圖在

<http auto-config="true" use-expressions="true"> <!-- enable remember me --> <remember-me token-validity-seconds="1209600" remember-me-parameter="remember-me" data-source-ref="dataSource" /> </http> 

配置還記得,我豆腐就不會工作這麼有沒有其他配置,我必須在我的spring-security.xml文件中添加?

回答

0

在XML文件中添加此:

<beans:bean id="rememberMeAuthenticationProvider" 
       class="org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices"> 
     <beans:property name="key" value="_spring_security_remember_me"/> 
     <property name="alwaysRemember" value="true"/> 
     <beans:property name="tokenRepository" ref="jdbcTokenRepository"/> 
     <beans:property name="userDetailsService" ref="userDetailsService"/> 
    </beans:bean> 

// Do you see below createTableOnStartUp, just keep it true for one time, //run the webapp, stop it, make it false and re-run it. 

    <beans:bean id="jdbcTokenRepository" 
       class="org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl"> 
     <beans:property name="createTableOnStartup" value="false"/> 
     <beans:property name="dataSource" ref="dataSource"/> 
    </beans:bean> 

如果你有疑問,還是讓我知道。

相關問題