Class AcceptToken
- java.lang.Object
-
- org.simpleframework.http.socket.service.AcceptToken
-
class AcceptToken extends java.lang.Object
TheAcceptToken
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 theSec-WebSocket-Key
header field in the client handshake, the second is the globally unique identifier258EAFA5-E914-47DA-95CA-C5AB0DC85B11
. Both are concatenated and an SHA-1 has is generated and used in the session initiating response.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
charset
This is the character encoding to decode the key with.private java.security.MessageDigest
digest
This is used to generate the SHA-1 has from the user key.private static byte[]
MAGIC
This is the globally unique identifier used in the handshake.private Request
request
This is the original request used to initiate the session.
-
Constructor Summary
Constructors Constructor Description AcceptToken(Request request)
Constructor for theAcceptToken
object.AcceptToken(Request request, java.lang.String algorithm)
Constructor for theAcceptToken
object.AcceptToken(Request request, java.lang.String algorithm, java.lang.String charset)
Constructor for theAcceptToken
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
create()
This is used to create the required accept token for the session initiating response.
-
-
-
Field Detail
-
MAGIC
private static final byte[] MAGIC
This is the globally unique identifier used in the handshake.
-
digest
private final java.security.MessageDigest digest
This is used to generate the SHA-1 has from the user key.
-
request
private final Request request
This is the original request used to initiate the session.
-
charset
private final java.lang.String charset
This is the character encoding to decode the key with.
-
-
Constructor Detail
-
AcceptToken
public AcceptToken(Request request) throws java.lang.Exception
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:
java.lang.Exception
-
AcceptToken
public AcceptToken(Request request, java.lang.String algorithm) throws java.lang.Exception
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:
java.lang.Exception
-
AcceptToken
public AcceptToken(Request request, java.lang.String algorithm, java.lang.String charset) throws java.lang.Exception
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:
java.lang.Exception
-
-
Method Detail
-
create
public java.lang.String create() throws java.io.IOException
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:
java.io.IOException
-
-