Share via


SecurityToken.SecurityKeys 属性

定义

获取与安全令牌相关联的加密密钥。

public:
 abstract property System::Collections::ObjectModel::ReadOnlyCollection<System::IdentityModel::Tokens::SecurityKey ^> ^ SecurityKeys { System::Collections::ObjectModel::ReadOnlyCollection<System::IdentityModel::Tokens::SecurityKey ^> ^ get(); };
public abstract System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Tokens.SecurityKey> SecurityKeys { get; }
member this.SecurityKeys : System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Tokens.SecurityKey>
Public MustOverride ReadOnly Property SecurityKeys As ReadOnlyCollection(Of SecurityKey)

属性值

一个类型为 ReadOnlyCollection<T>SecurityKey,包含与安全令牌相关联的密钥集。

示例

主题中使用的 SecurityToken 代码示例取自示例 Custom Token 。 此示例提供自定义类,这些类支持处理简单 Web 令牌 (SWT) 。 它包括类和SimpleWebTokenHandler类的实现SimpleWebToken,以及其他支持 SWT 令牌的类。 有关此示例和可用于 WIF 的其他示例以及下载位置的信息,请参阅 WIF 代码示例索引。 以下代码显示了 属性的 SecurityKeys 替代。

/// <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 keys associated with this token.
/// </summary>
/// <value>The keys associated with this token.</value>
public override ReadOnlyCollection<SecurityKey> SecurityKeys
{
    get 
    { 
        return new ReadOnlyCollection<SecurityKey>( new List<SecurityKey>() ); 
    }
}

注解

SecurityKeys使用 属性设置此安全令牌的加密密钥,以保护令牌或 SOAP 消息。 密钥可用于对令牌或 SOAP 消息进行数字签名或加密。

实施者说明

必须重写 SecurityKeys 属性。

适用于