/// <summary>
        /// Dependency Injection aware constructor; uses the instance of <see cref="IX509StoreWrapper" />
        /// </summary>
        /// <example>
        /// var storeWrapper = new X509StoreWrapper();
        /// var certificateRepo = new CertificateRepository(storeWrapper);
        /// </example>
        /// <remarks>
        /// This constructor should only be used if you need control over the <see cref="IX509StoreWrapper" /> 
        /// </remarks>
        /// <param name="storeWrapper">Instance of <see cref="IX509StoreWrapper" /></param>
        /// <param name="thumbprintValidator">Validator that implements <see cref="IValidator" /> and asserts that a thumbprint is valid.</param>
        /// <exception cref="ArgumentNullException">Thrown in the event that <paramref name="storeWrapper"/> or <paramref name="thumbprintValidator"/> is null.</exception>
        public CertificateRepository(IX509StoreWrapper storeWrapper, IValidator<string> thumbprintValidator) {
            if (storeWrapper == null) {
                throw new ArgumentNullException("storeWrapper");
            }

            if (thumbprintValidator == null) {
                throw new ArgumentNullException("thumbprintValidator");
            }

            _storeWrapper = storeWrapper;
            _thumbprintValidator = thumbprintValidator;
        }
예제 #2
0
        public GatewayKeyProvider(
            [NotNull] string authenticationCertificateFingerprint = null,
            [NotNull] string signingCertificateFingerprint        = null,
            [NotNull] IX509StoreWrapper x509StoreWrapper          = null,
            [NotNull] ISha256Wrapper sha256Wrapper                               = null,
            [NotNull] IBitConverterWrapper bitConverterWrapper                   = null,
            [NotNull] IPrivateKeyFactoryWrapper privateKeyFactoryWrapper         = null,
            [NotNull] IX509CertificateParserWrapper x509CertificateParserWrapper = null
            )
        {
            _x509StoreWrapper         = x509StoreWrapper ?? new IX509StoreWrapper.X509StoreWrapper();
            _sha256Wrapper            = sha256Wrapper ?? new ISha256Wrapper.Sha256WrapperWrapper();
            _bitConverterWrapper      = bitConverterWrapper ?? new IBitConverterWrapper.BitConverterWrapperWrapper();
            _privateKeyFactoryWrapper = privateKeyFactoryWrapper ?? new IPrivateKeyFactoryWrapper.PrivateKeyFactoryWrapperWrapper();
            _x509CertificateParser    = x509CertificateParserWrapper ?? new IX509CertificateParserWrapper.X509CertificateParserWrapper();

            if (authenticationCertificateFingerprint != null && signingCertificateFingerprint != null)
            {
                LoadCertificates(authenticationCertificateFingerprint, signingCertificateFingerprint);
            }
        }