Share via


SecurityToken.Id 屬性

定義

取得安全性權杖的唯一識別碼。

public:
 abstract property System::String ^ Id { System::String ^ get(); };
public abstract string Id { get; }
member this.Id : string
Public MustOverride ReadOnly Property Id As String

屬性值

安全性權杖的唯一識別碼。

範例

主題中使用的 SecurityToken 程式代碼範例取自 Custom Token 範例。 此範例提供自定義類別,可讓您處理簡單 Web 令牌 (SWT) 。 它包含類別和SimpleWebTokenHandler類別的實作SimpleWebToken,以及支援 SWT 令牌的其他類別。 如需此範例和其他可供 WIF 使用之範例以及下載位置的相關信息,請參閱 WIF 程式代碼範例索引。 下列程式代碼顯示 屬性的 Id 覆寫。

/// <summary>
/// Defines the set of constants for the Simple Web Token.
/// </summary>
public static class SimpleWebTokenConstants
{
    public const string Audience = "Audience";
    public const string ExpiresOn = "ExpiresOn";
    public const string Id = "Id";
    public const string Issuer = "Issuer";
    public const string Signature = "HMACSHA256";
    public const string ValidFrom = "ValidFrom";
    public const string ValueTypeUri = "http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0";     
}
public static DateTime SwtBaseTime = new DateTime( 1970, 1, 1, 0, 0, 0, 0 ); // per SWT psec

NameValueCollection _properties;
/// <summary>
/// Gets the Id of the token.
/// </summary>
/// <value>The Id of the token.</value>
public override string Id
{
    get 
    {
        return _properties[SimpleWebTokenConstants.Id];
    }
}

備註

一般來說,當安全性權杖已序列化為 XML 時,安全性權杖的 Id 屬性 (Attribute) 就會設定為 Id 屬性 (Property) 的值。

給實施者的注意事項

您必須覆寫 Id 屬性。

適用於