Esempio n. 1
0
        /// <summary>
        /// Overrides the certificates given in app.config with the ones set programatically
        /// </summary>
        protected void OverrideConfig()
        {
            if (pListenerIdentity != null)
            {
                // Override certificate
                // TOOD: what is going on here? why only override the servicehost cridentials one time ?
                if (pListenerIdentity.ListenerCertificate != null && pServiceHost != null)
                {
                    pServiceHost.Credentials.ServiceCertificate.Certificate = pListenerIdentity.ListenerCertificate.Certificate;
                }
                else
                {
                    pListenerIdentity.ListenerCertificate = new OcesX509Certificate(pServiceHost.Credentials.ServiceCertificate.Certificate);
                }
            }
            else
            {
                CustomBinding           customBinding    = (CustomBinding)pServiceHost.Description.Endpoints[0].Binding;
                TransportBindingElement transportBinding = customBinding.Elements.Find <TransportBindingElement>();
                EmailTransport          emailTransport   = new EmailTransport(transportBinding);
                OcesX509Certificate     ocesCertificate  = new OcesX509Certificate(pServiceHost.Credentials.ServiceCertificate.Certificate);
                pListenerIdentity = new ListenerIdentity(emailTransport, ocesCertificate);
            }

            //Override transport binding
            pEmailBinding = GetEmailBinding();
            if (pListenerIdentity.Transport != null)
            {
                pEmailBinding.CopyElement((EmailBindingElement)pListenerIdentity.Transport.TransportBinding);
            }
            else
            {
                pListenerIdentity.Transport = new EmailTransport(pEmailBinding);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public EmailTransport(TransportBindingElement binding)
 {
     pBindingElement = (EmailBindingElement)binding;
 }