Partager via


JwtSecurityToken Class

Definition

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

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

Constructors

JwtSecurityToken(JwtHeader, JwtPayload, String, String, String)

Initializes a new instance of the JwtSecurityToken class where the JwtHeader contains the crypto algorithms applied to the encoded JwtHeader and JwtPayload. The jwtEncodedString is the result of those operations.

JwtSecurityToken(JwtHeader, JwtPayload)

Initializes a new instance of the JwtSecurityToken class where the JwtHeader contains the crypto algorithms applied to the encoded JwtHeader and JwtPayload. The jwtEncodedString is the result of those operations.

JwtSecurityToken(JwtHeader, JwtSecurityToken, String, String, String, String, String)

Initializes an instance of JwtSecurityToken where the JwtHeader contains the crypto algorithms applied to the innerToken JwtSecurityToken.

JwtSecurityToken(String, String, IEnumerable<Claim>, Nullable<DateTime>, Nullable<DateTime>, SigningCredentials)

Initializes a new instance of the JwtSecurityToken class specifying optional parameters.

JwtSecurityToken(String)

Initializes a new instance of JwtSecurityToken from a string in JWS Compact serialized format.

Properties

Actor

Gets the 'value' of the 'actor' claim { actort, 'value' }.

Audiences

Gets the list of 'audience' claim { aud, 'value' }.

Claims

Gets the Claim(s) for this token. If this is a JWE token, this property only returns the encrypted claims; the unencrypted claims should be read from the header seperately.

EncodedHeader

Gets the Base64UrlEncoded JwtHeader associated with this instance.

EncodedPayload

Gets the Base64UrlEncoded JwtPayload associated with this instance.

EncryptingCredentials

Gets the EncryptingCredentials to use when writing this token.

Header

Gets the JwtHeader associated with this instance if the token is signed.

Id

Gets the 'value' of the 'JWT ID' claim { jti, 'value' }.

InnerToken

Gets the JwtSecurityToken associated with this instance.

IssuedAt

Gets the 'value' of the 'issued at' claim { iat, 'value' } converted to a DateTime assuming 'value' is seconds since UnixEpoch (UTC 1970-01-01T0:0:0Z).

Issuer

Gets the 'value' of the 'issuer' claim { iss, 'value' }.

Payload

Gets the JwtPayload associated with this instance. Note that if this JWT is nested ( InnerToken != null, this property represents the payload of the most inner token. This property can be null if the content type of the most inner token is unrecognized, in that case the content of the token is the string returned by PlainText property.

RawAuthenticationTag

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

RawCiphertext

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

RawData

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

RawEncryptedKey

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

RawHeader

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

RawInitializationVector

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

RawPayload

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

RawSignature

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

SecurityKey

Gets the SecurityKeys for this instance.

SignatureAlgorithm

Gets the signature algorithm associated with this instance.

SigningCredentials

Gets the SigningCredentials to use when writing this token.

SigningKey

Gets or sets the SecurityKey that signed this instance.

Subject

Gets the "value" of the 'subject' claim { sub, 'value' }.

ValidFrom

Gets the 'value' of the 'notbefore' claim { nbf, 'value' } converted to a DateTime assuming 'value' is seconds since UnixEpoch (UTC 1970-01-01T0:0:0Z).

ValidTo

Gets the 'value' of the 'expiration' claim { exp, 'value' } converted to a DateTime assuming 'value' is seconds since UnixEpoch (UTC 1970-01-01T0:0:0Z).

Methods

ToString()

Serializes the JwtHeader and JwtPayload

UnsafeToString()

Returns a string that represents the complete security artifact. This may include sensitive information and should only be used for debugging purposes.

Applies to