TokenCache Class

Definition

Token cache class used by AuthenticationContext to store access and refresh tokens.

public class TokenCache
Inheritance
TokenCache

Constructors

TokenCache()

Default constructor.

TokenCache(Byte[])

Constructor receiving state of the cache

Properties

AfterAccess

Notification method called after any library method accesses the cache.

BeforeAccess

Notification method called before any library method accesses the cache.

BeforeWrite

Notification method called before any library method writes to the cache. This notification can be used to reload the cache state from a row in database and lock that row. That database row can then be unlocked in AfterAccess notification.

Count

Gets the nunmber of items in the cache.

DefaultShared

Static token cache shared by all instances of AuthenticationContext which do not explicitly pass a cache instance during construction.

HasStateChanged

Gets or sets the flag indicating whether cache state has changed. ADAL methods set this flag after any change. Caller application should reset the flag after serializing and persisting the state of the cache.

Methods

Clear()

Clears the cache by deleting all the items. Note that if the cache is the default shared cache, clearing it would impact all the instances of AuthenticationContext which share that cache.

DeleteItem(TokenCacheItem)

Deletes an item from the cache.

Deserialize(Byte[])

Deserializes state of the cache. The state should be the blob received earlier by calling the method Serialize.

ReadItems()

Reads a copy of the list of all items in the cache.

Serialize()

Serializes current state of the cache as a blob. Caller application can persist the blob and update the state of the cache later by passing that blob back in constructor or by calling method Deserialize.

Extension Methods

IsDefined(Object)
IsNull(Object)
IsPrimitive(Object)