Share via


JsonWebToken Class

Definition

A SecurityToken designed for representing a JSON Web Token (JWT).

public class JsonWebToken : Microsoft.IdentityModel.Tokens.SecurityToken
type JsonWebToken = class
    inherit SecurityToken
Public Class JsonWebToken
Inherits SecurityToken
Inheritance
JsonWebToken

Constructors

JsonWebToken(ReadOnlyMemory<Char>)

Initializes a new instance of JsonWebToken from a ReadOnlyMemory{char} in JWS or JWE Compact serialized format.

JsonWebToken(String, String)

Initializes a new instance of the JsonWebToken class where the header contains the crypto algorithms applied to the encoded header and payload.

JsonWebToken(String)

Initializes a new instance of JsonWebToken from a string in JWS or JWE Compact serialized format.

Properties

Actor

Gets the 'value' of the 'actort' claim the payload.

Alg

Gets the 'value' of the 'alg' claim from the header.

Audiences

Gets the list of 'aud' claims from the payload.

AuthenticationTag

Gets the AuthenticationTag from the original raw data of this instance when it was created.

Azp

Gets the 'azp' claim from the payload.

Ciphertext

Gets the Ciphertext representing the encrypted JWT in the original raw data.

Claims

Gets a IEnumerable<T> where each claim in the JWT { name, value } is returned as a Claim.

Cty

Gets the 'value' of the 'cty' claim from the header.

Enc

Gets the 'value' of the 'enc' claim from the header.

EncodedHeader

Gets the EncodedHeader from the original raw data of this instance when it was created.

EncodedPayload

Gets the EncodedPayload from the original raw data of this instance when it was created.

EncodedSignature

Gets the EncodedSignature from the original raw data of this instance when it was created.

EncodedToken

Gets the original raw data of this instance when it was created.

EncryptedKey

Gets the Encrypted Content Encryption Key.

Id

Gets the 'value' of the 'jti' claim from the payload.

InitializationVector

Gets the Initialization Vector used when encrypting the plaintext.

InnerToken

Gets the JsonWebToken associated with this instance.

IsEncrypted

Returns true if this JsonWebToken was encrypted a JWE.

IsSigned

Returns true if this JsonWebToken was signed a JWS.

IssuedAt

Gets the 'value' of the 'iat' claim converted to a DateTime from the payload.

Issuer

Gets the 'value' of the 'iss' claim from the payload.

Kid

Gets the 'value' of the 'kid' claim from the header.

SecurityKey

Not implemented.

SigningKey

Gets or sets the SecurityKey that was used to sign this token.

Subject

Gets the 'value' of the 'sub' claim from the payload.

Typ

Gets the 'value' of the 'typ' claim from the header.

ValidFrom

Gets the 'value' of the 'nbf' claim converted to a DateTime from the payload.

ValidTo

Gets the 'value' of the 'exp' claim converted to a DateTime from the payload.

X5t

Gets the 'value' of the 'x5t' claim from the header.

Zip

Gets the 'value' of the 'zip' claim from the header.

Methods

GetClaim(String)

Gets a Claim representing the { key, 'value' } pair corresponding to the provided key.

GetHeaderValue<T>(String)

Gets the 'value' corresponding to key from the JWT header transformed as type 'T'.

GetPayloadValue<T>(String)

Gets the 'value' corresponding to key from the JWT payload transformed as type 'T'.

ToString()

Returns the encoded token without signature or authentication tag.

TryGetClaim(String, Claim)

Try to get a Claim representing the { key, 'value' } pair corresponding to the provided key. The value is obtained from the Payload.

TryGetHeaderValue<T>(String, T)

Tries to get the value corresponding to the provided key from the JWT header { key, 'value' }.

TryGetPayloadValue<T>(String, T)

Try to get the 'value' corresponding to key from the JWT payload transformed as type 'T'.

TryGetValue<T>(String, T)

Tries to get the claim from the JWT payload.

UnsafeToString() System.Object.UnsafeToString

Applies to