Class AcceptHash

java.lang.Object
org.eclipse.jetty.websocket.common.AcceptHash

public class AcceptHash extends Object
Logic for working with the Sec-WebSocket-Key and Sec-WebSocket-Accept headers.

This is kept separate from Connection objects to facilitate difference in behavior between client and server, as well as making testing easier.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final byte[]
    Globally Unique Identifier for use in WebSocket handshake within Sec-WebSocket-Accept and Sec-WebSocket-Key http headers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Concatenate the provided key with the Magic GUID and return the Base64 encoded form.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAGIC

      private static final byte[] MAGIC
      Globally Unique Identifier for use in WebSocket handshake within Sec-WebSocket-Accept and Sec-WebSocket-Key http headers.

      See Opening Handshake (Section 1.3)

  • Constructor Details

    • AcceptHash

      public AcceptHash()
  • Method Details

    • hashKey

      public static String hashKey(String key)
      Concatenate the provided key with the Magic GUID and return the Base64 encoded form.
      Parameters:
      key - the key to hash
      Returns:
      the Sec-WebSocket-Accept header response (per opening handshake spec)