/// <summary> /// Initializes a new instance of CacheSettings from the specified instance. /// </summary> public CacheSettings(CacheSettings settings) { if (settings != null) { Name = settings.Name; Cache = settings.Cache; NegativeCache = settings.NegativeCache; CacheTTLSeconds = settings.CacheTTLSeconds; } }
/// <summary> /// Creates a new instance using the specified CacheSettings. /// </summary> public PolicyCache(CacheSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } m_settings = new CacheSettings(settings); InitializeCache(); }
/// <summary> /// Create a resolver that resolvers anchors from the middle tier /// </summary> /// <param name="clientSettings">Settings to set up WCF connections to the middle tier</param> /// <param name="cacheSettings">Optional: if caching is enabled. Else null</param> public ConfigAnchorResolver(ClientSettings clientSettings, CacheSettings cacheSettings) { if (clientSettings == null) { throw new ArgumentNullException("clientSettings"); } CacheSettings incomingCacheSettings = new CacheSettings(cacheSettings) { Name = "AnchorCache.incoming" }; CacheSettings outgoingCacheSettings = new CacheSettings(cacheSettings) { Name = "AnchorCache.outgoing" }; m_incomingResolver = new CertificateResolver(new AnchorIndex(clientSettings, true), incomingCacheSettings); m_outgoingResolver = new CertificateResolver(new AnchorIndex(clientSettings, false), outgoingCacheSettings); }
public void CachingDisabledNegativeCacheEnabled() { CacheSettings settings = new CacheSettings() { Cache = false, NegativeCache = true, CacheTTLSeconds = 60, Name = "ABC" }; Assert.Throws(typeof(InvalidOperationException), () => settings.Validate()); Assert.Throws(typeof(InvalidOperationException), () => new CertificateCache(settings)); }
/// <summary> /// Creates a policy resolver that retrieves policies from the email address. /// Policies are resolved against the host portion fo the<see cref="MailAddress"/>. /// </summary> /// <param name="index"> /// An index instance providing <see cref="IPolicyIndex"/> /// </param> /// <param name="cacheSettings"> /// The cache settings to use. Specify null for no caching. /// </param> public PolicyResolver(IPolicyIndex index, CacheSettings cacheSettings) { if (index == null) { throw new ArgumentNullException("index"); } m_policyIndex = index; if (cacheSettings != null && cacheSettings.Cache) { m_policyCache = new PolicyCache(cacheSettings); } }
/// <summary> /// Creates a certificate resolver that retrieves certificates from the given certificate index instance. /// </summary> /// <param name="index"> /// An index instance providing <see cref="IX509CertificateIndex"/> /// </param> /// <param name="cacheSettings"> /// The cache settings to use. Specify null for no caching. /// </param> public CertificateResolver(IX509CertificateIndex index, CacheSettings cacheSettings) { if (index == null) { throw new ArgumentNullException("index"); } m_certIndex = index; if (cacheSettings != null && cacheSettings.Cache) { m_certificateCache = new CertificateCache(cacheSettings); } }
public TrustPolicyResolver(TrustPolicyServiceResolverSettings settings) { ClientSettings settings1 = settings.ClientSettings; var incomingCacheSettings = new CacheSettings(settings.CacheSettings) {Name = "BundleCache.incoming"}; var outgoingCacheSettings = new CacheSettings(settings.CacheSettings) {Name = "BundleCache.outgoing"}; m_incomingResolver = new PolicyResolver(new CertPolicyIndex(settings1, true, CertPolicyUse.TRUST), incomingCacheSettings); m_outgoingResolver = new PolicyResolver(new CertPolicyIndex(settings1, false, CertPolicyUse.TRUST), outgoingCacheSettings); }
/// <summary> /// Tuck away settings and create resolvers. /// </summary> /// <param name="settings"></param> public void Initialize(BundleResolverSettings settings) { m_settings = settings; CacheSettings incomingCacheSettings = new CacheSettings(m_settings.CacheSettings) { Name = "BundleCache.incoming" }; CacheSettings outgoingCacheSettings = new CacheSettings(m_settings.CacheSettings) { Name = "BundleCache.outgoing" }; m_incomingResolver = new CertificateResolver(new BundleAnchorIndex(m_settings, true), incomingCacheSettings); m_outgoingResolver = new CertificateResolver(new BundleAnchorIndex(m_settings, false), outgoingCacheSettings); }
public PublicPolicyResolver(PublicPolicyServiceResolverSettings settings) { PublicPolicyServiceResolverSettings settings1 = settings; CacheSettings incomingCacheSettings = new CacheSettings(settings1.CacheSettings) { Name = "publicPolicy.incoming" }; CacheSettings outgoingCacheSettings = new CacheSettings(settings1.CacheSettings) { Name = "publicPolicy.outgoing" }; m_incomingResolver = new PolicyResolver(new CertPolicyIndex(settings1.ClientSettings, true, CertPolicyUse.PUBLIC_RESOLVER), incomingCacheSettings); m_outgoingResolver = new PolicyResolver(new CertPolicyIndex(settings1.ClientSettings, false, CertPolicyUse.PUBLIC_RESOLVER), outgoingCacheSettings); }
public void TestErrorEventHandler() { ThrowingX509Index throwingIndex = new ThrowingX509Index(); CacheSettings cacheSettings = new CacheSettings(); cacheSettings.Cache = false; List<Exception> notifiedErrors = new List<Exception>(); List<Exception> thrownErrors = new List<Exception>(); // // Test Notifications are fired // CertificateResolver resolver = new CertificateResolver(throwingIndex, cacheSettings); resolver.Error += (r, e) => notifiedErrors.Add(e); MailAddress address = new MailAddress("toby@toby"); this.TryResolveCerts(resolver, address, thrownErrors); Assert.True(notifiedErrors.Count == thrownErrors.Count); // // Test they are NOT fired // int countThrownFiredBefore = thrownErrors.Count; resolver = new CertificateResolver(throwingIndex, cacheSettings); notifiedErrors.Clear(); thrownErrors.Clear(); this.TryResolveCerts(resolver, address, thrownErrors); Assert.True(notifiedErrors.Count == 0); Assert.True(thrownErrors.Count == countThrownFiredBefore); }