2015-04-06 37 views
0

我正在通过sockJs开发一个带有spring-messaging和STOMP的服务器。 我想做授权trhought websockets。 所以从客户端我也送一些象征性的,然后我得到令牌针用户,我想我会与该用户相关联,我做下一个:春季消息+安全如何通过websockets登录?

private void authorizeUser(Profile profile) { 

    SignedUser signedUser = new SignedUser(profile); 
    List<GrantedAuthority> authorities = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); 

    UsernamePasswordAuthenticationToken authentication = 
      new UsernamePasswordAuthenticationToken(signedUser, null, authorities); 


    SecurityContextHolder.getContext().setAuthentication(authentication); 
} 

但会议没有关联,任何人都可以帮我这个问题?

谢谢。

+0

我面临着类似的问题,你是如何发送来自客户端的令牌? – 2015-06-24 06:25:33

回答

0
+0

我尝试实现,但得到'不能autowire字段:私人org.springframework.session.SessionRepository org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigurer.sessionRepository;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有[org.springframework.session.SessionRepository]类型的合格bean' 你有什么建议吗? – satween 2015-04-07 00:47:18