Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler
A SecurityTokenHandler designed for creating and validating Json Web Tokens.
See: https://datatracker.ietf.org/doc/html/rfc7519 and http://www.rfc-editor.org/info/rfc7515.
Default claim type mapping for inbound claims.
Default value for the flag that determines whether or not the InboundClaimTypeMap is used.
Gets or sets the property name of Properties the will contain the original JSON claim 'name' if a mapping occurred when the Claim(s) were created.
Returns a value that indicates if this handler can validate a SecurityToken.
Gets or sets the InboundClaimTypeMap which is used when setting the Type for claims in the ClaimsPrincipal extracted when validating a JsonWebToken.
The Type is set to the JSON claim 'name' after translating using this mapping.
The default value is ClaimTypeMapping.InboundClaimTypeMap.
Gets or sets the MapInboundClaims property which is used when determining whether or not to map claim types that are extracted when validating a JsonWebToken.
If this is set to true, the Type is set to the JSON claim 'name' after translating using this mapping. Otherwise, no mapping occurs.
The default value is false.
Gets the type of the JsonWebToken.
public JsonWebTokenHandler()
Initializes a new instance of the JsonWebTokenHandler class.
Determines if the string is a well formed JSON Web Token (JWT). See: .
protected virtual ClaimsIdentity CreateClaimsIdentity(JsonWebToken jwtToken, TokenValidationParameters validationParameters)
Creates a ClaimsIdentity from a JsonWebToken.
protected virtual ClaimsIdentity CreateClaimsIdentity(JsonWebToken jwtToken, TokenValidationParameters validationParameters, string issuer)
Creates a ClaimsIdentity from a JsonWebToken with the specified issuer.
Creates an unsigned JSON Web Signature (JWS).
public virtual string CreateToken(string payload, IDictionary<string, object> additionalHeaderClaims)
Creates an unsigned JSON Web Signature (JWS).
Creates a JSON Web Signature (JWS).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, IDictionary<string, object> additionalHeaderClaims)
Creates a JSON Web Signature (JWS).
Creates a JWT that can be a JWS or JWE.
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, EncryptingCredentials encryptingCredentials, IDictionary<string, object> additionalHeaderClaims)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, IDictionary<string, object> additionalHeaderClaims)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, EncryptingCredentials encryptingCredentials, string compressionAlgorithm)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, string compressionAlgorithm)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, string compressionAlgorithm, IDictionary<string, object> additionalHeaderClaims, IDictionary<string, object> additionalInnerHeaderClaims)
Creates a JSON Web Encryption (JWE).
public virtual string CreateToken(string payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, string compressionAlgorithm, IDictionary<string, object> additionalHeaderClaims)
Creates a JSON Web Encryption (JWE).
Decrypts a JWE and returns the clear text.
public Task<string> DecryptTokenWithConfigurationAsync(JsonWebToken jwtToken, TokenValidationParameters validationParameters, CancellationToken cancellationToken)
Decrypts a JWE and returns the clear text.
Encrypts a JWS.
public string EncryptToken(string innerJwt, EncryptingCredentials encryptingCredentials, IDictionary<string, object> additionalHeaderClaims)
Encrypts a JWS.
public string EncryptToken(string innerJwt, EncryptingCredentials encryptingCredentials, string algorithm)
Encrypts a JWS.
public string EncryptToken(string innerJwt, EncryptingCredentials encryptingCredentials, string algorithm, IDictionary<string, object> additionalHeaderClaims)
Encrypts a JWS.
Converts a string into an instance of JsonWebToken.
Converts a ReadOnlyMemory span of characters into an instance of JsonWebToken.
protected virtual SecurityKey ResolveTokenDecryptionKey(string token, JsonWebToken jwtToken, TokenValidationParameters validationParameters)
Returns a SecurityKey to use when decrypting a JWE.
public virtual TokenValidationResult ValidateToken(string token, TokenValidationParameters validationParameters)
Validates a JWS or a JWE.