語言

JwtSecurityTokenHandler.CreateEncodedJwt 方法

定義

多載

CreateEncodedJwt(SecurityTokenDescriptor)

回傳一個 json 網頁標記(JWT)。

public virtual string CreateEncodedJwt(Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor);
abstract member CreateEncodedJwt : Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor -> string
override this.CreateEncodedJwt : Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor -> string
Public Overridable Function CreateEncodedJwt (tokenDescriptor As SecurityTokenDescriptor) As String

參數

tokenDescriptor
SecurityTokenDescriptor

SecurityTokenDescriptor A 包含代幣內容的詳細資訊。

傳回

備註

JWS和JWE可以退回。

若 EncryptingCredentials提供,則會建立一個 JWE。

若 SigningCredentials 提供,則會建立一個JWS。

若兩者皆提供,則會建立一個內嵌 JWS 的 JWE。

適用於

CreateEncodedJwt(String, String, ClaimsIdentity, Nullable<DateTime>, Nullable<DateTime>, Nullable<DateTime>, SigningCredentials)

建立一個「緊湊序列化格式」的 JWT。

public virtual string CreateEncodedJwt(string issuer, string audience, System.Security.Claims.ClaimsIdentity subject, DateTime? notBefore, DateTime? expires, DateTime? issuedAt, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials);
abstract member CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials -> string
override this.CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials -> string
Public Overridable Function CreateEncodedJwt (issuer As String, audience As String, subject As ClaimsIdentity, notBefore As Nullable(Of DateTime), expires As Nullable(Of DateTime), issuedAt As Nullable(Of DateTime), signingCredentials As SigningCredentials) As String

參數

issuer
String

令牌的發行者。

audience
String

這個代幣的受眾。

subject
ClaimsIdentity

這個標記的 Claim來源。

notBefore
Nullable<DateTime>

這個代幣的非官方時機。

expires
Nullable<DateTime>

這個代幣的有效期限。

issuedAt
Nullable<DateTime>

這個代幣的發行時間到了。

signingCredentials
SigningCredentials

包含用於產生簽名的密碼學材料。

傳回

一個 Base64UrlEncoded 的「緊湊序列化格式」字串。

備註

若 Actor 非空,則會加入 claim { actort, 'value' } 於有效載荷中。 請參閱 CreateActorValue(ClaimsIdentity) 有關價值如何創造的詳細資訊。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtHeader”></參見,> 了解標頭參數如何被加入標頭。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtPayload”></另> 見,了解如何加入有效載荷的細節。

每個 在 subject 中 的映射Claim都是透過應用 OutboundClaimTypeMap來映射Type的。 修改 OutboundClaimTypeMap 可能會改變出站的 JWT。

若 SigningCredentials 提供,則會建立一個 JWS。

適用於

CreateEncodedJwt(String, String, ClaimsIdentity, Nullable<DateTime>, Nullable<DateTime>, Nullable<DateTime>, SigningCredentials, EncryptingCredentials)

建立一個「緊湊序列化格式」的 JWT。

public virtual string CreateEncodedJwt(string issuer, string audience, System.Security.Claims.ClaimsIdentity subject, DateTime? notBefore, DateTime? expires, DateTime? issuedAt, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials);
abstract member CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
override this.CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
Public Overridable Function CreateEncodedJwt (issuer As String, audience As String, subject As ClaimsIdentity, notBefore As Nullable(Of DateTime), expires As Nullable(Of DateTime), issuedAt As Nullable(Of DateTime), signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials) As String

參數

issuer
String

令牌的發行者。

audience
String

這個代幣的受眾。

subject
ClaimsIdentity

這個標記的 Claim來源。

notBefore
Nullable<DateTime>

翻譯成「時代」並歸入「nbf」。

expires
Nullable<DateTime>

翻譯成「紀元時間」並被分配到「經驗值」。

issuedAt
Nullable<DateTime>

翻譯成「紀元時間」並歸入「iat」。

signingCredentials
SigningCredentials

包含用於簽署的密碼資料。

encryptingCredentials
EncryptingCredentials

包含用於加密的密碼資料。

傳回

一個 Base64UrlEncoded 的「緊湊序列化格式」字串。

例外狀況

如果「過期」 <=「非之前」。

備註

若 Actor 非空,則會加入 claim { actort, 'value' } 於有效載荷中。 CreateActorValue(ClaimsIdentity) 關於價值如何產生的詳細資訊。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtHeader”></參見,> 了解標頭參數如何被加入標頭。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtPayload”></另> 見,了解如何加入有效載荷的細節。

每個 在 subject 中 的映射Claim都是透過應用 OutboundClaimTypeMap來映射Type的。 修改 OutboundClaimTypeMap 可能會改變出站的 JWT。

適用於

CreateEncodedJwt(String, String, ClaimsIdentity, Nullable<DateTime>, Nullable<DateTime>, Nullable<DateTime>, SigningCredentials, EncryptingCredentials, IDictionary<String,Object>)

建立一個「緊湊序列化格式」的 JWT。

public virtual string CreateEncodedJwt(string issuer, string audience, System.Security.Claims.ClaimsIdentity subject, DateTime? notBefore, DateTime? expires, DateTime? issuedAt, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, System.Collections.Generic.IDictionary<string,object> claimCollection);
abstract member CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateEncodedJwt : string * string * System.Security.Claims.ClaimsIdentity * Nullable<DateTime> * Nullable<DateTime> * Nullable<DateTime> * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateEncodedJwt (issuer As String, audience As String, subject As ClaimsIdentity, notBefore As Nullable(Of DateTime), expires As Nullable(Of DateTime), issuedAt As Nullable(Of DateTime), signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials, claimCollection As IDictionary(Of String, Object)) As String

參數

issuer
String

令牌的發行者。

audience
String

這個代幣的受眾。

subject
ClaimsIdentity

這個標記的 Claim來源。

notBefore
Nullable<DateTime>

翻譯成「時代」並歸入「nbf」。

expires
Nullable<DateTime>

翻譯成「紀元時間」並被分配到「經驗值」。

issuedAt
Nullable<DateTime>

翻譯成「紀元時間」並歸入「iat」。

signingCredentials
SigningCredentials

包含用於簽署的密碼資料。

encryptingCredentials
EncryptingCredentials

包含用於加密的密碼資料。

claimCollection
IDictionary<String,Object>

一組代表 Claim此標記(s)的(key, value)對。

傳回

一個 Base64UrlEncoded 的「緊湊序列化格式」字串。

例外狀況

如果「過期」 <=「非之前」。

備註

若 Actor 非空,則會加入 claim { actort, 'value' } 於有效載荷中。 CreateActorValue(ClaimsIdentity) 關於價值如何產生的詳細資訊。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtHeader”></參見,> 了解標頭參數如何被加入標頭。

另見 <cref=“T:System.IdentityModel.Tokens.Jwt.JwtPayload”></另> 見,了解如何加入有效載荷的細節。

每個 在 subject 中 的映射Claim都是透過應用 OutboundClaimTypeMap來映射Type的。 修改 OutboundClaimTypeMap 可能會改變出站的 JWT。

適用於