com.sun.grizzly.websockets
Class SecKey

java.lang.Object
  extended by com.sun.grizzly.websockets.SecKey

public class SecKey
extends Object

Class represents WebSocket's security key, used during the handshake phase. See Sec-WebSocket-Key1, Sec-WebSocket-Key2.

Author:
Alexey Stashok

Method Summary
static SecKey create(String secKey)
          Create a SecKey object basing on String representation, which includes spaces and chars.
static SecKey generateSecKey()
          Generates random security key.
static byte[] generateServerKey(SecKey clientKey1, SecKey clientKey2, byte[] clientKey3)
          Generate server-side security key, which gets passed to the client during the handshake phase as part of message payload.
 String getSecKey()
          Gets security key string representation, which includes chars and spaces.
 long getSecKeyValue()
          Gets original security key value (already divided by number of spaces).
static void init()
           
 String toString()
           
static SecKey validateSecKey(String key)
          Validate security key, represented as string value (which includes chars and spaces).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static SecKey create(String secKey)
Create a SecKey object basing on String representation, which includes spaces and chars. Method also performs key validation.

Parameters:
secKey - security key string representation with spaces and chars included.
Returns:
SecKey

getSecKey

public String getSecKey()
Gets security key string representation, which includes chars and spaces.

Returns:
Security key string representation, which includes chars and spaces.

getSecKeyValue

public long getSecKeyValue()
Gets original security key value (already divided by number of spaces).

Returns:
original security key value (already divided by number of spaces).

toString

public String toString()
Overrides:
toString in class Object

generateSecKey

public static SecKey generateSecKey()
Generates random security key.

Returns:
SecKey

generateServerKey

public static byte[] generateServerKey(SecKey clientKey1,
                                       SecKey clientKey2,
                                       byte[] clientKey3)
                                throws HandshakeException
Generate server-side security key, which gets passed to the client during the handshake phase as part of message payload.

Parameters:
clientKey1 - client's Sec-WebSocket-Key1
clientKey2 - client's Sec-WebSocket-Key2
clientKey3 - client's key3, which is sent as part of handshake request payload.
Returns:
server key.
Throws:
NoSuchAlgorithmException
HandshakeException

validateSecKey

public static SecKey validateSecKey(String key)
Validate security key, represented as string value (which includes chars and spaces).

Parameters:
key - security key, represented as string value (which includes chars and spaces).
Returns:
validated SecKey

init

public static void init()


Copyright © 2011 Oracle Corpration. All Rights Reserved.