File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public static TokenCache GetUserCache()
5454 /// <summary>
5555 /// Path to the token cache
5656 /// </summary>
57- public static string CacheFilePath = System . Reflection . Assembly . GetExecutingAssembly ( ) . Location + "msalcache.txt " ;
57+ public static readonly string CacheFilePath = System . Reflection . Assembly . GetExecutingAssembly ( ) . Location + ". msalcache.bin " ;
5858
5959 private static readonly object FileLock = new object ( ) ;
6060
@@ -63,7 +63,9 @@ public static void BeforeAccessNotification(TokenCacheNotificationArgs args)
6363 lock ( FileLock )
6464 {
6565 args . TokenCache . Deserialize ( File . Exists ( CacheFilePath )
66- ? File . ReadAllBytes ( CacheFilePath )
66+ ? ProtectedData . Unprotect ( File . ReadAllBytes ( CacheFilePath ) ,
67+ null ,
68+ DataProtectionScope . CurrentUser )
6769 : null ) ;
6870 }
6971 }
@@ -76,7 +78,11 @@ public static void AfterAccessNotification(TokenCacheNotificationArgs args)
7678 lock ( FileLock )
7779 {
7880 // reflect changesgs in the persistent store
79- File . WriteAllBytes ( CacheFilePath , args . TokenCache . Serialize ( ) ) ;
81+ File . WriteAllBytes ( CacheFilePath ,
82+ ProtectedData . Protect ( args . TokenCache . Serialize ( ) ,
83+ null ,
84+ DataProtectionScope . CurrentUser )
85+ ) ;
8086 // once the write operationtakes place restore the HasStateChanged bit to filse
8187 args . TokenCache . HasStateChanged = false ;
8288 }
You can’t perform that action at this time.
0 commit comments