public class OriginHandshakeInterceptor extends Object implements HandshakeInterceptor
Origin header value against a collection of
allowed origins.| Constructor and Description |
|---|
OriginHandshakeInterceptor()
Default constructor with no origin allowed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
Exception exception)
Invoked after the handshake is done.
|
boolean |
beforeHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
Map<String,Object> attributes)
Invoked before the handshake is processed.
|
protected boolean |
isValidOrigin(org.springframework.http.server.ServerHttpRequest request) |
void |
setAllowedOrigins(Collection<String> allowedOrigins)
Use this property to define a collection of allowed origins.
|
protected Log logger
public OriginHandshakeInterceptor()
public void setAllowedOrigins(Collection<String> allowedOrigins)
public boolean beforeHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
Map<String,Object> attributes)
throws Exception
HandshakeInterceptorbeforeHandshake in interface HandshakeInterceptorrequest - the current requestresponse - the current responsewsHandler - the target WebSocket handlerattributes - attributes from the HTTP handshake to associate with the WebSocket
session; the provided attributes are copied, the original map is not used.true) or abort (false)Exceptionprotected boolean isValidOrigin(org.springframework.http.server.ServerHttpRequest request)
public void afterHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
Exception exception)
HandshakeInterceptorafterHandshake in interface HandshakeInterceptorrequest - the current requestresponse - the current responsewsHandler - the target WebSocket handlerexception - an exception raised during the handshake, or null if none