Renci.SshNet.KeyboardInteractiveAuthenticationMethod.Session_UserAuthenticationInformationRequestReceived C# (CSharp) Method

Session_UserAuthenticationInformationRequestReceived() private method

private Session_UserAuthenticationInformationRequestReceived ( object sender, MessageEventArgs e ) : void
sender object
e MessageEventArgs
return void
        private void Session_UserAuthenticationInformationRequestReceived(object sender, MessageEventArgs<InformationRequestMessage> e)
        {
            var informationRequestMessage = e.Message;

            var eventArgs = new AuthenticationPromptEventArgs(Username,
                                                              informationRequestMessage.Instruction,
                                                              informationRequestMessage.Language,
                                                              informationRequestMessage.Prompts);

            ThreadAbstraction.ExecuteThread(() =>
                {
                    try
                    {
                        if (AuthenticationPrompt != null)
                        {
                            AuthenticationPrompt(this, eventArgs);
                        }

                        var informationResponse = new InformationResponseMessage();

                        foreach (var response in from r in eventArgs.Prompts orderby r.Id ascending select r.Response)
                        {
                            informationResponse.Responses.Add(response);
                        }

                        //  Send information response message
                        _session.SendMessage(informationResponse);
                    }
                    catch (Exception exp)
                    {
                        _exception = exp;
                        _authenticationCompleted.Set();
                    }
                });
        }