0

我似乎无法获得记忆会话的春季 cookie,也没有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);
     }
}
4

0 回答 0