예제 #1
0
 // Initializes the cache against a local file.
 // If the file is already present, it loads its content in the ADAL cache
 public SettingsFileTokenCache(ISettingsFile settingsFile)
 {
     _settingsFile = settingsFile;
     AfterAccess   = AfterAccessNotification;
     BeforeAccess  = BeforeAccessNotification;
     Deserialize(_settingsFile.ReadAllBytes());
 }
예제 #2
0
        public byte[] ReadAllBytes()
        {
            var bytes = _file.ReadAllBytes();

            if (bytes != null)
            {
                return(ProtectedData.Unprotect(bytes, null, DataProtectionScope.CurrentUser));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
 // Triggered right before ADAL needs to access the cache.
 // Reload the cache from the persistent store in case it changed since the last access.
 private void BeforeAccessNotification(TokenCacheNotificationArgs args)
 {
     Deserialize(_settingsFile.ReadAllBytes());
 }