Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SecurityToken::SecurityKeys Property

 

Gets the cryptographic keys associated with the security token.

Namespace:   System.IdentityModel.Tokens
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

public:
property ReadOnlyCollection<SecurityKey^>^ SecurityKeys {
	virtual ReadOnlyCollection<SecurityKey^>^ get() abstract;
}

Property Value

Type: System.Collections.ObjectModel::ReadOnlyCollection<SecurityKey^>^

A ReadOnlyCollection<T> of type SecurityKey that contains the set of keys associated with the security token.

Use the SecurityKeys property to set the cryptographic keys for this security token to protect tokens or a SOAP message. The keys can be used, among other things, to digitally sign or encrypt either tokens or SOAP messages.

Notes to Inheritors:

You must override the SecurityKeys property.

The code examples that are used in the SecurityToken topics are taken from the Custom Token sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a SimpleWebToken class and a SimpleWebTokenHandler class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see WIF Code Sample Index. The following code shows the override of the SecurityKeys 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 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>() ); 
    }
}

.NET Framework
Available since 3.0
Return to top
Show:
© 2017 Microsoft