public class OriginHandshakeInterceptor extends java.lang.Object implements HandshakeInterceptor
Origin
header value against a collection of
allowed origins.Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
allowedOrigins |
protected Log |
logger |
Constructor and Description |
---|
OriginHandshakeInterceptor()
Default constructor with no origin allowed.
|
Modifier and Type | Method and Description |
---|---|
void |
afterHandshake(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler wsHandler,
java.lang.Exception exception)
Invoked after the handshake is done.
|
boolean |
beforeHandshake(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler wsHandler,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Invoked before the handshake is processed.
|
protected boolean |
isValidOrigin(ServerHttpRequest request) |
void |
setAllowedOrigins(java.util.Collection<java.lang.String> allowedOrigins)
Use this property to define a collection of allowed origins.
|
protected Log logger
private final java.util.List<java.lang.String> allowedOrigins
public OriginHandshakeInterceptor()
public void setAllowedOrigins(java.util.Collection<java.lang.String> allowedOrigins)
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, java.util.Map<java.lang.String,java.lang.Object> attributes) throws java.lang.Exception
HandshakeInterceptor
beforeHandshake
in interface HandshakeInterceptor
request
- 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
)java.lang.Exception
protected boolean isValidOrigin(ServerHttpRequest request)
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, java.lang.Exception exception)
HandshakeInterceptor
afterHandshake
in interface HandshakeInterceptor
request
- the current requestresponse
- the current responsewsHandler
- the target WebSocket handlerexception
- an exception raised during the handshake, or null
if none