SecurityToken.Id 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取安全令牌的唯一标识符。
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 安全令牌的属性将设置为该属性的值 Id 。
实施者说明
必须重写该 Id 属性。