Saml2SecurityTokenHandler.DetectReplayedToken Method (SecurityToken)

.NET Framework (current version)

Throws an exception if the specified token already exists in the token replay cache; otherwise the token is added to the cache.

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

protected override void DetectReplayedToken(
	SecurityToken token


Type: System.IdentityModel.Tokens.SecurityToken

A SecurityToken that represents the SAML 2.0 security token (the token should be of type Saml2SecurityToken) to be checked.

Exception Condition

token is null.


The Configuration property is null.


There is no TokenReplayCache configured under the Caches property of the handler configuration (accessed through the Configuration property).


token cannot be cast as an instance of Saml2SecurityToken.


The ID of the assertion associated with the token is null or empty. (The Assertion property of the token references a Saml2Assertion that has an Id property that references a Saml2Id with a Value property that is null or empty.)


The token already exists in the TokenReplayCache.

The default behavior is to only check bearer tokens (tokens that do not have keys). The token replay cache is the TokenReplayCache object configured for this handler through the Caches property of the SecurityTokenHandlerConfiguration object referenced through the Configuration property.

.NET Framework
Available since 4.5
Return to top