Beispiel #1
0
        private static void ReadCallback(IAsyncResult transportResult)
        {
            if (!(transportResult.AsyncState is LazyAsyncResult))
            {
                NetEventSource.Fail(transportResult, "State type is wrong, expected LazyAsyncResult.");
            }

            if (transportResult.CompletedSynchronously)
            {
                return;
            }

            LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState;

            // Async completion.
            try
            {
                NegoState authState = (NegoState)lazyResult.AsyncObject;
                byte[]    message   = authState._framer.EndReadMessage(transportResult);
                authState.ProcessReceivedBlob(message, lazyResult);
            }
            catch (Exception e)
            {
                if (lazyResult.InternalPeekCompleted)
                {
                    // This will throw on a worker thread.
                    throw;
                }

                lazyResult.InvokeCallback(e);
            }
        }
Beispiel #2
0
 private static void WriteCallback(IAsyncResult transportResult)
 {
     if (!transportResult.CompletedSynchronously)
     {
         LazyAsyncResult asyncState = (LazyAsyncResult)transportResult.AsyncState;
         try
         {
             NegoState asyncObject = (NegoState)asyncState.AsyncObject;
             asyncObject._Framer.EndWriteMessage(transportResult);
             if (asyncState.Result is Exception)
             {
                 asyncObject._CanRetryAuthentication = true;
                 throw ((Exception)asyncState.Result);
             }
             asyncObject.CheckCompletionBeforeNextReceive(asyncState);
         }
         catch (Exception exception)
         {
             if (asyncState.InternalPeekCompleted)
             {
                 throw;
             }
             asyncState.InvokeCallback(exception);
         }
     }
 }
Beispiel #3
0
        //
        //
        //
        private static void WriteCallback(IAsyncResult transportResult)
        {
            GlobalLog.Assert(transportResult.AsyncState is LazyAsyncResult, "WriteCallback|State type is wrong, expected LazyAsyncResult.");
            if (transportResult.CompletedSynchronously)
            {
                return;
            }

            LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState;

            // Async completion
            try
            {
                NegoState authState = (NegoState)lazyResult.AsyncObject;
                authState._Framer.EndWriteMessage(transportResult);

                //special case for an error notification
                if (lazyResult.Result is Exception)
                {
                    authState._CanRetryAuthentication = true;
                    throw (Exception)lazyResult.Result;
                }
                authState.CheckCompletionBeforeNextReceive(lazyResult);
            }
            catch (Exception e)
            {
                if (lazyResult.InternalPeekCompleted)
                {
                    // This will throw on a worker thread.
                    throw;
                }
                lazyResult.InvokeCallback(e);
            }
        }
Beispiel #4
0
        public NegotiateStream(Stream innerStream, bool leaveInnerStreamOpen) : base(innerStream, leaveInnerStreamOpen)
        {
#if DEBUG
            using (GlobalLog.SetThreadKind(ThreadKinds.User)) {
#endif
            _NegoState = new NegoState(innerStream, leaveInnerStreamOpen);
            _Package   = NegoState.DefaultPackage;
            InitializeStreamPart();
#if DEBUG
        }
#endif
        }
Beispiel #5
0
        public NegotiateStream(Stream innerStream,  bool leaveInnerStreamOpen): base(innerStream,  leaveInnerStreamOpen)
        {
#if DEBUG
            using (GlobalLog.SetThreadKind(ThreadKinds.User)) {
#endif
            _NegoState = new NegoState(innerStream, leaveInnerStreamOpen);
            _Package = NegoState.DefaultPackage;
            InitializeStreamPart();
#if DEBUG
            }
#endif
        }
Beispiel #6
0
 private static void ReadCallback(IAsyncResult transportResult)
 {
     if (!transportResult.CompletedSynchronously)
     {
         LazyAsyncResult asyncState = (LazyAsyncResult)transportResult.AsyncState;
         try
         {
             NegoState asyncObject = (NegoState)asyncState.AsyncObject;
             byte[]    message     = asyncObject._Framer.EndReadMessage(transportResult);
             asyncObject.ProcessReceivedBlob(message, asyncState);
         }
         catch (Exception exception)
         {
             if (asyncState.InternalPeekCompleted)
             {
                 throw;
             }
             asyncState.InvokeCallback(exception);
         }
     }
 }
Beispiel #7
0
        private static void WriteCallback(IAsyncResult transportResult)
        {
            if (!(transportResult.AsyncState is LazyAsyncResult))
            {
                NetEventSource.Fail(transportResult, "State type is wrong, expected LazyAsyncResult.");
            }

            if (transportResult.CompletedSynchronously)
            {
                return;
            }

            LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState;

            // Async completion.
            try
            {
                NegoState authState = (NegoState)lazyResult.AsyncObject;
                authState._framer.EndWriteMessage(transportResult);

                // Special case for an error notification.
                if (lazyResult.Result is Exception e)
                {
                    authState._canRetryAuthentication = true;
                    ExceptionDispatchInfo.Throw(e);
                }

                authState.CheckCompletionBeforeNextReceive(lazyResult);
            }
            catch (Exception e)
            {
                if (lazyResult.InternalPeekCompleted)
                {
                    // This will throw on a worker thread.
                    throw;
                }

                lazyResult.InvokeCallback(e);
            }
        }
 public NegotiateStream(Stream innerStream, bool leaveInnerStreamOpen) : base(innerStream, leaveInnerStreamOpen)
 {
     this._NegoState = new NegoState(innerStream, leaveInnerStreamOpen);
     this._Package   = NegoState.DefaultPackage;
     this.InitializeStreamPart();
 }