Class WebSocketServerProtocolConfig


  • public final class WebSocketServerProtocolConfig
    extends java.lang.Object
    WebSocket server configuration.

    Security note: By default no validation of the Origin header is performed during the handshake. Browsers do not apply the same-origin policy to WebSocket connections and send ambient credentials (like cookies) with the handshake request, so applications that authenticate WebSocket connections using such credentials are exposed to Cross-Site WebSocket Hijacking unless they validate the Origin header. Such applications must configure WebSocketServerProtocolConfig.Builder.allowedOrigins(String...) (or perform an equivalent check in a handler placed before WebSocketServerProtocolHandler).

    • Field Detail

      • DEFAULT_HANDSHAKE_TIMEOUT_MILLIS

        static final long DEFAULT_HANDSHAKE_TIMEOUT_MILLIS
        See Also:
        Constant Field Values
      • DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS

        static final long DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS
        See Also:
        Constant Field Values
      • websocketPath

        private final java.lang.String websocketPath
      • subprotocols

        private final java.lang.String subprotocols
      • checkStartsWith

        private final boolean checkStartsWith
      • handshakeTimeoutMillis

        private final long handshakeTimeoutMillis
      • forceCloseTimeoutMillis

        private final long forceCloseTimeoutMillis
      • handleCloseFrames

        private final boolean handleCloseFrames
      • dropPongFrames

        private final boolean dropPongFrames
      • allowedOrigins

        private final java.util.Set<java.lang.String> allowedOrigins
    • Constructor Detail

      • WebSocketServerProtocolConfig

        private WebSocketServerProtocolConfig​(java.lang.String websocketPath,
                                              java.lang.String subprotocols,
                                              boolean checkStartsWith,
                                              long handshakeTimeoutMillis,
                                              long forceCloseTimeoutMillis,
                                              boolean handleCloseFrames,
                                              WebSocketCloseStatus sendCloseFrame,
                                              boolean dropPongFrames,
                                              WebSocketDecoderConfig decoderConfig,
                                              java.util.Set<java.lang.String> allowedOrigins)
    • Method Detail

      • websocketPath

        public java.lang.String websocketPath()
      • subprotocols

        public java.lang.String subprotocols()
      • checkStartsWith

        public boolean checkStartsWith()
      • handshakeTimeoutMillis

        public long handshakeTimeoutMillis()
      • forceCloseTimeoutMillis

        public long forceCloseTimeoutMillis()
      • handleCloseFrames

        public boolean handleCloseFrames()
      • dropPongFrames

        public boolean dropPongFrames()
      • allowedOrigins

        public java.util.Set<java.lang.String> allowedOrigins()
        Returns the (lower-cased) origins that are allowed to open a WebSocket connection, or an empty set if the Origin header is not validated.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object