コード例 #1
0
        /// <summary>
        /// Returns a selected certificate based on configuration.
        /// </summary>
        /// <param name="certificateSubject">The subject serial number of the certificate</param>
        /// <returns>Returns a selected certificate based on configuration.</returns>
        public X509Certificate2 GetCertificate(CertificateSubject certificateSubject)
        {
            CertificateLoader certificateLoader = new CertificateLoader();

            switch (_config.Action)
            {
            case LdapCertificateLookupTestConfig.LookupAction.FindCertificate:
                // 1. Attempt to load the certificate from store:
                return(certificateLoader.GetCertificateFromStoreWithSSN(
                           certificateSubject.SerialNumberValue,
                           _config.StoreLocation,
                           _config.StoreName
                           ));

            case LdapCertificateLookupTestConfig.LookupAction.ConnectionFailed:
                LdapSettings settings = ConfigurationHandler.GetConfigurationSection <LdapSettings>();
                throw new ConnectingToLdapServerFailedException(settings, new Exception(this.ToString()));

            case LdapCertificateLookupTestConfig.LookupAction.SearchFailed:
                throw new SearchFailedException(new Exception(this.ToString()));

            default:
                throw new NotImplementedException();
            }
        }
コード例 #2
0
        private static Dictionary <string, string> CreateKeywords(LdapSettings settings)
        {
            Dictionary <string, string> keywords = new Dictionary <string, string>();

            keywords.Add("address", settings.Host.ToString());
            keywords.Add("port", settings.Port.ToString());
            return(keywords);
        }
コード例 #3
0
 /// <summary>
 /// Constructor that takes the settings used for the connection and the cause
 /// exception. It transforms the setting object into a keyword dictionary before
 /// calling its base constructor with the dictionary and inner exception as
 /// parameters.
 /// </summary>
 /// <param name="settings">The settings used when attempting connection</param>
 /// <param name="innerException">The cause exception</param>
 public ConnectingToLdapServerFailedException(LdapSettings settings, System.Exception innerException) : base(CreateKeywords(settings), innerException)
 {
 }
コード例 #4
0
 /// <summary>
 /// The LdapCertificateLookup constructor takes an ldap settings object
 /// as a paramter. The setting object is used everytime a lookup is done
 /// in the GetCertificate function.
 /// </summary>
 /// <param name="settings">Setting object that contains the ldap settings to be used.</param>
 public LdapCertificateLookup(LdapSettings settings)
 {
     _settings             = settings;
     this.certiticateCache = this.CreateCache();
 }