SecurityToken.Id 属性

定义

获取安全令牌的唯一标识符。Gets a unique identifier of the security token.

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

属性值

String

安全令牌的唯一标识符。The unique identifier of the security token.

示例

本主题中使用的代码示例 SecurityToken 摘自 Custom Token 示例。The code examples that are used in the SecurityToken topics are taken from the Custom Token sample. 此示例提供了自定义类,这些类可用于处理简单 Web 标记 (SWT) 。This sample provides custom classes that enable processing of Simple Web Tokens (SWT). 它包含 SimpleWebToken 类和 SimpleWebTokenHandler 类以及支持 SWT 标记的其他类的实现。It includes an implementation of a SimpleWebToken class and a SimpleWebTokenHandler class, as well as other classes that support SWT tokens. 有关此示例和可供 WIF 使用的其他示例的信息,请参阅 WIF 代码示例索引For information about this sample and other samples available for WIF and about where to download them, see WIF Code Sample Index. 下面的代码演示了属性的重写 IdThe following code shows the override of the Id property.

/// <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) 的值。Typically, when a security token is serialized into XML, the Id attribute for the security token is set to the value of the Id property.

实施者说明

必须重写 Id 属性。You must override the Id property.

适用于