package sg.ncl.webssh;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;

/**
 * References:
 * [1] http://www.sergialmar.com/2014/03/detect-websocket-connects-and-disconnects-in-spring-4/
 * [2] http://www.devglan.com/spring-boot/spring-session-stomp-websocket
 */

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Bean
    public SocketChannelInterceptor socketChannelInterceptor() {
        return new SocketChannelInterceptor();
    }

    @Override
    public void configureClientInboundChannel(ChannelRegistration registration) {
        registration.setInterceptors(socketChannelInterceptor());
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/shell");
        config.setApplicationDestinationPrefixes("/webssh");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/websocket").setAllowedOrigins("https://ncl.sg").withSockJS();
    }
}

@@ -724,16 +724,127 @@
 bsocket%0A
+ * %5B3%5D https://stackoverflow.com/questions/33977803/origin-header-value-not-allowed-even-though-url-is-allowed%0A
  */%0A%0A@Co

add reference