IServiceFactory.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net.Sockets;
  4. using System.Text;
  5. using Renci.SshNet.Common;
  6. using Renci.SshNet.Connection;
  7. using Renci.SshNet.NetConf;
  8. using Renci.SshNet.Security;
  9. using Renci.SshNet.Sftp;
  10. namespace Renci.SshNet
  11. {
  12. /// <summary>
  13. /// Factory for creating new services.
  14. /// </summary>
  15. internal partial interface IServiceFactory
  16. {
  17. /// <summary>
  18. /// Creates an <see cref="IClientAuthentication"/>.
  19. /// </summary>
  20. /// <returns>
  21. /// An <see cref="IClientAuthentication"/>.
  22. /// </returns>
  23. IClientAuthentication CreateClientAuthentication();
  24. /// <summary>
  25. /// Creates a new <see cref="INetConfSession"/> in a given <see cref="ISession"/>
  26. /// and with the specified operation timeout.
  27. /// </summary>
  28. /// <param name="session">The <see cref="ISession"/> to create the <see cref="INetConfSession"/> in.</param>
  29. /// <param name="operationTimeout">The number of milliseconds to wait for an operation to complete, or <c>-1</c> to wait indefinitely.</param>
  30. /// <returns>
  31. /// An <see cref="INetConfSession"/>.
  32. /// </returns>
  33. INetConfSession CreateNetConfSession(ISession session, int operationTimeout);
  34. /// <summary>
  35. /// Creates a new <see cref="ISession"/> with the specified <see cref="ConnectionInfo"/> and
  36. /// <see cref="ISocketFactory"/>.
  37. /// </summary>
  38. /// <param name="connectionInfo">The <see cref="ConnectionInfo"/> to use for creating a new session.</param>
  39. /// <param name="socketFactory">A factory to create <see cref="Socket"/> instances.</param>
  40. /// <returns>
  41. /// An <see cref="ISession"/> for the specified <see cref="ConnectionInfo"/>.
  42. /// </returns>
  43. /// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <see langword="null"/>.</exception>
  44. /// <exception cref="ArgumentNullException"><paramref name="socketFactory"/> is <see langword="null"/>.</exception>
  45. ISession CreateSession(ConnectionInfo connectionInfo, ISocketFactory socketFactory);
  46. /// <summary>
  47. /// Creates a new <see cref="ISftpSession"/> in a given <see cref="ISession"/> and with
  48. /// the specified operation timeout and encoding.
  49. /// </summary>
  50. /// <param name="session">The <see cref="ISession"/> to create the <see cref="ISftpSession"/> in.</param>
  51. /// <param name="operationTimeout">The number of milliseconds to wait for an operation to complete, or <c>-1</c> to wait indefinitely.</param>
  52. /// <param name="encoding">The encoding.</param>
  53. /// <param name="sftpMessageFactory">The factory to use for creating SFTP messages.</param>
  54. /// <returns>
  55. /// An <see cref="ISftpSession"/>.
  56. /// </returns>
  57. ISftpSession CreateSftpSession(ISession session, int operationTimeout, Encoding encoding, ISftpResponseFactory sftpMessageFactory);
  58. /// <summary>
  59. /// Create a new <see cref="PipeStream"/>.
  60. /// </summary>
  61. /// <returns>
  62. /// A <see cref="PipeStream"/>.
  63. /// </returns>
  64. PipeStream CreatePipeStream();
  65. /// <summary>
  66. /// Negotiates a key exchange algorithm, and creates a <see cref="IKeyExchange" /> for the negotiated
  67. /// algorithm.
  68. /// </summary>
  69. /// <param name="clientAlgorithms">A <see cref="IDictionary{String, Type}"/> of the key exchange algorithms supported by the client where the key is the name of the algorithm, and the value is the type implementing this algorithm.</param>
  70. /// <param name="serverAlgorithms">The names of the key exchange algorithms supported by the SSH server.</param>
  71. /// <returns>
  72. /// A <see cref="IKeyExchange"/> that was negotiated between client and server.
  73. /// </returns>
  74. /// <exception cref="ArgumentNullException"><paramref name="clientAlgorithms"/> is <see langword="null"/>.</exception>
  75. /// <exception cref="ArgumentNullException"><paramref name="serverAlgorithms"/> is <see langword="null"/>.</exception>
  76. /// <exception cref="SshConnectionException">No key exchange algorithm is supported by both client and server.</exception>
  77. IKeyExchange CreateKeyExchange(IDictionary<string, Type> clientAlgorithms, string[] serverAlgorithms);
  78. /// <summary>
  79. /// Creates an <see cref="ISftpFileReader"/> for the specified file and with the specified
  80. /// buffer size.
  81. /// </summary>
  82. /// <param name="fileName">The file to read.</param>
  83. /// <param name="sftpSession">The SFTP session to use.</param>
  84. /// <param name="bufferSize">The size of buffer.</param>
  85. /// <returns>
  86. /// An <see cref="ISftpFileReader"/>.
  87. /// </returns>
  88. ISftpFileReader CreateSftpFileReader(string fileName, ISftpSession sftpSession, uint bufferSize);
  89. /// <summary>
  90. /// Creates a new <see cref="ISftpResponseFactory"/> instance.
  91. /// </summary>
  92. /// <returns>
  93. /// An <see cref="ISftpResponseFactory"/>.
  94. /// </returns>
  95. ISftpResponseFactory CreateSftpResponseFactory();
  96. /// <summary>
  97. /// Creates a shell stream.
  98. /// </summary>
  99. /// <param name="session">The SSH session.</param>
  100. /// <param name="terminalName">The <c>TERM</c> environment variable.</param>
  101. /// <param name="columns">The terminal width in columns.</param>
  102. /// <param name="rows">The terminal width in rows.</param>
  103. /// <param name="width">The terminal width in pixels.</param>
  104. /// <param name="height">The terminal height in pixels.</param>
  105. /// <param name="terminalModeValues">The terminal mode values.</param>
  106. /// <param name="bufferSize">Size of the buffer.</param>
  107. /// <returns>
  108. /// The created <see cref="ShellStream"/> instance.
  109. /// </returns>
  110. /// <exception cref="SshConnectionException">Client is not connected.</exception>
  111. /// <remarks>
  112. /// <para>
  113. /// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities.
  114. /// You can get a detailed list of these cababilities by using the ‘infocmp’ command.
  115. /// </para>
  116. /// <para>
  117. /// The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer
  118. /// to the drawable area of the window.
  119. /// </para>
  120. /// </remarks>
  121. ShellStream CreateShellStream(ISession session,
  122. string terminalName,
  123. uint columns,
  124. uint rows,
  125. uint width,
  126. uint height,
  127. IDictionary<TerminalModes, uint> terminalModeValues,
  128. int bufferSize);
  129. /// <summary>
  130. /// Creates an <see cref="IRemotePathTransformation"/> that encloses a path in double quotes, and escapes
  131. /// any embedded double quote with a backslash.
  132. /// </summary>
  133. /// <returns>
  134. /// An <see cref="IRemotePathTransformation"/> that encloses a path in double quotes, and escapes any
  135. /// embedded double quote with a backslash.
  136. /// with a shell.
  137. /// </returns>
  138. IRemotePathTransformation CreateRemotePathDoubleQuoteTransformation();
  139. /// <summary>
  140. /// Creates an <see cref="IConnector"/> that can be used to establish a connection
  141. /// to the server identified by the specified <paramref name="connectionInfo"/>.
  142. /// </summary>
  143. /// <param name="connectionInfo">A <see cref="IConnectionInfo"/> detailing the server to establish a connection to.</param>
  144. /// <param name="socketFactory">A factory to create <see cref="Socket"/> instances.</param>
  145. /// <returns>
  146. /// An <see cref="IConnector"/> that can be used to establish a connection to the
  147. /// server identified by the specified <paramref name="connectionInfo"/>.
  148. /// </returns>
  149. /// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <see langword="null"/>.</exception>
  150. /// <exception cref="ArgumentNullException"><paramref name="socketFactory"/> is <see langword="null"/>.</exception>
  151. /// <exception cref="NotSupportedException">The <see cref="IConnectionInfo.ProxyType"/> value of <paramref name="connectionInfo"/> is not supported.</exception>
  152. IConnector CreateConnector(IConnectionInfo connectionInfo, ISocketFactory socketFactory);
  153. /// <summary>
  154. /// Creates an <see cref="IProtocolVersionExchange"/> that deals with the SSH protocol
  155. /// version exchange.
  156. /// </summary>
  157. /// <returns>
  158. /// An <see cref="IProtocolVersionExchange"/>.
  159. /// </returns>
  160. IProtocolVersionExchange CreateProtocolVersionExchange();
  161. /// <summary>
  162. /// Creates a factory to create <see cref="Socket"/> instances.
  163. /// </summary>
  164. /// <returns>
  165. /// An <see cref="ISocketFactory"/>.
  166. /// </returns>
  167. ISocketFactory CreateSocketFactory();
  168. }
  169. }