Top Description Fields Constructors Methods
io.netty.handler.codec.http.websocketx

pack-priv final Class WebSocketUtil

extends Object
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .Unpooled, io.netty.handler.codec.base64.Base64, io.netty.util.CharsetUtil, io.netty.util.concurrent.FastThreadLocal, io.netty.util.internal.PlatformDependent, .SuppressJava6Requirement, java.security.MessageDigest, .NoSuchAlgorithmException

A utility class mainly for use by web sockets

Field Summary

Modifier and TypeField and Description
private static final FastThreadLocal<MessageDigest>
private static final FastThreadLocal<MessageDigest>

Constructor Summary

AccessConstructor and Description
private
WebSocketUtil()

A private constructor to ensure that instances of this class cannot be made

Method Summary

Modifier and TypeMethod and Description
pack-priv static String

Returns:

An encoded string containing the data
base64
(byte[]
The data to encode
data
)

Performs base64 encoding on the specified data

pack-priv static int
byteAtIndex(int mask, int index)

private static byte[]
digest(FastThreadLocal<MessageDigest> digestFastThreadLocal, byte[] data)

pack-priv static byte[]

Returns:

The hashed data
md5
(byte[]
The data to hash
data
)

Performs a MD5 hash on the specified data

pack-priv static byte[]

Returns:

An array of random bytes
randomBytes
(int
the number of random bytes to create
size
)

Creates an arbitrary number of random bytes

pack-priv static int

Returns:

A pseudo-random number
randomNumber
(int
The minimum allowable value
minimum
,
int
The maximum allowable value
maximum
)

Generates a pseudo-random number

pack-priv static byte[]

Returns:

The hashed data
sha1
(byte[]
The data to hash
data
)

Performs a SHA-1 hash on the specified data

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MD5back to summary
private static final FastThreadLocal<MessageDigest> MD5
SHA1back to summary
private static final FastThreadLocal<MessageDigest> SHA1

Constructor Detail

WebSocketUtilback to summary
private WebSocketUtil()

A private constructor to ensure that instances of this class cannot be made

Method Detail

base64back to summary
pack-priv static String base64(byte[] data)

Performs base64 encoding on the specified data

Parameters
data:byte[]

The data to encode

Returns:String

An encoded string containing the data

Annotations
@SuppressJava6Requirement
reason:Guarded with java version check
byteAtIndexback to summary
pack-priv static int byteAtIndex(int mask, int index)
digestback to summary
private static byte[] digest(FastThreadLocal<MessageDigest> digestFastThreadLocal, byte[] data)
md5back to summary
pack-priv static byte[] md5(byte[] data)

Performs a MD5 hash on the specified data

Parameters
data:byte[]

The data to hash

Returns:byte[]

The hashed data

randomBytesback to summary
pack-priv static byte[] randomBytes(int size)

Creates an arbitrary number of random bytes

Parameters
size:int

the number of random bytes to create

Returns:byte[]

An array of random bytes

randomNumberback to summary
pack-priv static int randomNumber(int minimum, int maximum)

Generates a pseudo-random number

Parameters
minimum:int

The minimum allowable value

maximum:int

The maximum allowable value

Returns:int

A pseudo-random number

sha1back to summary
pack-priv static byte[] sha1(byte[] data)

Performs a SHA-1 hash on the specified data

Parameters
data:byte[]

The data to hash

Returns:byte[]

The hashed data