private TokenProvider.TokenInfo GetTokenInfoFromCache(TokenProvider.Key key) { TokenProvider.TokenInfo tokenInfo; TokenProvider.TokenInfo tokenInfo1; lock (this.mutex) { if (!this.CacheTokens) { tokenInfo1 = new TokenProvider.TokenInfo(); } else if (this.tokenCache.TryGetValue(key, out tokenInfo)) { DateTime utcNow = DateTime.UtcNow; if (tokenInfo.WebTokenCacheUntil < utcNow) { tokenInfo.ResetWebToken(); } if (tokenInfo.SecurityTokenCacheUntil < utcNow) { tokenInfo.ResetSecurityToken(); } tokenInfo1 = tokenInfo; } else { tokenInfo = new TokenProvider.TokenInfo(); this.tokenCache.Add(key, tokenInfo); tokenInfo1 = tokenInfo; } } return(tokenInfo1); }
protected GetTokenAsyncResultBase(TokenProvider tokenProvider, string appliesTo, string action, bool bypassCache, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.TokenProvider = tokenProvider; this.cacheKey = this.TokenProvider.BuildKey(appliesTo, action); this.retrySleepTime = this.TokenProvider.retrySleepTime; this.bypassCache = bypassCache; this.AppliesTo = appliesTo; this.Action = action; if (!Uri.TryCreate(appliesTo, UriKind.RelativeOrAbsolute, out this.appliesToUri)) { UriBuilder uriBuilder = new UriBuilder() { Scheme = "sb", Host = appliesTo }; this.appliesToUri = uriBuilder.Uri; } }