Table of Contents

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 IAlgorithmFactory

The JWT algorithm factory

jsonSerializer IJsonSerializer

The JSON serializer

urlEncoder IBase64UrlEncoder

The base64 URL encoder

JwtEncoder(IJwtAlgorithm, IJsonSerializer, IBase64UrlEncoder)

Creates an instance of JwtEncoder

public JwtEncoder(IJwtAlgorithm algorithm, IJsonSerializer jsonSerializer, IBase64UrlEncoder urlEncoder)

Parameters

algorithm IJwtAlgorithm

The JWT algorithm

jsonSerializer IJsonSerializer

The JSON serializer

urlEncoder IBase64UrlEncoder

The 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 object

An arbitrary payload (must be serializable to JSON)

key byte[]

The key bytes used to sign the token

Returns

string

The generated JWT

Exceptions

ArgumentNullException