示例#1
0
 /// <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;
     }
 }
示例#2
0
        /// <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(); 
        }
示例#3
0
        /// <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);
        }
示例#4
0
        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)); 
        }
示例#5
0
        /// <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); 
            }
        }
示例#6
0
        /// <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); 
            }
        }
示例#7
0
        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);
        }
示例#8
0
        /// <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);
        }
示例#9
0
        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);
        
        }
示例#10
0
 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);
 }