2015-04-06 78 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