Class JwtEncoder
- Namespace
- JWT
- Assembly
- Coherence.JWT.dll
Encodes Jwt.
public sealed class JwtEncoder : IJwtEncoder
- Inheritance
-
JwtEncoder
- Implements
- Extension Methods
Constructors
JwtEncoder(IAlgorithmFactory, IJsonSerializer, IBase64UrlEncoder)
Creates an instance of JwtEncoder
public JwtEncoder(IAlgorithmFactory algFactory, IJsonSerializer jsonSerializer, IBase64UrlEncoder urlEncoder)
Parameters
algFactory
IAlgorithmFactoryThe JWT algorithm factory
jsonSerializer
IJsonSerializerThe JSON serializer
urlEncoder
IBase64UrlEncoderThe base64 URL encoder
JwtEncoder(IJwtAlgorithm, IJsonSerializer, IBase64UrlEncoder)
Creates an instance of JwtEncoder
public JwtEncoder(IJwtAlgorithm algorithm, IJsonSerializer jsonSerializer, IBase64UrlEncoder urlEncoder)
Parameters
algorithm
IJwtAlgorithmThe JWT algorithm
jsonSerializer
IJsonSerializerThe JSON serializer
urlEncoder
IBase64UrlEncoderThe base64 URL encoder
Methods
Encode(IDictionary<string, object>, object, byte[])
Creates a JWT given a header, a payload, the signing key, and the algorithm to use.
public string Encode(IDictionary<string, object> extraHeaders, object payload, byte[] key)
Parameters
extraHeaders
IDictionary<string, object>An arbitrary set of extra headers. Will be augmented with the standard "typ" and "alg" headers
payload
objectAn arbitrary payload (must be serializable to JSON)
key
byte[]The key bytes used to sign the token
Returns
- string
The generated JWT