Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SecurityTokenHandler.CreateSecurityTokenReference Method

.NET Framework 4.5

When overridden in a derived class, creates the security token reference for tokens processed by that class. This method is typically called by a security token service (STS).

Namespace:  System.IdentityModel.Tokens
Assembly:  System.IdentityModel (in System.IdentityModel.dll)
public virtual SecurityKeyIdentifierClause CreateSecurityTokenReference(
	SecurityToken token,
	bool attached
)

Parameters

token
Type: System.IdentityModel.Tokens.SecurityToken

The token for which the reference is to be created.

attached
Type: System.Boolean

true if an attached reference should be created; false if an unattached reference should be created.

Return Value

Type: System.IdentityModel.Tokens.SecurityKeyIdentifierClause
A key identifier clause that references the specified token.

By default this method throws a NotImplementedException exception.

Derived classes override this method to return a key identifier clause (SecurityKeyIdentifierClause) that can be used to create a <wsse:SecurityTokenReference> element for the specified token.

Called from implementations of the SecurityTokenService class.

Typically, a SecurityKeyIdentifierClause does not need to be used, other than when a custom security token service is created. When a security token service returns a security token, the issued security token contains references to attached and unattached security tokens. Attached references refer to security tokens that are contained within the security header of a SOAP message and unattached references reference security tokens that are not included within the security header of a SOAP message. These references typically affirm the authenticity of the issued security token.

The following code shows how to override the CreateSecurityTokenReference method to create a key identifier clause from the specified token. The code is taken from the Custom Token sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). For information about this sample and other samples available for WIF and where to download them, see WIF Code Sample Index.

public override SecurityKeyIdentifierClause CreateSecurityTokenReference(SecurityToken token, bool attached)
{
    return token.CreateKeyIdentifierClause<LocalIdKeyIdentifierClause>();           
}

.NET Framework

Supported in: 4.5.1, 4.5

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.