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