Fix a package tangle between SockJS support and transport packages

Issue: SPR-12379
This commit is contained in:
Sebastien Deleuze
2014-10-27 11:24:26 +01:00
parent 9243869763
commit 6592784ef4
2 changed files with 9 additions and 7 deletions

View File

@@ -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();

View File

@@ -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<String, Object> attributes) {