protected virtual void ConfigureServiceAuthentication(X509CertificateRecipientClientCredential service)
		{
			var authentication = service.Authentication;

			if (RevocationMode.HasValue)
				authentication.RevocationMode = RevocationMode.Value;

			if (CertificateValidationMode.HasValue)
				authentication.CertificateValidationMode = CertificateValidationMode.Value;

			if (RemoteCertificateValidator != null)
				authentication.CustomCertificateValidator = RemoteCertificateValidator;

			if (TrustedStoreLocation.HasValue)
				authentication.TrustedStoreLocation = TrustedStoreLocation.Value;

			if (DefaultRemoteCertificate != null)
				service.DefaultCertificate = DefaultRemoteCertificate;

			if (ScopedRemoteCertificates != null)
			{
				foreach (var certificateScope in ScopedRemoteCertificates)
                {
					service.ScopedCertificates.Add(certificateScope.Key, certificateScope.Value);         	
                }
			}
		}
        internal void ApplyConfiguration(X509CertificateRecipientClientCredential cert)
        {
            if (cert == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("cert");
            }

            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
            if (propertyInfo[ConfigurationStrings.Authentication].ValueOrigin != PropertyValueOrigin.Default)
            {
                this.Authentication.ApplyConfiguration(cert.Authentication);
            }

            if (propertyInfo[ConfigurationStrings.SslCertificateAuthentication].ValueOrigin != PropertyValueOrigin.Default)
            {
                cert.SslCertificateAuthentication = new X509ServiceCertificateAuthentication();
                this.SslCertificateAuthentication.ApplyConfiguration(cert.SslCertificateAuthentication);
            }

            this.DefaultCertificate.ApplyConfiguration(cert);

            X509ScopedServiceCertificateElementCollection scopedCertificates = this.ScopedCertificates;
            for (int i = 0; i < scopedCertificates.Count; ++i)
            {
                scopedCertificates[i].ApplyConfiguration(cert);
            }
        }
 internal X509CertificateRecipientClientCredential(X509CertificateRecipientClientCredential other)
 {
     this.authentication = new X509ServiceCertificateAuthentication(other.authentication);
     this.defaultCertificate = other.defaultCertificate;
     this.scopedCertificates = new Dictionary<Uri, X509Certificate2>();
     foreach (Uri uri in other.ScopedCertificates.Keys)
     {
         this.scopedCertificates.Add(uri, other.ScopedCertificates[uri]);
     }
     this.isReadOnly = other.isReadOnly;
 }
 internal void ApplyConfiguration(X509CertificateRecipientClientCredential creds)
 {
     if (creds == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("creds");
     }
     PropertyInformationCollection properties = base.ElementInformation.Properties;
     if (((properties["targetUri"].ValueOrigin != PropertyValueOrigin.Default) || (properties["storeLocation"].ValueOrigin != PropertyValueOrigin.Default)) || (((properties["storeName"].ValueOrigin != PropertyValueOrigin.Default) || (properties["x509FindType"].ValueOrigin != PropertyValueOrigin.Default)) || (properties["findValue"].ValueOrigin != PropertyValueOrigin.Default)))
     {
         creds.SetScopedCertificate(this.StoreLocation, this.StoreName, this.X509FindType, this.FindValue, this.TargetUri);
     }
 }
 internal void ApplyConfiguration(X509CertificateRecipientClientCredential creds)
 {
     if (creds == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("creds");
     }
     PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
     if (propertyInfo[ConfigurationStrings.StoreLocation].ValueOrigin != PropertyValueOrigin.Default
         || propertyInfo[ConfigurationStrings.StoreName].ValueOrigin != PropertyValueOrigin.Default
         || propertyInfo[ConfigurationStrings.X509FindType].ValueOrigin != PropertyValueOrigin.Default
         || propertyInfo[ConfigurationStrings.FindValue].ValueOrigin != PropertyValueOrigin.Default)
     {
         creds.SetDefaultCertificate(this.StoreLocation, this.StoreName, this.X509FindType, this.FindValue);
     }
 }
        internal X509CertificateRecipientClientCredential(X509CertificateRecipientClientCredential other)
        {
            _authentication = new X509ServiceCertificateAuthentication(other._authentication);
            if (other._sslCertificateAuthentication != null)
            {
                _sslCertificateAuthentication = new X509ServiceCertificateAuthentication(other._sslCertificateAuthentication);
            }

            _defaultCertificate = other._defaultCertificate;
            _scopedCertificates = new Dictionary <Uri, X509Certificate2>();
            foreach (Uri uri in other.ScopedCertificates.Keys)
            {
                _scopedCertificates.Add(uri, other.ScopedCertificates[uri]);
            }
            _isReadOnly = other._isReadOnly;
        }
        internal X509CertificateRecipientClientCredential(X509CertificateRecipientClientCredential other)
        {
            _authentication = new X509ServiceCertificateAuthentication(other._authentication);
            if (other._sslCertificateAuthentication != null)
            {
                _sslCertificateAuthentication = new X509ServiceCertificateAuthentication(other._sslCertificateAuthentication);
            }

            _defaultCertificate = other._defaultCertificate;
            _scopedCertificates = new Dictionary<Uri, X509Certificate2>();
            foreach (Uri uri in other.ScopedCertificates.Keys)
            {
                _scopedCertificates.Add(uri, other.ScopedCertificates[uri]);
            }
            _isReadOnly = other._isReadOnly;
        }
 internal void ApplyConfiguration(X509CertificateRecipientClientCredential cert)
 {
     if (cert == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("cert");
     }
     if (base.ElementInformation.Properties["authentication"].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.Authentication.ApplyConfiguration(cert.Authentication);
     }
     this.DefaultCertificate.ApplyConfiguration(cert);
     X509ScopedServiceCertificateElementCollection scopedCertificates = this.ScopedCertificates;
     for (int i = 0; i < scopedCertificates.Count; i++)
     {
         scopedCertificates[i].ApplyConfiguration(cert);
     }
 }
        protected ClientCredentials(ClientCredentials other)
        {
            if (other == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
            if (other.userName != null)
                this.userName = new UserNamePasswordClientCredential(other.userName);
            if (other.clientCertificate != null)
                this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate);
            if (other.serviceCertificate != null)
                this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate);
            if (other.windows != null)
                this.windows = new WindowsClientCredential(other.windows);
            if (other.httpDigest != null)
                this.httpDigest = new HttpDigestClientCredential(other.httpDigest);
            if (other.issuedToken != null)
                this.issuedToken = new IssuedTokenClientCredential(other.issuedToken);
            if (other.peer != null)
                this.peer = new PeerCredential(other.peer);

            this.getInfoCardTokenCallback = other.getInfoCardTokenCallback;
            this.supportInteractive = other.supportInteractive;
            this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager;
            this.useIdentityConfiguration = other.useIdentityConfiguration;
            this.isReadOnly = other.isReadOnly;
        }
Example #10
-1
 protected ClientCredentials(ClientCredentials other)
 {
     if (other == null)
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
     if (other._userName != null)
         _userName = new UserNamePasswordClientCredential(other._userName);
     if (other._clientCertificate != null)
         _clientCertificate = new X509CertificateInitiatorClientCredential(other._clientCertificate);
     if (other._serviceCertificate != null)
         _serviceCertificate = new X509CertificateRecipientClientCredential(other._serviceCertificate);
     if (other._httpDigest != null)
         _httpDigest = new HttpDigestClientCredential(other._httpDigest);
     _isReadOnly = other._isReadOnly;
 }