Beispiel #1
0
        public bool TryGetValue(string credentialSpec, out SecretCredential secret)
        {
            if (this.secretCache.TryGetValue(credentialSpec, out var cachedValue))
            {
                var now = this.clock.Get();
                if (now < cachedValue.Expiry - TimeSpan.FromMinutes(5))
                {
                    this.logger.LogInformation($"Found cached token for {credentialSpec}, expires after {cachedValue.Expiry}");
                    secret = cachedValue;
                    return(true);
                }
                else
                {
                    this.logger.LogInformation($"Found cached token for {credentialSpec}, but expired already or near it ({cachedValue.Expiry})");
                    secret = SecretCredential.Empty;
                    return(false);
                }
            }

            secret = SecretCredential.Empty;
            return(false);
        }
Beispiel #2
0
 public void TryAdd(string credentialSpec, SecretCredential newVal)
 {
     this.secretCache.AddOrUpdate(credentialSpec, newVal, (_, _) => newVal);
 }
Beispiel #3
0
 public HomeController(SecretCredential credential)
 {
     this.credential = credential;
 }