public void TestCollectionRetryAlways()
        {
            CertificateResolverCollection resolvers = new CertificateResolverCollection();

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Always;

            resolvers.Add(new ThrowingCertResolver());
            resolvers.Add(m_resolver);

            Assert.DoesNotThrow(() => resolvers.GetCertificates(m_address));
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());

            resolvers.Insert(0, new NullResolver());
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
        }
        /// <summary>
        /// Creates the DNS certificate resolver from the configured settings.
        /// </summary>
        /// <returns>A configured DNS certificate resolver.</returns>
        public override ICertificateResolver CreateResolver()
        {
            this.Validate();

            if (string.IsNullOrEmpty(this.BackupServerIP))
            {
                return(CreateResolver(this.ServerIP));
            }

            CertificateResolverCollection resolvers = new CertificateResolverCollection();

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            resolvers.Add(this.CreateResolver(this.ServerIP));
            resolvers.Add(this.CreateResolver(this.BackupServerIP));
            return(resolvers);
        }
        public void TestCollectionRetryException()
        {
            CertificateResolverCollection resolvers = new CertificateResolverCollection();

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;

            resolvers.Add(new NullResolver());
            resolvers.Add(m_resolver);
            Assert.True(resolvers.GetCertificates(m_address).IsNullOrEmpty());

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.NotFound;
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());

            resolvers.Clear();

            resolvers.Add(new ThrowingCertResolver());
            resolvers.Add(m_resolver);
            Assert.Throws <InvalidOperationException>(() => resolvers.GetCertificates(m_address));

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
        }
        /// <summary>
        /// Creates the maachine store based certificate resolver.
        /// </summary>
        /// <returns>An instance of a machine-based certificate store resolver.</returns>
        public override ICertificateResolver CreateResolver()
        {
            Validate();

            if (string.IsNullOrEmpty(ServerIP) && string.IsNullOrEmpty(BackupServerIP))
            {
                return(new LdapCertResolver(null,
                                            TimeSpan.FromMilliseconds(TimeoutMilliseconds)
                                            , m_cache));
            }

            if (string.IsNullOrEmpty(BackupServerIP))
            {
                return(CreateResolver(ServerIP));
            }

            CertificateResolverCollection resolvers = new CertificateResolverCollection();

            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            resolvers.Add(this.CreateResolver(this.ServerIP));
            resolvers.Add(this.CreateResolver(this.BackupServerIP));
            return(resolvers);
        }
Exemple #5
0
 /// <summary>
 /// Create a resolver as defined in the Resolvers setting
 /// </summary>
 /// <returns>The certificate resolver instance corresponding to the settings.</returns>
 public ICertificateResolver CreateResolver()
 {
     if (this.Resolvers == null)
     {
         throw new NotSupportedException();
     }
     
     CertificateResolverCollection resolvers = new CertificateResolverCollection();
     foreach (CertResolverSettings resolverSettings in this.Resolvers)
     {
         resolvers.Add(resolverSettings.CreateResolver());
     }
     
     return resolvers;
 }
        /// <summary>
        /// Create a resolver as defined in the Resolvers setting
        /// </summary>
        /// <returns>The certificate resolver instance corresponding to the settings.</returns>
        public ICertificateResolver CreateResolver()
        {
            if (this.Resolvers == null)
            {
                throw new NotSupportedException();
            }

            CertificateResolverCollection resolvers = new CertificateResolverCollection();

            foreach (CertResolverSettings resolverSettings in this.Resolvers)
            {
                resolvers.Add(resolverSettings.CreateResolver());
            }

            return(resolvers);
        }
 /// <summary>
 /// Creates the DNS certificate resolver from the configured settings.
 /// </summary>
 /// <returns>A configured DNS certificate resolver.</returns>
 public override ICertificateResolver CreateResolver()
 {
     this.Validate();
     
     if (string.IsNullOrEmpty(this.BackupServerIP))
     {
         return CreateResolver(this.ServerIP);
     }
     
     CertificateResolverCollection resolvers = new CertificateResolverCollection();
     resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;            
     resolvers.Add(this.CreateResolver(this.ServerIP));
     resolvers.Add(this.CreateResolver(this.BackupServerIP));            
     return resolvers;
 }
        /// <summary>
        /// Creates the maachine store based certificate resolver.
        /// </summary>
        /// <returns>An instance of a machine-based certificate store resolver.</returns>
        public override ICertificateResolver CreateResolver()
        {
            Validate();

            if (string.IsNullOrEmpty(ServerIP) && string.IsNullOrEmpty(BackupServerIP))
            {
                return new LdapCertResolver(null,
                                        TimeSpan.FromMilliseconds(TimeoutMilliseconds)
                                        , m_cache);
            }

            if (string.IsNullOrEmpty(BackupServerIP))
            {
                return CreateResolver(ServerIP);
            }

            CertificateResolverCollection resolvers = new CertificateResolverCollection();
            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            resolvers.Add(this.CreateResolver(this.ServerIP));
            resolvers.Add(this.CreateResolver(this.BackupServerIP));
            return resolvers;
            
        }
Exemple #9
0
        public void TestCollectionRetryAlways()
        {
            CertificateResolverCollection resolvers = new CertificateResolverCollection();
            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Always;
            
            resolvers.Add(new ThrowingCertResolver());
            resolvers.Add(m_resolver);

            Assert.DoesNotThrow(() => resolvers.GetCertificates(m_address));
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
            
            resolvers.Insert(0, new NullResolver());
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
        }
Exemple #10
0
        public void TestCollectionRetryException()
        {
            CertificateResolverCollection resolvers = new CertificateResolverCollection();
            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            
            resolvers.Add(new NullResolver());
            resolvers.Add(m_resolver);
            Assert.True(resolvers.GetCertificates(m_address).IsNullOrEmpty());
            
            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.NotFound;
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
            
            resolvers.Clear();

            resolvers.Add(new ThrowingCertResolver());
            resolvers.Add(m_resolver);
            Assert.Throws<InvalidOperationException>(() => resolvers.GetCertificates(m_address));
            
            resolvers.TryNextWhen = CertificateResolverCollection.TryNextCriteria.Exception;
            Assert.True(!resolvers.GetCertificates(m_address).IsNullOrEmpty());
        }