Provides data for Renci.SshNet.KeyboardInteractiveConnectionInfo.AuthenticationPrompt event.
Inheritance: AuthenticationEventArgs
 public void AuthenticationPromptEventArgsConstructorTest()
 {
     string username = string.Empty; // TODO: Initialize to an appropriate value
     string instruction = string.Empty; // TODO: Initialize to an appropriate value
     string language = string.Empty; // TODO: Initialize to an appropriate value
     IEnumerable<AuthenticationPrompt> prompts = null; // TODO: Initialize to an appropriate value
     AuthenticationPromptEventArgs target = new AuthenticationPromptEventArgs(username, instruction, language, prompts);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 //Event handler for password prompt
 public static void HandleKeyEvent(Object sender, Renci.SshNet.Common.AuthenticationPromptEventArgs e)
 {
     foreach (Renci.SshNet.Common.AuthenticationPrompt prompt in e.Prompts)
     {
         if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
         {
             prompt.Response = password;
         }
     }
 }
Exemplo n.º 3
0
 private void SftpWebRequest_AuthenticationPrompt(object sender, Renci.SshNet.Common.AuthenticationPromptEventArgs e)
 {
     foreach (AuthenticationPrompt prompt in e.Prompts)
     {
         if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
         {
             prompt.Response = (m_cred as NetworkCredential).Password;
         }
     }
 }
 private void AuthenticationMethod_AuthenticationPrompt(object sender, AuthenticationPromptEventArgs e)
 {
     if (this.AuthenticationPrompt != null)
     {
         this.AuthenticationPrompt(sender, e);
     }
 }
        /// <summary>
        /// Handles the MessageReceived event of the session.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The event data.</param>
        protected override void Session_MessageReceived(object sender, MessageEventArgs<Message> e)
        {
            var informationRequestMessage = e.Message as InformationRequestMessage;
            if (informationRequestMessage != null)
            {
                var eventArgs = new AuthenticationPromptEventArgs(this.Username, informationRequestMessage.Instruction, informationRequestMessage.Language, informationRequestMessage.Prompts);

                this.ExecuteThread(() =>
                {
                    try
                    {
                        if (this.AuthenticationPrompt != null)
                        {
                            this.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
                        this.SendMessage(informationResponse);
                    }
                    catch (Exception exp)
                    {
                        this._exception = exp;
                        this._authenticationCompleted.Set();
                    }
                });
            }
        }
        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();
                    }
                });
        }