Top Description Fields Constructors Methods
org.glassfish.tyrus.core

pack-priv Class SecKey

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, java.security.MessageDigest, .NoSuchAlgorithmException, .SecureRandom, java.util.Base64, .Random, org.glassfish.tyrus.core.l10n.LocalizationMessages, org.glassfish.tyrus.spi.UpgradeRequest

Class represents security key, used during the handshake phase.
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
private static final int
private static final Random
private final String
secKey

Security key string representation, which includes chars and spaces.

Constructor Summary

AccessConstructor and Description
public
public
SecKey(String
sec key to be represented as SecKey instance.
base64
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private String
public static SecKey

Returns:

server key.
generateServerKey
(SecKey
client's Sec-WebSocket-Key
clientKey
)

Generate server-side security key, which gets passed to the client during the handshake phase as part of message payload.

public String

Returns:

Security key string representation, which includes chars and spaces.
getSecKey
()

Gets security key string representation, which includes chars and spaces.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
validateServerKey(String
server key to be validated.
serverKey
)

Validate provided server key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

KEY_SIZEback to summary
private static final int KEY_SIZE
randomback to summary
private static final Random random
secKeyback to summary
private final String secKey

Security key string representation, which includes chars and spaces.

Constructor Detail

SecKeyback to summary
public SecKey()
SecKeyback to summary
public SecKey(String base64) throws HandshakeException

Constructor.

Parameters
base64:String

sec key to be represented as SecKey instance.

Exceptions
HandshakeException:
when the provided key is null.

Method Detail

createback to summary
private String create()
generateServerKeyback to summary
public static SecKey generateServerKey(SecKey clientKey) throws HandshakeException

Generate server-side security key, which gets passed to the client during the handshake phase as part of message payload.

Parameters
clientKey:SecKey

client's Sec-WebSocket-Key

Returns:SecKey

server key.

getSecKeyback to summary
public String getSecKey()

Gets security key string representation, which includes chars and spaces.

Returns:String

Security key string representation, which includes chars and spaces.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
validateServerKeyback to summary
public void validateServerKey(String serverKey) throws HandshakeException

Validate provided server key.

Parameters
serverKey:String

server key to be validated.

Exceptions
HandshakeException:
when the server key is invalid.