我已经在我的安全包中实现了以下类
公共类TokenBasedRememberMeServices扩展了AbstractRememberMeServices
但是当我尝试在
中配置remember-me bean时<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 :(得分: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>
如果你有疑问,请知道。