From 6592784ef408ade36cb62b62356ca019ded8e344 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Mon, 27 Oct 2014 11:24:26 +0100 Subject: [PATCH] Fix a package tangle between SockJS support and transport packages Issue: SPR-12379 --- .../web/socket/sockjs/support/AbstractSockJsService.java | 7 ------- .../sockjs/transport/TransportHandlingSockJsService.java | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java index 34bbb39b9a..e5c0ebeb90 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java @@ -46,7 +46,6 @@ import org.springframework.util.StringUtils; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.sockjs.SockJsException; import org.springframework.web.socket.sockjs.SockJsService; -import org.springframework.web.socket.sockjs.transport.TransportType; /** * An abstract base class for {@link SockJsService} implementations that provides SockJS @@ -379,12 +378,6 @@ public abstract class AbstractSockJsService implements SockJsService { response.setStatusCode(HttpStatus.NOT_FOUND); return; } - else if(!this.allowedOrigins.contains("*") && !TransportType.fromValue(transport).supportsOrigin()) { - logger.debug("Origin check has been enabled, but this transport does not support it, ignoring " - + requestInfo); - response.setStatusCode(HttpStatus.NOT_FOUND); - return; - } handleTransportRequest(request, response, wsHandler, sessionId, transport); } response.close(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java index 279cbc86a7..3c14770ff7 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java @@ -273,6 +273,15 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem } } + @Override + protected boolean validateRequest(String serverId, String sessionId, String transport) { + if(!this.getAllowedOrigins().contains("*") && !TransportType.fromValue(transport).supportsOrigin()) { + logger.error("Origin check has been enabled, but this transport does not support it"); + return false; + } + return super.validateRequest(serverId, sessionId, transport); + } + private SockJsSession createSockJsSession(String sessionId, SockJsSessionFactory sessionFactory, WebSocketHandler handler, Map attributes) {