Class OorianWebsocketConfigurator
OorianWebsocketConfigurator intercepts the WebSocket handshake to extract
the HTTP session and store it in the endpoint configuration. This allows
OorianWebsocket to access the user's session data during WebSocket
communication.
When allowed origins are configured via Application.addAllowedOrigin(String),
this configurator validates the Origin header during the handshake and rejects
connections from unauthorized origins to prevent cross-site WebSocket hijacking.
This configurator is referenced in the @ServerEndpoint annotation
on OorianWebsocket.
- Since:
- 2020
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckOrigin(String originHeaderValue) Checks whether the WebSocket handshake origin is allowed.voidmodifyHandshake(jakarta.websocket.server.ServerEndpointConfig conf, jakarta.websocket.server.HandshakeRequest req, jakarta.websocket.HandshakeResponse resp) Modifies the WebSocket handshake to store the HTTP session.Methods inherited from class jakarta.websocket.server.ServerEndpointConfig.Configurator
getContainerDefaultConfigurator, getEndpointInstance, getNegotiatedExtensions, getNegotiatedSubprotocol
-
Constructor Details
-
OorianWebsocketConfigurator
public OorianWebsocketConfigurator()
-
-
Method Details
-
checkOrigin
Checks whether the WebSocket handshake origin is allowed.If origin validation is enabled, examines the
Originheader from the handshake request and rejects the connection if it does not match the configured allowed origins.- Overrides:
checkOriginin classjakarta.websocket.server.ServerEndpointConfig.Configurator- Parameters:
originHeaderValue- the value of the Origin header from the client- Returns:
trueif the origin is allowed,falseto reject
-
modifyHandshake
public void modifyHandshake(jakarta.websocket.server.ServerEndpointConfig conf, jakarta.websocket.server.HandshakeRequest req, jakarta.websocket.HandshakeResponse resp) Modifies the WebSocket handshake to store the HTTP session.Extracts the HTTP session from the handshake request and stores it in the endpoint configuration's user properties under the key "httpsession".
- Overrides:
modifyHandshakein classjakarta.websocket.server.ServerEndpointConfig.Configurator- Parameters:
conf- the server endpoint configurationreq- the handshake requestresp- the handshake response
-