RequestMessageHost.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. namespace Renci.SshNet.Messages.Authentication
  2. {
  3. /// <summary>
  4. /// Represents "hostbased" SSH_MSG_USERAUTH_REQUEST message.
  5. /// </summary>
  6. internal class RequestMessageHost : RequestMessage
  7. {
  8. /// <summary>
  9. /// Gets the name of the authentication method.
  10. /// </summary>
  11. /// <value>
  12. /// The name of the method.
  13. /// </value>
  14. public override string MethodName
  15. {
  16. get
  17. {
  18. return "hostbased";
  19. }
  20. }
  21. /// <summary>
  22. /// Gets the public key algorithm for host key
  23. /// </summary>
  24. public string PublicKeyAlgorithm { get; private set; }
  25. /// <summary>
  26. /// Gets or sets the public host key and certificates for client host.
  27. /// </summary>
  28. /// <value>
  29. /// The public host key.
  30. /// </value>
  31. public byte[] PublicHostKey { get; private set; }
  32. /// <summary>
  33. /// Gets or sets the name of the client host.
  34. /// </summary>
  35. /// <value>
  36. /// The name of the client host.
  37. /// </value>
  38. public string ClientHostName { get; private set; }
  39. /// <summary>
  40. /// Gets or sets the client username on the client host
  41. /// </summary>
  42. /// <value>
  43. /// The client username.
  44. /// </value>
  45. public string ClientUsername { get; private set; }
  46. /// <summary>
  47. /// Gets or sets the signature.
  48. /// </summary>
  49. /// <value>
  50. /// The signature.
  51. /// </value>
  52. public byte[] Signature { get; set; }
  53. /// <summary>
  54. /// Initializes a new instance of the <see cref="RequestMessageHost"/> class.
  55. /// </summary>
  56. /// <param name="serviceName">Name of the service.</param>
  57. /// <param name="username">Authentication username.</param>
  58. /// <param name="publicKeyAlgorithm">The public key algorithm.</param>
  59. /// <param name="publicHostKey">The public host key.</param>
  60. /// <param name="clientHostName">Name of the client host.</param>
  61. /// <param name="clientUsername">The client username.</param>
  62. public RequestMessageHost(ServiceName serviceName, string username, string publicKeyAlgorithm, byte[] publicHostKey, string clientHostName, string clientUsername)
  63. : base(serviceName, username)
  64. {
  65. this.PublicKeyAlgorithm = publicKeyAlgorithm;
  66. this.PublicHostKey = publicHostKey;
  67. this.ClientHostName = clientHostName;
  68. this.ClientUsername = clientUsername;
  69. }
  70. /// <summary>
  71. /// Called when type specific data need to be saved.
  72. /// </summary>
  73. protected override void SaveData()
  74. {
  75. base.SaveData();
  76. this.WriteAscii(this.PublicKeyAlgorithm);
  77. this.WriteBinaryString(this.PublicHostKey);
  78. this.Write(this.ClientHostName);
  79. this.Write(this.ClientUsername);
  80. if (this.Signature != null)
  81. this.WriteBinaryString(this.Signature);
  82. }
  83. }
  84. }