Export (0) Print
Expand All

SecurityToken.Id Property

Gets a unique identifier of the security token.

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

Public MustOverride ReadOnly Property Id As String

Property Value

Type: System.String
The unique identifier of the security token.

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.

Notes to Inheritors

You must override the Id 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 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
        return _properties[SimpleWebTokenConstants.Id];

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft