private void InitializeNonceCounterSweeper() { _nonceCounterSweeper = new Timer(s => { DateTime utcStaleTimestamp = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)); var staledEntries = NonceCounter.Where(pair => pair.Value.Arg1 <= utcStaleTimestamp).ToList(); foreach (var staledEntry in staledEntries) { TesterDoer.IgnoreResult <string, Template <DateTime, string>, bool>(NonceCounter.TryRemove, staledEntry.Key); } }, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2)); }
/// <summary> /// Initializes a new instance of the <see cref="DigestAccessAuthenticationMiddleware"/> class. /// </summary> /// <param name="next">The delegate of the request pipeline to invoke.</param> /// <param name="setup">The middleware <see cref="DigestAccessAuthenticationOptions"/> which need to be configured.</param> public DigestAccessAuthenticationMiddleware(RequestDelegate next, Action <DigestAccessAuthenticationOptions> setup) : base(next, setup) { _nonceCounterSweeper = new Timer(s => { DateTime utcStaleTimestamp = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)); var staledEntries = NonceCounter.Where(pair => pair.Value.Arg1 <= utcStaleTimestamp).ToList(); foreach (var staledEntry in staledEntries) { TesterDoer.IgnoreResult <string, Template <DateTime, string>, bool>(NonceCounter.TryRemove, staledEntry.Key); } }, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2)); }