다음을 통해 공유


JwtSecurityToken Constructors

Definition

Overloads

JwtSecurityToken(String)

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

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, 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(String, String, IEnumerable<Claim>, Nullable<DateTime>, Nullable<DateTime>, SigningCredentials)

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

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)

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

public JwtSecurityToken (string jwtEncodedString);
new System.IdentityModel.Tokens.Jwt.JwtSecurityToken : string -> System.IdentityModel.Tokens.Jwt.JwtSecurityToken
Public Sub New (jwtEncodedString As String)

Parameters

jwtEncodedString
String

A JSON Web Token that has been serialized in JWS Compact serialized format.

Exceptions

'jwtEncodedString' is not in JWS Compact serialized format.

'jwtEncodedString' is null or contains only whitespace.

'jwtEncodedString' is not in JWS or JWE format.

Remarks

The contents of this JwtSecurityToken have not been validated, the JSON Web Token is simply decoded. Validation can be accomplished using ValidateToken(String, TokenValidationParameters, SecurityToken)

Applies to

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.

public JwtSecurityToken (System.IdentityModel.Tokens.Jwt.JwtHeader header, System.IdentityModel.Tokens.Jwt.JwtPayload payload);
new System.IdentityModel.Tokens.Jwt.JwtSecurityToken : System.IdentityModel.Tokens.Jwt.JwtHeader * System.IdentityModel.Tokens.Jwt.JwtPayload -> System.IdentityModel.Tokens.Jwt.JwtSecurityToken
Public Sub New (header As JwtHeader, payload As JwtPayload)

Parameters

header
JwtHeader

Contains JSON objects representing the cryptographic operations applied to the JWT and optionally any additional properties of the JWT

payload
JwtPayload

Contains JSON objects representing the claims contained in the JWT. Each claim is a JSON object of the form { Name, Value }

Exceptions

'payload' is null.

Applies to

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.

public JwtSecurityToken (System.IdentityModel.Tokens.Jwt.JwtHeader header, System.IdentityModel.Tokens.Jwt.JwtPayload payload, string rawHeader, string rawPayload, string rawSignature);
new System.IdentityModel.Tokens.Jwt.JwtSecurityToken : System.IdentityModel.Tokens.Jwt.JwtHeader * System.IdentityModel.Tokens.Jwt.JwtPayload * string * string * string -> System.IdentityModel.Tokens.Jwt.JwtSecurityToken
Public Sub New (header As JwtHeader, payload As JwtPayload, rawHeader As String, rawPayload As String, rawSignature As String)

Parameters

header
JwtHeader

Contains JSON objects representing the cryptographic operations applied to the JWT and optionally any additional properties of the JWT

payload
JwtPayload

Contains JSON objects representing the claims contained in the JWT. Each claim is a JSON object of the form { Name, Value }

rawHeader
String

base64urlencoded JwtHeader

rawPayload
String

base64urlencoded JwtPayload

rawSignature
String

base64urlencoded JwtSignature

Exceptions

'rawSignature' is null.

'rawHeader' or 'rawPayload' is null or whitespace.

Applies to

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

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

public JwtSecurityToken (string issuer = default, string audience = default, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims = default, DateTime? notBefore = default, DateTime? expires = default, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials = default);
new System.IdentityModel.Tokens.Jwt.JwtSecurityToken : string * string * seq<System.Security.Claims.Claim> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials -> System.IdentityModel.Tokens.Jwt.JwtSecurityToken
Public Sub New (Optional issuer As String = Nothing, Optional audience As String = Nothing, Optional claims As IEnumerable(Of Claim) = Nothing, Optional notBefore As Nullable(Of DateTime) = Nothing, Optional expires As Nullable(Of DateTime) = Nothing, Optional signingCredentials As SigningCredentials = Nothing)

Parameters

issuer
String

If this value is not null, a { iss, 'issuer' } claim will be added, overwriting any 'iss' claim in 'claims' if present.

audience
String

If this value is not null, a { aud, 'audience' } claim will be added, appending to any 'aud' claims in 'claims' if present.

claims
IEnumerable<Claim>

If this value is not null then for each Claim a { 'Claim.Type', 'Claim.Value' } is added. If duplicate claims are found then a { 'Claim.Type', List<object> } will be created to contain the duplicate values.

notBefore
Nullable<DateTime>

If notbefore.HasValue a { nbf, 'value' } claim is added, overwriting any 'nbf' claim in 'claims' if present.

expires
Nullable<DateTime>

If expires.HasValue a { exp, 'value' } claim is added, overwriting any 'exp' claim in 'claims' if present.

signingCredentials
SigningCredentials

The SigningCredentials that will be used to sign the JwtSecurityToken. See JwtHeader(SigningCredentials) for details pertaining to the Header Parameter(s).

Exceptions

If 'expires' <= 'notbefore'.

Applies to

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.

public JwtSecurityToken (System.IdentityModel.Tokens.Jwt.JwtHeader header, System.IdentityModel.Tokens.Jwt.JwtSecurityToken innerToken, string rawHeader, string rawEncryptedKey, string rawInitializationVector, string rawCiphertext, string rawAuthenticationTag);
new System.IdentityModel.Tokens.Jwt.JwtSecurityToken : System.IdentityModel.Tokens.Jwt.JwtHeader * System.IdentityModel.Tokens.Jwt.JwtSecurityToken * string * string * string * string * string -> System.IdentityModel.Tokens.Jwt.JwtSecurityToken
Public Sub New (header As JwtHeader, innerToken As JwtSecurityToken, rawHeader As String, rawEncryptedKey As String, rawInitializationVector As String, rawCiphertext As String, rawAuthenticationTag As String)

Parameters

header
JwtHeader

Defines cryptographic operations applied to the 'innerToken'.

innerToken
JwtSecurityToken
rawHeader
String

base64urlencoded JwtHeader

rawEncryptedKey
String

base64urlencoded key

rawInitializationVector
String

base64urlencoded initialization vector.

rawCiphertext
String

base64urlencoded encrypted innerToken

rawAuthenticationTag
String

base64urlencoded authentication tag.

Exceptions

'rawAuthenticationTag' is null or empty.

Applies to