春天:记住我没有设置cookie

时间:2013-02-14 14:27:17

标签: spring cookies spring-security

我似乎无法获得记住会话的spring的cookie,也不会填充dataSource的persistent_logins表。为什么客户没有收到cookie?

应用程序上下文xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<bean:beans>
    <http>
...
        <remember-me data-source-ref="dataSource"
            user-service-ref="userService" />
    </http>

    <authentication-manager alias="authenticationManager">
        <authentication-provider user-service-ref="userService">
            <password-encoder hash="md5" ref="passwordEncoder">
                <salt-source ref="saltSource" />
            </password-encoder>
        </authentication-provider>
    </authentication-manager>
...
</bean:beans>  

登录方法:

@Service
public class AServiceImpl extends RemoteServiceServlet implements AService {
    @Override
    public boolean login(String username, String password, boolean remember) {
         Collection<GrantedAuthority> auths = userDetailsService.getGrantedAuthorities(user);
         auth = new UsernamePasswordAuthenticationToken(username, password, auths);
         Authentication result = authenticationManager.authenticate(auth);
         SecurityContextHolder.getContext().setAuthentication(result);
         getThreadLocalRequest().getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,SecurityContextHolder.getContext());
         rememberMeServices.loginSuccess(getThreadLocalRequest(),getThreadLocalResponse(), auth);
     }
}

0 个答案:

没有答案