2 instantiations of CacheableKeyRing
Microsoft.AspNetCore.DataProtection (2)
KeyManagement\Internal\CacheableKeyRing.cs (1)
49return new CacheableKeyRing(CancellationToken.None, now + extension, KeyRing);
KeyManagement\KeyRingProvider.cs (1)
196return new CacheableKeyRing(
72 references to CacheableKeyRing
KeyManagementSimulator (1)
Program.cs (1)
392var keyRing = _cacheableKeyRingProvider.GetCacheableKeyRing(now);
Microsoft.AspNetCore.DataProtection (24)
KeyManagement\Internal\CacheableKeyRing.cs (3)
34internal static bool IsValid([NotNullWhen(true)] CacheableKeyRing? keyRing, DateTime utcNow) 42/// Returns a new <see cref="CacheableKeyRing"/> which is identical to 'this' but with a 46internal CacheableKeyRing WithTemporaryExtendedLifetime(DateTimeOffset now)
KeyManagement\Internal\ICacheableKeyRingProvider.cs (1)
19CacheableKeyRing GetCacheableKeyRing(DateTimeOffset now);
KeyManagement\KeyRingProvider.cs (20)
22private CacheableKeyRing? _cacheableKeyRing; 24private Task<CacheableKeyRing>? _cacheableKeyRingTask; // Also covered by _cacheableKeyRingLockObj 81private CacheableKeyRing CreateCacheableKeyRingCore(DateTimeOffset now, IKey? keyJustAdded) 171private CacheableKeyRing CreateCacheableKeyRingCoreStep2(DateTimeOffset now, CancellationToken cacheExpirationToken, IKey defaultKey, IEnumerable<IKey> allKeys) 231CacheableKeyRing? existingCacheableKeyRing = null; 235if (CacheableKeyRing.IsValid(existingCacheableKeyRing, utcNow)) 257if (CacheableKeyRing.IsValid(existingCacheableKeyRing, utcNow)) 270CacheableKeyRing newCacheableKeyRing; 337var cached = Volatile.Read(ref _cacheableKeyRing); 338if (CacheableKeyRing.IsValid(cached, utcNow)) 344CacheableKeyRing? existingCacheableKeyRing = null; 345Task<CacheableKeyRing>? existingTask = null; 354if (CacheableKeyRing.IsValid(existingCacheableKeyRing, utcNow)) 396Debug.Assert(!CacheableKeyRing.IsValid(existingCacheableKeyRing, utcNow), "Should have returned a valid cached key ring above"); 422var newCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 444private IKeyRing? GetKeyRingFromCompletedTaskUnsynchronized(Task<CacheableKeyRing> task, DateTime utcNow) 459var newCacheableKeyRing = task.GetAwaiter().GetResult(); // Call GetResult to throw on failure 465var existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 466if (existingCacheableKeyRing is not null && !CacheableKeyRing.IsValid(existingCacheableKeyRing, utcNow)) 496CacheableKeyRing ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
Microsoft.AspNetCore.DataProtection.Tests (47)
KeyManagement\CacheableKeyRingTests.cs (8)
14Assert.False(CacheableKeyRing.IsValid(null, DateTime.UtcNow)); 24var cacheableKeyRing = new CacheableKeyRing(cts.Token, now.AddHours(1), keyRing); 27Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now.UtcDateTime)); 29Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now.UtcDateTime)); 39var cacheableKeyRing = new CacheableKeyRing(cts.Token, now.AddHours(1), keyRing); 42Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now.UtcDateTime)); 43Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now.AddHours(1).UtcDateTime)); 51var cacheableKeyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.Now, keyRing);
KeyManagement\KeyRingBasedDataProtectorTests.cs (13)
262var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key }); 293var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key }); 297var keyRing2 = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key2 }); 329var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key }); 333var keyRing2 = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key2 }); 350private CacheableKeyRing _keyRing; 352public TestKeyRingProvider(CacheableKeyRing keys) => _keyRing = keys; 354public CacheableKeyRing GetCacheableKeyRing(DateTimeOffset now) => _keyRing; 359private CacheableKeyRing _keyRing; 360private CacheableKeyRing _refreshKeyRing; 363public RefreshTestKeyRingProvider(CacheableKeyRing keys, CacheableKeyRing refreshKeys) 369public CacheableKeyRing GetCacheableKeyRing(DateTimeOffset now)
KeyManagement\KeyRingProviderTests.cs (26)
44var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 49Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 51Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 87var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 92Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 94Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 135var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 140Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 142Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 144Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 224var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 229Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 231Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 233Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 308var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 313Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 315Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 317Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 348var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 353Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 355Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 386var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 391Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 393Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now)); 509var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now); 555var cacheableKeyRing = keyRingProvider.GetCacheableKeyRing(now);