Class Handshake

java.lang.Object
io.undertow.websockets.handshake.Handshake

public class Handshake extends Object
Abstract base class for doing a WebSocket Handshake.
Author:
Mike Brock
  • Field Details

    • MAGIC_NUMBER

      public static final String MAGIC_NUMBER
      See Also:
    • SHA1

      public static final String SHA1
      See Also:
    • subprotocols

      protected final Set<String> subprotocols
    • availableExtensions

      protected Set<io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandshaker> availableExtensions
    • allowExtensions

      protected boolean allowExtensions
  • Constructor Details

  • Method Details

    • getConfig

      public ConfiguredServerEndpoint getConfig()
    • getWebSocketLocation

      protected static String getWebSocketLocation(WebSocketHttpExchange exchange)
      Return the full url of the websocket location of the given WebSocketHttpExchange
    • handshake

      public final void handshake(WebSocketHttpExchange exchange, Consumer<io.netty.channel.ChannelHandlerContext> completeListener)
      Issue the WebSocket upgrade
      Parameters:
      exchange - The WebSocketHttpExchange for which the handshake and upgrade should occur.
    • handshakeInternal

      protected void handshakeInternal(WebSocketHttpExchange exchange)
    • performUpgrade

      protected final void performUpgrade(WebSocketHttpExchange exchange)
      convenience method to perform the upgrade
    • selectSubprotocol

      protected final void selectSubprotocol(WebSocketHttpExchange exchange)
      Selects the first matching supported sub protocol and add it the the headers of the exchange.
    • addExtension

      public final void addExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandshaker extension)
      Add a new WebSocket Extension handshake to the list of available extensions.
      Parameters:
      extension - a new ExtensionHandshake
    • initExtensions

      protected final List<io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtension> initExtensions(WebSocketHttpExchange exchange)
      Create the ExtensionFunction list associated with the negotiated extensions defined in the exchange's response.
      Parameters:
      exchange - the exchange used to retrieve negotiated extensions
      Returns:
      a list of ExtensionFunction with the implementation of the extensions
    • supportedSubprotols

      protected String supportedSubprotols(String[] requestedSubprotocolArray)
    • selectedExtension

      protected List<io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtension> selectedExtension(List<io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData> extensionList)
    • matches

      public boolean matches(WebSocketHttpExchange exchange)
    • solve

      protected final String solve(String nonceBase64) throws NoSuchAlgorithmException
      Throws:
      NoSuchAlgorithmException