Class AcceptToken
java.lang.Object
org.simpleframework.http.socket.service.AcceptToken
The
AcceptToken
is used to create a unique token based
on a random key sent by the client. This is used to prove that the
handshake was received, the server has to take two pieces of
information and combine them to form a response. The first piece
of information comes from the Sec-WebSocket-Key
header
field in the client handshake, the second is the globally unique
identifier 258EAFA5-E914-47DA-95CA-C5AB0DC85B11
. Both
are concatenated and an SHA-1 has is generated and used in the
session initiating response.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
This is the character encoding to decode the key with.private final MessageDigest
This is used to generate the SHA-1 has from the user key.private static final byte[]
This is the globally unique identifier used in the handshake.private final Request
This is the original request used to initiate the session. -
Constructor Summary
ConstructorsConstructorDescriptionAcceptToken
(Request request) Constructor for theAcceptToken
object.AcceptToken
(Request request, String algorithm) Constructor for theAcceptToken
object.AcceptToken
(Request request, String algorithm, String charset) Constructor for theAcceptToken
object. -
Method Summary
-
Field Details
-
MAGIC
private static final byte[] MAGICThis is the globally unique identifier used in the handshake. -
digest
This is used to generate the SHA-1 has from the user key. -
request
This is the original request used to initiate the session. -
charset
This is the character encoding to decode the key with.
-
-
Constructor Details
-
AcceptToken
Constructor for theAcceptToken
object. This is to create an object that can generate a token from the client key available from theSec-WebSocket-Key
header.- Parameters:
request
- this is the session initiating request- Throws:
Exception
-
AcceptToken
Constructor for theAcceptToken
object. This is to create an object that can generate a token from the client key available from theSec-WebSocket-Key
header.- Parameters:
request
- this is the session initiating requestalgorithm
- the algorithm used to create the token- Throws:
Exception
-
AcceptToken
Constructor for theAcceptToken
object. This is to create an object that can generate a token from the client key available from theSec-WebSocket-Key
header.- Parameters:
request
- this is the session initiating requestalgorithm
- the algorithm used to create the tokencharset
- the encoding used to decode the client key- Throws:
Exception
-
-
Method Details
-
create
This is used to create the required accept token for the session initiating response. The resulting token is a SHA-1 digest of theSec-WebSocket-Key
a globally unique identifier defined in RFC 6455 all encoded in base64.- Returns:
- the accept token for the session initiating response
- Throws:
IOException
-