This exception can be thrown from Authenticate() method of Ssl and Negotiate classes. The authentication is expected to fail prematurely if called using the same underlined stream.

Inheritance: AuthenticationException
Exemplo n.º 1
0
        //
        //  This is to reset auth state on the remote side.
        //  If this write succeeds we will allow auth retrying.
        //
        private void StartSendAuthResetSignal(LazyAsyncResult lazyResult, byte[] message, Exception exception)
        {
            _framer.WriteHeader.MessageId = FrameHeader.HandshakeErrId;

            Win32Exception win32exception = exception as Win32Exception;

            if (win32exception != null && win32exception.NativeErrorCode == (int)Interop.SecurityStatus.LogonDenied)
            {
                if (IsServer)
                {
                    exception = new InvalidCredentialException(SR.net_auth_bad_client_creds, exception);
                }
                else
                {
                    exception = new InvalidCredentialException(SR.net_auth_bad_client_creds_or_target_mismatch, exception);
                }
            }

            if (!(exception is AuthenticationException))
            {
                exception = new AuthenticationException(SR.net_auth_SSPI, exception);
            }

            if (lazyResult == null)
            {
                _framer.WriteMessage(message);
            }
            else
            {
                lazyResult.Result = exception;
                IAsyncResult ar = _framer.BeginWriteMessage(message, s_writeCallback, lazyResult);
                if (!ar.CompletedSynchronously)
                {
                    return;
                }

                _framer.EndWriteMessage(ar);
            }

            _canRetryAuthentication = true;
            throw exception;
        }
 private void StartSendAuthResetSignal(LazyAsyncResult lazyResult, byte[] message, Exception exception)
 {
     this._Framer.WriteHeader.MessageId = 0x15;
     Win32Exception exception2 = exception as Win32Exception;
     if ((exception2 != null) && (exception2.NativeErrorCode == -2146893044))
     {
         if (this.IsServer)
         {
             exception = new InvalidCredentialException(SR.GetString("net_auth_bad_client_creds"), exception);
         }
         else
         {
             exception = new InvalidCredentialException(SR.GetString("net_auth_bad_client_creds_or_target_mismatch"), exception);
         }
     }
     if (!(exception is AuthenticationException))
     {
         exception = new AuthenticationException(SR.GetString("net_auth_SSPI"), exception);
     }
     if (lazyResult == null)
     {
         this._Framer.WriteMessage(message);
     }
     else
     {
         lazyResult.Result = exception;
         IAsyncResult asyncResult = this._Framer.BeginWriteMessage(message, _WriteCallback, lazyResult);
         if (!asyncResult.CompletedSynchronously)
         {
             return;
         }
         this._Framer.EndWriteMessage(asyncResult);
     }
     this._CanRetryAuthentication = true;
     throw exception;
 }