/// <summary> /// Notification that is triggered after token acquisition. /// </summary> /// <param name="args">Arguments related to the cache item impacted</param> public override void AfterAccessNotification(TokenCacheNotificationArgs args) { MsalCacheHelper cacheStorage = GetMsalCacheStorage(); args.AssertNotNull(nameof(args)); try { if (args.HasStateChanged) { cacheStorage.SaveUnencryptedTokenCache(args.TokenCache.SerializeMsalV3()); } } catch (Exception) { cacheStorage.Clear(); throw; } finally { CrossPlatformLock localDispose = cacheLock; cacheLock = null; localDispose?.Dispose(); } }
/// <summary> /// Notification that is triggered before token acquisition. /// </summary> /// <param name="args">Arguments related to the cache item impacted</param> public override void BeforeAccessNotification(TokenCacheNotificationArgs args) { MsalCacheHelper cacheStorage = GetMsalCacheHelper(); args.AssertNotNull(nameof(args)); try { args.TokenCache.DeserializeMsalV3(cacheStorage.LoadUnencryptedTokenCache()); } catch (Exception) { cacheStorage.Clear(); throw; } }
/// <summary> /// Notification that is triggered before token acquisition. /// </summary> /// <param name="args">Arguments related to the cache item impacted</param> public override void BeforeAccessNotification(TokenCacheNotificationArgs args) { MsalCacheHelper cacheStorage = GetMsalCacheStorage(); args.AssertNotNull(nameof(args)); try { cacheLock = new CrossPlatformLock($"{CacheFilePath}.lockfile"); cacheLock.CreateLockAsync().ConfigureAwait(false); args.TokenCache.DeserializeMsalV3(cacheStorage.LoadUnencryptedTokenCache()); } catch (Exception) { cacheStorage.Clear(); throw; } }
/// <summary> /// Notification that is triggered after token acquisition. /// </summary> /// <param name="args">Arguments related to the cache item impacted</param> public override void AfterAccessNotification(TokenCacheNotificationArgs args) { MsalCacheHelper cacheHelper = GetMsalCacheHelper(); args.AssertNotNull(nameof(args)); try { if (args.HasStateChanged) { cacheHelper.SaveUnencryptedTokenCache(args.TokenCache.SerializeMsalV3()); } } catch (Exception) { cacheHelper.Clear(); throw; } }
/// <summary> /// Clears the token store. /// </summary> public virtual void Clear() { _helper.Clear(); }