Beispiel #1
0
        static IAzureTokenCache InitializeTokenCache(IDataStore store, string cacheDirectory, string cacheFile, string autoSaveMode)
        {
            IAzureTokenCache result = new AuthenticationStoreTokenCache(new AzureTokenCache());

            if (autoSaveMode == ContextSaveMode.CurrentUser)
            {
                try
                {
                    FileUtilities.DataStore = store;
                    FileUtilities.EnsureDirectoryExists(cacheDirectory);
                    var cachePath = Path.Combine(cacheDirectory, cacheFile);
                    result = new ProtectedFileTokenCache(cachePath, store);
                }
                catch
                {
                }
            }

            return(result);
        }
        static IAzureTokenCache InitializeTokenCache(IDataStore store, string cacheDirectory, string cacheFile, string autoSaveMode)
        {
            IAzureTokenCache result = new AuthenticationStoreTokenCache(new AzureTokenCache());

            if (autoSaveMode == ContextSaveMode.CurrentUser)
            {
                try
                {
                    FileUtilities.DataStore = store;
                    FileUtilities.EnsureDirectoryExists(cacheDirectory);
                    var cachePath = Path.Combine(cacheDirectory, cacheFile);
                    result = new ProtectedFileTokenCache(cachePath, store);
                }
                catch (Exception ex)
                {
                    TracingAdapter.Information("[AzureSessionInitializer]: Cannot initialize token cache in 'CurrentUser' mode. Falling back to 'Process' mode.");
                    TracingAdapter.Information($"[AzureSessionInitializer]: Message: {ex.Message}; Stacktrace: {ex.StackTrace}");
                }
            }

            return(result);
        }