InformationRequestMessage.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using Renci.SshNet.Common;
  4. namespace Renci.SshNet.Messages.Authentication
  5. {
  6. /// <summary>
  7. /// Represents SSH_MSG_USERAUTH_INFO_REQUEST message.
  8. /// </summary>
  9. [Message("SSH_MSG_USERAUTH_INFO_REQUEST", 60)]
  10. internal class InformationRequestMessage : Message
  11. {
  12. /// <summary>
  13. /// Gets information request name.
  14. /// </summary>
  15. public string Name { get; private set; }
  16. /// <summary>
  17. /// Gets information request instruction.
  18. /// </summary>
  19. public string Instruction { get; private set; }
  20. /// <summary>
  21. /// Gets information request language.
  22. /// </summary>
  23. public string Language { get; private set; }
  24. /// <summary>
  25. /// Gets information request prompts.
  26. /// </summary>
  27. public IEnumerable<AuthenticationPrompt> Prompts { get; private set; }
  28. /// <summary>
  29. /// Called when type specific data need to be loaded.
  30. /// </summary>
  31. protected override void LoadData()
  32. {
  33. this.Name = this.ReadString();
  34. this.Instruction = this.ReadString();
  35. this.Language = this.ReadString();
  36. var numOfPrompts = this.ReadUInt32();
  37. var prompts = new List<AuthenticationPrompt>();
  38. for (int i = 0; i < numOfPrompts; i++)
  39. {
  40. var prompt = this.ReadString();
  41. var echo = this.ReadBoolean();
  42. prompts.Add(new AuthenticationPrompt(i, echo, prompt));
  43. }
  44. this.Prompts = prompts;
  45. }
  46. /// <summary>
  47. /// Called when type specific data need to be saved.
  48. /// </summary>
  49. protected override void SaveData()
  50. {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. }