コード例 #1
0
ファイル: TokenUtils.cs プロジェクト: suwatch/CSMClient
        public static async Task <AuthenticationResult> GetRecentToken()
        {
            var recentTokenFile = GetRecentTokenFile();
            var authResult      = AuthenticationResult.Deserialize(ProtectedFile.ReadAllText(recentTokenFile));

            if (!String.IsNullOrEmpty(authResult.RefreshToken) && authResult.ExpiresOn <= DateTime.UtcNow)
            {
                var tokenCache = TokenCache.GetCache();
                authResult = await GetAuthorizationResult(tokenCache, authResult.TenantId, authResult.UserInfo.UserId);

                TokenCache.SaveCache(tokenCache);
                SaveRecentToken(authResult);
            }

            return(authResult);
        }
コード例 #2
0
ファイル: TenantCache.cs プロジェクト: suwatch/CSMClient
        public static Dictionary <string, TenantCacheInfo> GetCache()
        {
            var file = GetCacheFile();

            if (!File.Exists(file))
            {
                return(new Dictionary <string, TenantCacheInfo>());
            }

            return(JsonConvert.DeserializeObject <Dictionary <string, TenantCacheInfo> >(ProtectedFile.ReadAllText(file)));
        }
コード例 #3
0
ファイル: TokenCache.cs プロジェクト: suwatch/CSMClient
        public static Dictionary <TokenCacheKey, string> GetCache()
        {
            var file = GetCacheFile();

            if (!File.Exists(file))
            {
                return(new Dictionary <TokenCacheKey, string>());
            }

            var dict = JsonConvert.DeserializeObject <Dictionary <string, TokenCacheKey> >(ProtectedFile.ReadAllText(file));

            return(dict.ToDictionary(p => p.Value, p => p.Key));
        }