TokenCacheAccessContext Class

  • java.lang.Object
    • com.microsoft.aad.msal4j.TokenCacheAccessContext

Implements

public class TokenCacheAccessContext
implements ITokenCacheAccessContext

Context in which the token cache is accessed

For more details, see https://aka.ms/msal4j-token-cache

Method Summary

Modifier and Type Method and Description
IAccount account()

Gets the account associated with the current cache access operation, if any.

static TokenCacheAccessContextBuilder builder()
java.lang.String clientId()

Gets the client ID associated with the current cache access operation.

boolean hasCacheChanged()

Indicates whether the cache was modified during this operation.

ITokenCache tokenCache()

Gets the token cache instance being accessed.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

account

public IAccount account()

Gets the account associated with the current cache access operation, if any.

This may be null for operations that are not specific to a user account, such as client credential flow token requests.

builder

public static TokenCacheAccessContext.TokenCacheAccessContextBuilder builder()

clientId

public String clientId()

Gets the client ID associated with the current cache access operation.

This identifies which client application (registered in Azure AD) is performing the cache access. In multi-tenant or multi-client scenarios, applications may want to partition their token cache by client ID.

hasCacheChanged

public boolean hasCacheChanged()

Indicates whether the cache was modified during this operation.

This is particularly useful in the ITokenCacheAccessAspect#afterCacheAccess method to determine whether the cache should be persisted. If no changes were made to the cache, applications can avoid unnecessary write operations.

tokenCache

public ITokenCache tokenCache()

Gets the token cache instance being accessed.

This can be used to read or modify the cache entries during a cache access operation.

Applies to