我正在玩Spring 4 Stomp over Websockets。现在我试图在我的配置中输入登录名和密码。
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
//registry.enableSimpleBroker("/queue/", "/topic/");
//Enable MQ
StompBrokerRelayRegistration relay=registry.enableStompBrokerRelay("/queue/", "/topic/");
relay.setSystemLogin("login");
relay.setSystemPasscode("passcode");
//relay.setClientLogin("login");
//relay.setClientPasscode("passcode");
registry.setApplicationDestinationPrefixes("/app");
}
但是当我尝试连接不同的登录名和密码时,我仍然可以连接。这是我的javascript。
$scope.initSockets = function() {
$scope.socket.client = new SockJS('/Html5GameApp');
$scope.socket.stomp = Stomp.over($scope.socket.client);
$scope.socket.stomp.connect("sample","sample",function(frame) {
console.log('Connected: ' + frame);
$scope.socket.stomp.subscribe("/queue/stomp.data", $scope.liveGameData);
});
$scope.socket.client.onclose = $scope.reconnect;
};
我的配置是否有问题?如何正确设置。谢谢
答案 0 :(得分:3)
您的申请是由3"系统"或者"演员"在这种情况下:
如果您查看StompBrokerRelayRegistration的javadoc,您会看到:
如果您实际上是在尝试在应用程序中强制实施访问安全性,则可以查看the portfolio sample和its security config。简而言之,在此示例中,在HTTP升级阶段强制执行安全性。