public InitiateUpgradeAsyncResult(SslStreamSecurityUpgradeInitiator initiator, AsyncCallback callback, object state) : base(callback, state)
 {
     this.initiator = initiator;
     if (initiator.clientToken != null)
     {
         this.clientCertificates = new X509CertificateCollection();
         this.clientCertificates.Add(initiator.clientToken.Certificate);
         this.selectionCallback = SslStreamSecurityUpgradeInitiator.ClientCertificateSelectionCallback;
     }
 }
            public CloseAsyncResult(SslStreamSecurityUpgradeInitiator parent, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.parent = parent;
                TimeoutHelper helper = new TimeoutHelper(timeout);

                this.onBaseClose = Fx.ThunkCallback(new AsyncCallback(this.OnBaseClose));
                if (parent.clientCertificateProvider != null)
                {
                    this.onCloseTokenProvider = Fx.ThunkCallback(new AsyncCallback(this.OnCloseTokenProvider));
                }
                IAsyncResult result = parent.BaseBeginClose(helper.RemainingTime(), this.onBaseClose, this);

                if (result.CompletedSynchronously && this.HandleBaseCloseComplete(result))
                {
                    base.Complete(true);
                }
            }
Esempio n. 3
0
        ChannelBinding IStreamUpgradeChannelBindingProvider.GetChannelBinding(StreamUpgradeInitiator upgradeInitiator, ChannelBindingKind kind)
        {
            if (upgradeInitiator == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("upgradeInitiator");
            }
            SslStreamSecurityUpgradeInitiator initiator = upgradeInitiator as SslStreamSecurityUpgradeInitiator;

            if (initiator == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("upgradeInitiator", System.ServiceModel.SR.GetString("UnsupportedUpgradeInitiator", new object[] { upgradeInitiator.GetType() }));
            }
            if (kind != ChannelBindingKind.Endpoint)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("kind", System.ServiceModel.SR.GetString("StreamUpgradeUnsupportedChannelBindingKind", new object[] { base.GetType(), kind }));
            }
            return(initiator.ChannelBinding);
        }
        ChannelBinding IStreamUpgradeChannelBindingProvider.GetChannelBinding(StreamUpgradeInitiator upgradeInitiator, ChannelBindingKind kind)
        {
            if (upgradeInitiator == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("upgradeInitiator");
            }

            SslStreamSecurityUpgradeInitiator sslUpgradeInitiator = upgradeInitiator as SslStreamSecurityUpgradeInitiator;

            if (sslUpgradeInitiator == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("upgradeInitiator", SR.Format(SR.UnsupportedUpgradeInitiator, upgradeInitiator.GetType()));
            }

            if (kind != ChannelBindingKind.Endpoint)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("kind", SR.Format(SR.StreamUpgradeUnsupportedChannelBindingKind, this.GetType(), kind));
            }

            return(sslUpgradeInitiator.ChannelBinding);
        }
 public OpenAsyncResult(SslStreamSecurityUpgradeInitiator parent, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.parent = parent;
     TimeoutHelper helper = new TimeoutHelper(timeout);
     this.onBaseOpen = Fx.ThunkCallback(new AsyncCallback(this.OnBaseOpen));
     if (parent.clientCertificateProvider != null)
     {
         this.onOpenTokenProvider = Fx.ThunkCallback(new AsyncCallback(this.OnOpenTokenProvider));
         this.onGetClientToken = Fx.ThunkCallback(new AsyncCallback(this.OnGetClientToken));
     }
     IAsyncResult result = parent.BaseBeginOpen(helper.RemainingTime(), this.onBaseOpen, this);
     if (result.CompletedSynchronously && this.HandleBaseOpenComplete(result))
     {
         base.Complete(true);
     }
 }
 public InitiateUpgradeAsyncResult(SslStreamSecurityUpgradeInitiator initiator, AsyncCallback callback, object state) : base(callback, state)
 {
     this.initiator = initiator;
     if (initiator.clientToken != null)
     {
         this.clientCertificates = new X509CertificateCollection();
         this.clientCertificates.Add(initiator.clientToken.Certificate);
         this.selectionCallback = SslStreamSecurityUpgradeInitiator.ClientCertificateSelectionCallback;
     }
 }