示例#1
0
        X509SecurityTokenAuthenticator CreateX509Authenticator(SecurityTokenRequirement requirement)
        {
            X509CertificateInitiatorServiceCredential c = ServiceCredentials.ClientCertificate;

            switch (c.Authentication.CertificateValidationMode)
            {
            case X509CertificateValidationMode.Custom:
                if (c.Authentication.CustomCertificateValidator == null)
                {
                    throw new InvalidOperationException("For Custom certificate validation mode, CustomCertificateValidator is required to create a token authenticator for X509 certificate.");
                }
                return(new X509SecurityTokenAuthenticator(c.Authentication.CustomCertificateValidator));

            case X509CertificateValidationMode.None:
                return(new X509SecurityTokenAuthenticator(X509CertificateValidator.None));

            case X509CertificateValidationMode.PeerOrChainTrust:
                return(new X509SecurityTokenAuthenticator(X509CertificateValidator.PeerOrChainTrust));

            case X509CertificateValidationMode.ChainTrust:
                return(new X509SecurityTokenAuthenticator(X509CertificateValidator.ChainTrust));

            default:
                return(new X509SecurityTokenAuthenticator(X509CertificateValidator.PeerTrust));
            }
        }
 public ServiceCredentials()
 {
     this.userName = new UserNamePasswordServiceCredential();
     this.clientCertificate = new X509CertificateInitiatorServiceCredential();
     this.serviceCertificate = new X509CertificateRecipientServiceCredential();
     this.windows = new WindowsServiceCredential();
     this.issuedToken = new IssuedTokenServiceCredential();
     this.peer = new PeerCredential();
     this.secureConversation = new SecureConversationServiceCredential();
 }
 internal void ApplyConfiguration(X509CertificateInitiatorServiceCredential creds)
 {
     if (creds == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("creds");
     }
     PropertyInformationCollection properties = base.ElementInformation.Properties;
     if (((properties["storeLocation"].ValueOrigin != PropertyValueOrigin.Default) || (properties["storeName"].ValueOrigin != PropertyValueOrigin.Default)) || ((properties["x509FindType"].ValueOrigin != PropertyValueOrigin.Default) || (properties["findValue"].ValueOrigin != PropertyValueOrigin.Default)))
     {
         creds.SetCertificate(this.StoreLocation, this.StoreName, this.X509FindType, this.FindValue);
     }
 }
 protected ServiceCredentials(ServiceCredentials other)
 {
     if (other == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
     }
     this.userName = new UserNamePasswordServiceCredential(other.userName);
     this.clientCertificate = new X509CertificateInitiatorServiceCredential(other.clientCertificate);
     this.serviceCertificate = new X509CertificateRecipientServiceCredential(other.serviceCertificate);
     this.windows = new WindowsServiceCredential(other.windows);
     this.issuedToken = new IssuedTokenServiceCredential(other.issuedToken);
     this.peer = new PeerCredential(other.peer);
     this.secureConversation = new SecureConversationServiceCredential(other.secureConversation);
 }
 internal void ApplyConfiguration(X509CertificateInitiatorServiceCredential 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.Certificate].ValueOrigin != PropertyValueOrigin.Default)
     {
         this.Certificate.ApplyConfiguration(cert);
     }
 }
示例#6
0
 internal X509CertificateInitiatorServiceCredential(X509CertificateInitiatorServiceCredential other)
 {
     this.certificate    = other.certificate;
     this.authentication = new X509ClientCertificateAuthentication(other.authentication);
     this.isReadOnly     = other.isReadOnly;
 }
 internal X509CertificateInitiatorServiceCredential(X509CertificateInitiatorServiceCredential other)
 {
     this.certificate = other.certificate;
     this.authentication = new X509ClientCertificateAuthentication(other.authentication);
     this.isReadOnly = other.isReadOnly;
 }