2
0

ServiceAcceptMessage.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. namespace Renci.SshNet.Messages.Transport
  3. {
  4. /// <summary>
  5. /// Represents SSH_MSG_SERVICE_ACCEPT message.
  6. /// </summary>
  7. [Message("SSH_MSG_SERVICE_ACCEPT", 6)]
  8. public class ServiceAcceptMessage : Message
  9. {
  10. /// <summary>
  11. /// Gets the name of the service.
  12. /// </summary>
  13. /// <value>
  14. /// The name of the service.
  15. /// </value>
  16. public ServiceName ServiceName { get; private set; }
  17. /// <summary>
  18. /// Called when type specific data need to be loaded.
  19. /// </summary>
  20. protected override void LoadData()
  21. {
  22. var serviceName = this.ReadAsciiString();
  23. switch (serviceName)
  24. {
  25. case "ssh-userauth":
  26. this.ServiceName = ServiceName.UserAuthentication;
  27. break;
  28. case "ssh-connection":
  29. this.ServiceName = ServiceName.Connection;
  30. break;
  31. default:
  32. break;
  33. }
  34. }
  35. /// <summary>
  36. /// Called when type specific data need to be saved.
  37. /// </summary>
  38. protected override void SaveData()
  39. {
  40. throw new InvalidOperationException("Save data is not supported.");
  41. }
  42. }
  43. }