diff --git a/src/Microsoft.IdentityModel.Tokens/BaseConfigurationManager.cs b/src/Microsoft.IdentityModel.Tokens/BaseConfigurationManager.cs index 999bbc4340..4e0d47cc3d 100644 --- a/src/Microsoft.IdentityModel.Tokens/BaseConfigurationManager.cs +++ b/src/Microsoft.IdentityModel.Tokens/BaseConfigurationManager.cs @@ -23,10 +23,6 @@ public abstract class BaseConfigurationManager private DateTime? _lastKnownGoodConfigFirstUse = null; internal EventBasedLRUCache _lastKnownGoodConfigurationCache; - //private EventBasedLRUCache _lastKnownGoodConfigurationCache = new EventBasedLRUCache(10, TaskCreationOptions.None, new BaseConfigurationComparer(), true, maintainLRU: true); - - private int _lastKnownGoodConfigurationSizeLimit = DefaultLastKnownGoodConfigurationSizeLimit; - private IEqualityComparer _baseConfigurationComparer = new BaseConfigurationComparer(); /// /// Gets or sets the that controls how often an automatic metadata refresh should occur. @@ -43,18 +39,6 @@ public TimeSpan AutomaticRefreshInterval } } - /// - /// Gets or sets the BaseConfgiurationComparer that to compare . - /// - public IEqualityComparer BaseConfigurationComparer - { - get { return _baseConfigurationComparer; } - set - { - _baseConfigurationComparer = value ?? throw LogHelper.LogExceptionMessage(new ArgumentNullException(nameof(value))); - } - } - /// /// 12 hours is the default time interval that afterwards will obtain new configuration. /// @@ -65,11 +49,6 @@ public IEqualityComparer BaseConfigurationComparer /// public static readonly TimeSpan DefaultLastKnownGoodConfigurationLifetime = new TimeSpan(0, 1, 0, 0); - /// - /// 10 is the default size limit of the cache (in number of items) for last known good configuration. - /// - public static readonly int DefaultLastKnownGoodConfigurationSizeLimit = 10; - /// /// 5 minutes is the default time interval that must pass for to obtain a new configuration. /// @@ -114,26 +93,11 @@ public BaseConfiguration LastKnownGoodConfiguration _lastKnownGoodConfiguration = value ?? throw LogHelper.LogArgumentNullException(nameof(value)); _lastKnownGoodConfigFirstUse = DateTime.UtcNow; - if (_lastKnownGoodConfigurationCache == null) - _lastKnownGoodConfigurationCache = new EventBasedLRUCache(LastKnownGoodConfigurationSizeLimit, TaskCreationOptions.None, BaseConfigurationComparer, true, maintainLRU: true); - // LRU cache will remove the expired configuration _lastKnownGoodConfigurationCache.SetValue(_lastKnownGoodConfiguration, DateTime.UtcNow + LastKnownGoodLifetime, DateTime.UtcNow + LastKnownGoodLifetime); } } - /// - /// The size limit of the cache (in number of items) for last known good configuration. - /// - public int LastKnownGoodConfigurationSizeLimit - { - get { return _lastKnownGoodConfigurationSizeLimit; } - set - { - _lastKnownGoodConfigurationSizeLimit = (value > 0) ? value : throw LogHelper.LogExceptionMessage(new ArgumentOutOfRangeException(nameof(value))); - } - } - /// /// The length of time that a last known good configuration is valid for. /// diff --git a/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs b/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs index a4f3110b35..efd0a27a13 100644 --- a/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs +++ b/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.Configuration; using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.TestUtils @@ -32,6 +33,11 @@ public MockConfigurationManager(T configuration) throw LogHelper.LogExceptionMessage(new ArgumentNullException(nameof(configuration))); _configuration = configuration; + _lastKnownGoodConfigurationCache = new EventBasedLRUCache( + LastKnownGoodConfigurationCacheOptions.DefaultLastKnownGoodConfigurationSizeLimit, + TaskCreationOptions.None, + new BaseConfigurationComparer(), + true); } ///