protected void ProcessMsgUserInfoResponse(SshStreamReader msgReader)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            // Read response info.
            int numResponses = msgReader.ReadInt32();

            string[] responses = new string[numResponses];

            for (int i = 0; i < numResponses; i++)
            {
                responses[i] = Encoding.UTF8.GetString(msgReader.ReadByteString());
            }

            // Raise event to get result of auth attempt.
            var authUserEventArgs = new AuthUserKeyboardInteractiveEventArgs(_lastUserName,
                                                                             responses);

            if (AuthenticateUserKeyboardInteractive != null)
            {
                AuthenticateUserKeyboardInteractive(this,
                                                    authUserEventArgs);
            }

            // Check result of auth attempt.
            switch (authUserEventArgs.Result)
            {
            case AuthenticationResult.Success:
                // Auth has succeeded.
                AuthenticateUser(_lastServiceName);

                break;

            case AuthenticationResult.FurtherAuthRequired:
                // Auth has succeeded, but further auth is required.
                SendMsgUserAuthFailure(true);

                break;

            case AuthenticationResult.Failure:
                // Auth has failed.
                SendMsgUserAuthFailure(false);

                break;

            case AuthenticationResult.RequestMoreInfo:
                // Request more prompt info from client.
                RequestPromptInfo(null);

                break;
            }
        }
        protected void ProcessMsgUserInfoResponse(SshStreamReader msgReader)
        {
            if (_isDisposed) throw new ObjectDisposedException(this.GetType().FullName);

            // Read response info.
            int numResponses = msgReader.ReadInt32();
            string[] responses = new string[numResponses];

            for (int i = 0; i < numResponses; i++)
                responses[i] = Encoding.UTF8.GetString(msgReader.ReadByteString());

            // Raise event to get result of auth attempt.
            var authUserEventArgs = new AuthUserKeyboardInteractiveEventArgs(_lastUserName,
                responses);

            if (AuthenticateUserKeyboardInteractive != null) AuthenticateUserKeyboardInteractive(this,
                authUserEventArgs);

            // Check result of auth attempt.
            switch (authUserEventArgs.Result)
            {
                case AuthenticationResult.Success:
                    // Auth has succeeded.
                    AuthenticateUser(_lastServiceName);

                    break;
                case AuthenticationResult.FurtherAuthRequired:
                    // Auth has succeeded, but further auth is required.
                    SendMsgUserAuthFailure(true);

                    break;
                case AuthenticationResult.Failure:
                    // Auth has failed.
                    SendMsgUserAuthFailure(false);

                    break;
                case AuthenticationResult.RequestMoreInfo:
                    // Request more prompt info from client.
                    RequestPromptInfo(null);

                    break;
            }
        }
Exemplo n.º 3
0
        private void authService_AuthenticateUserKeyboardInteractive(object sender,
            AuthUserKeyboardInteractiveEventArgs e)
        {
            var authService = (SshAuthenticationService)sender;

            e.Result = AuthenticationResult.Success;

            // Write to event log.
            LogClientAuthEvent(authService.Client, AuthenticationMethod.KeyboardInteractive, e);
        }