private static void AfterAccessNotification(Microsoft.Identity.Client.TokenCacheNotificationArgs TokenCacheNotificationArgs) { if (TokenCacheNotificationArgs.HasStateChanged) { SoftmakeAll.SDK.Fluent.GeneralCacheHelper.WriteBytes(TokenCacheNotificationArgs.TokenCache.SerializeMsalV3()); } }
private static void BeforeAccessNotification(Microsoft.Identity.Client.TokenCacheNotificationArgs TokenCacheNotificationArgs) { try { TokenCacheNotificationArgs.TokenCache.DeserializeMsalV3(SoftmakeAll.SDK.Fluent.GeneralCacheHelper.ReadBytes()); } catch { SoftmakeAll.SDK.Fluent.GeneralCacheHelper.Clear(); TokenCacheNotificationArgs.TokenCache.DeserializeMsalV3(null); } }
private void BeforeAccessHandler( Microsoft.Identity.Client.TokenCacheNotificationArgs args) { lock (fileLock) { try { args.TokenCache.DeserializeMsalV3( System.IO.File.Exists(tokenFilePath) ? System.Security.Cryptography.ProtectedData.Unprotect( System.IO.File.ReadAllBytes(tokenFilePath), null, System.Security.Cryptography.DataProtectionScope.CurrentUser) : null); } catch (Exception ex) { throw ex; } } }
private void AfterAccessHandler( Microsoft.Identity.Client.TokenCacheNotificationArgs args) { if (args.HasStateChanged) { lock (fileLock) { if (System.IO.File.Exists(tokenFilePath)) { System.IO.File.WriteAllBytes( tokenFilePath, System.Security.Cryptography.ProtectedData.Protect( args.TokenCache.SerializeMsalV3(), null, System.Security.Cryptography.DataProtectionScope.CurrentUser)); } else { if (!System.IO.Directory.Exists( System.IO.Path.GetDirectoryName( tokenFilePath))) { System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName( tokenFilePath)); } System.IO.File.WriteAllBytes( tokenFilePath, System.Security.Cryptography.ProtectedData.Protect( args.TokenCache.SerializeMsalV3(), null, System.Security.Cryptography.DataProtectionScope.CurrentUser)); } } } }