ITokenCacheAccessAspect Interface
public interface ITokenCacheAccessAspect
Interface representing operation of executing code before and after cache access.
This interface enables applications to hook into the token cache access operations, allowing for serialization and persistence of the token cache. Implementing this interface allows applications to load the cache state from persistent storage before MSAL accesses it, and save changes back to persistent storage after MSAL modifies it.
For more details, see https://aka.ms/msal4j-token-cache
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| abstract void |
afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
Executes after the token cache is accessed by MSAL. |
| abstract void |
beforeCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
Executes before the token cache is accessed by MSAL. |
Method Details
afterCacheAccess
public abstract void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
Executes after the token cache is accessed by MSAL.
This method is called by MSAL immediately after it accesses (and potentially modifies) the token cache. Applications should use this method to persist the current state of the cache to storage if changes were made. The hasCacheChanged() method can be used to determine if the cache was modified during the operation.
Parameters:
beforeCacheAccess
public abstract void beforeCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
Executes before the token cache is accessed by MSAL.
This method is called by MSAL immediately before it accesses the token cache. Applications should use this method to load the current cache state from persistent storage and update the in-memory cache by calling tokenCache(). This ensures MSAL has access to all previously cached tokens.
Parameters: