ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNet.Token.AuthToken Class Reference

Implements the IAuthToken interface for encoding, decoding, and verifying authentication tokens. More...

Inheritance diagram for XmobiTea.ProtonNet.Token.AuthToken:
XmobiTea.ProtonNet.Token.IAuthToken

Public Member Functions

 AuthToken ()
 Initializes a new instance of the AuthToken class.
 
void SetBinaryConverter (TokenBinaryType binaryType, IBinaryConverter binaryConverter)
 Sets the binary converter for the specified binary type.
 
string Encode< T > (T payload, string key, TokenOptions options=null)
 Encodes the specified payload into a token.
 
void Decode< T > (string token, out ITokenHeader header, out T payload)
 Decodes the specified token into a header and payload.
 
void Verify< T > (string token, string key, out ITokenHeader header, out T payload)
 Verifies the specified token using the provided key and outputs the header and payload.
 
- Public Member Functions inherited from XmobiTea.ProtonNet.Token.IAuthToken

Protected Member Functions

byte[] ReadBytes (Stream stream, int length)
 Reads a specified number of bytes from a stream.
 

Detailed Description

Implements the IAuthToken interface for encoding, decoding, and verifying authentication tokens.

Member Function Documentation

◆ Decode< T >()

void XmobiTea.ProtonNet.Token.AuthToken.Decode< T > ( string token,
out ITokenHeader header,
out T payload )

Decodes the specified token into a header and payload.

Template Parameters
TThe type of the payload.
Parameters
tokenThe token to decode.
headerOutputs the token header.
payloadOutputs the token payload.
Exceptions
TokenStringInvalidExceptionThrown if the token is invalid.

Implements XmobiTea.ProtonNet.Token.IAuthToken.

Type Constraints
T :ITokenPayload 

◆ Encode< T >()

string XmobiTea.ProtonNet.Token.AuthToken.Encode< T > ( T payload,
string key,
TokenOptions options = null )

Encodes the specified payload into a token.

Template Parameters
TThe type of the payload.
Parameters
payloadThe payload to encode.
keyThe key used for signing the token.
optionsOptional encoding options.
Returns
The encoded token as a string.

Implements XmobiTea.ProtonNet.Token.IAuthToken.

Type Constraints
T :ITokenPayload 

◆ ReadBytes()

byte[] XmobiTea.ProtonNet.Token.AuthToken.ReadBytes ( Stream stream,
int length )
protected

Reads a specified number of bytes from a stream.

Parameters
streamThe stream to read from.
lengthThe number of bytes to read.
Returns
A byte array containing the data read from the stream.

◆ SetBinaryConverter()

void XmobiTea.ProtonNet.Token.AuthToken.SetBinaryConverter ( TokenBinaryType binaryType,
IBinaryConverter binaryConverter )

Sets the binary converter for the specified binary type.

Parameters
binaryTypeThe binary type.
binaryConverterThe binary converter.

◆ Verify< T >()

void XmobiTea.ProtonNet.Token.AuthToken.Verify< T > ( string token,
string key,
out ITokenHeader header,
out T payload )

Verifies the specified token using the provided key and outputs the header and payload.

Template Parameters
TThe type of the payload.
Parameters
tokenThe token to verify.
keyThe key used for verification.
headerOutputs the verified token header.
payloadOutputs the verified token payload.
Exceptions
TokenSignatureInvalidExceptionThrown if the token signature is invalid.
TokenExpiredExceptionThrown if the token has expired.

Implements XmobiTea.ProtonNet.Token.IAuthToken.

Type Constraints
T :ITokenPayload 

The documentation for this class was generated from the following file: