ConnectionInfo.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Security.Cryptography;
  6. using System.Text;
  7. using Renci.SshNet.Abstractions;
  8. using Renci.SshNet.Common;
  9. using Renci.SshNet.Messages.Authentication;
  10. using Renci.SshNet.Messages.Connection;
  11. using Renci.SshNet.Security;
  12. using Renci.SshNet.Security.Cryptography;
  13. using Renci.SshNet.Security.Cryptography.Ciphers;
  14. using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
  15. namespace Renci.SshNet
  16. {
  17. /// <summary>
  18. /// Represents remote connection information class.
  19. /// </summary>
  20. /// <remarks>
  21. /// This class is NOT thread-safe. Do not use the same <see cref="ConnectionInfo"/> with multiple
  22. /// client instances.
  23. /// </remarks>
  24. public class ConnectionInfo : IConnectionInfoInternal
  25. {
  26. internal const int DefaultPort = 22;
  27. /// <summary>
  28. /// The default connection timeout.
  29. /// </summary>
  30. /// <value>
  31. /// 30 seconds.
  32. /// </value>
  33. private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
  34. /// <summary>
  35. /// The default channel close timeout.
  36. /// </summary>
  37. /// <value>
  38. /// 1 second.
  39. /// </value>
  40. private static readonly TimeSpan DefaultChannelCloseTimeout = TimeSpan.FromSeconds(1);
  41. /// <summary>
  42. /// Gets supported key exchange algorithms for this connection.
  43. /// </summary>
  44. public IDictionary<string, Type> KeyExchangeAlgorithms { get; private set; }
  45. /// <summary>
  46. /// Gets supported encryptions for this connection.
  47. /// </summary>
  48. public IDictionary<string, CipherInfo> Encryptions { get; private set; }
  49. /// <summary>
  50. /// Gets supported hash algorithms for this connection.
  51. /// </summary>
  52. public IDictionary<string, HashInfo> HmacAlgorithms { get; private set; }
  53. /// <summary>
  54. /// Gets supported host key algorithms for this connection.
  55. /// </summary>
  56. public IDictionary<string, Func<byte[], KeyHostAlgorithm>> HostKeyAlgorithms { get; private set; }
  57. /// <summary>
  58. /// Gets supported authentication methods for this connection.
  59. /// </summary>
  60. public IList<AuthenticationMethod> AuthenticationMethods { get; private set; }
  61. /// <summary>
  62. /// Gets supported compression algorithms for this connection.
  63. /// </summary>
  64. public IDictionary<string, Type> CompressionAlgorithms { get; private set; }
  65. /// <summary>
  66. /// Gets the supported channel requests for this connection.
  67. /// </summary>
  68. /// <value>
  69. /// The supported channel requests for this connection.
  70. /// </value>
  71. public IDictionary<string, RequestInfo> ChannelRequests { get; private set; }
  72. /// <summary>
  73. /// Gets a value indicating whether connection is authenticated.
  74. /// </summary>
  75. /// <value>
  76. /// <see langword="true"/> if connection is authenticated; otherwise, <see langword="false"/>.
  77. /// </value>
  78. public bool IsAuthenticated { get; private set; }
  79. /// <summary>
  80. /// Gets connection host.
  81. /// </summary>
  82. /// <value>
  83. /// The connection host.
  84. /// </value>
  85. public string Host { get; private set; }
  86. /// <summary>
  87. /// Gets connection port.
  88. /// </summary>
  89. /// <value>
  90. /// The connection port. The default value is 22.
  91. /// </value>
  92. public int Port { get; private set; }
  93. /// <summary>
  94. /// Gets connection username.
  95. /// </summary>
  96. public string Username { get; private set; }
  97. /// <summary>
  98. /// Gets proxy type.
  99. /// </summary>
  100. /// <value>
  101. /// The type of the proxy.
  102. /// </value>
  103. public ProxyTypes ProxyType { get; private set; }
  104. /// <summary>
  105. /// Gets proxy connection host.
  106. /// </summary>
  107. public string ProxyHost { get; private set; }
  108. /// <summary>
  109. /// Gets proxy connection port.
  110. /// </summary>
  111. public int ProxyPort { get; private set; }
  112. /// <summary>
  113. /// Gets proxy connection username.
  114. /// </summary>
  115. public string ProxyUsername { get; private set; }
  116. /// <summary>
  117. /// Gets proxy connection password.
  118. /// </summary>
  119. public string ProxyPassword { get; private set; }
  120. /// <summary>
  121. /// Gets or sets connection timeout.
  122. /// </summary>
  123. /// <value>
  124. /// The connection timeout. The default value is 30 seconds.
  125. /// </value>
  126. /// <example>
  127. /// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient Connect Timeout" language="C#" title="Specify connection timeout" />
  128. /// </example>
  129. public TimeSpan Timeout { get; set; }
  130. /// <summary>
  131. /// Gets or sets the timeout to use when waiting for a server to acknowledge closing a channel.
  132. /// </summary>
  133. /// <value>
  134. /// The channel close timeout. The default value is 1 second.
  135. /// </value>
  136. /// <remarks>
  137. /// If a server does not send a <c>SSH_MSG_CHANNEL_CLOSE</c> message before the specified timeout
  138. /// elapses, the channel will be closed immediately.
  139. /// </remarks>
  140. public TimeSpan ChannelCloseTimeout { get; set; }
  141. /// <summary>
  142. /// Gets or sets the character encoding.
  143. /// </summary>
  144. /// <value>
  145. /// The character encoding. The default is <see cref="Encoding.UTF8"/>.
  146. /// </value>
  147. public Encoding Encoding { get; set; }
  148. /// <summary>
  149. /// Gets or sets number of retry attempts when session channel creation failed.
  150. /// </summary>
  151. /// <value>
  152. /// The number of retry attempts when session channel creation failed. The default
  153. /// value is 10.
  154. /// </value>
  155. public int RetryAttempts { get; set; }
  156. /// <summary>
  157. /// Gets or sets maximum number of session channels to be open simultaneously.
  158. /// </summary>
  159. /// <value>
  160. /// The maximum number of session channels to be open simultaneously. The default
  161. /// value is 10.
  162. /// </value>
  163. public int MaxSessions { get; set; }
  164. /// <summary>
  165. /// Occurs when authentication banner is sent by the server.
  166. /// </summary>
  167. /// <example>
  168. /// <code source="..\..\src\Renci.SshNet.Tests\Classes\PasswordConnectionInfoTest.cs" region="Example PasswordConnectionInfo AuthenticationBanner" language="C#" title="Display authentication banner" />
  169. /// </example>
  170. public event EventHandler<AuthenticationBannerEventArgs> AuthenticationBanner;
  171. /// <summary>
  172. /// Gets the current key exchange algorithm.
  173. /// </summary>
  174. public string CurrentKeyExchangeAlgorithm { get; internal set; }
  175. /// <summary>
  176. /// Gets the current server encryption.
  177. /// </summary>
  178. public string CurrentServerEncryption { get; internal set; }
  179. /// <summary>
  180. /// Gets the current client encryption.
  181. /// </summary>
  182. public string CurrentClientEncryption { get; internal set; }
  183. /// <summary>
  184. /// Gets the current server hash algorithm.
  185. /// </summary>
  186. public string CurrentServerHmacAlgorithm { get; internal set; }
  187. /// <summary>
  188. /// Gets the current client hash algorithm.
  189. /// </summary>
  190. public string CurrentClientHmacAlgorithm { get; internal set; }
  191. /// <summary>
  192. /// Gets the current host key algorithm.
  193. /// </summary>
  194. public string CurrentHostKeyAlgorithm { get; internal set; }
  195. /// <summary>
  196. /// Gets the current server compression algorithm.
  197. /// </summary>
  198. public string CurrentServerCompressionAlgorithm { get; internal set; }
  199. /// <summary>
  200. /// Gets the server version.
  201. /// </summary>
  202. public string ServerVersion { get; internal set; }
  203. /// <summary>
  204. /// Gets the client version.
  205. /// </summary>
  206. public string ClientVersion { get; internal set; }
  207. /// <summary>
  208. /// Gets the current client compression algorithm.
  209. /// </summary>
  210. public string CurrentClientCompressionAlgorithm { get; internal set; }
  211. /// <summary>
  212. /// Initializes a new instance of the <see cref="ConnectionInfo"/> class.
  213. /// </summary>
  214. /// <param name="host">The host.</param>
  215. /// <param name="username">The username.</param>
  216. /// <param name="authenticationMethods">The authentication methods.</param>
  217. /// <exception cref="ArgumentNullException"><paramref name="host"/> is <see langword="null"/>.</exception>
  218. /// <exception cref="ArgumentException"><paramref name="host"/> is a zero-length string.</exception>
  219. /// <exception cref="ArgumentException"><paramref name="username" /> is <see langword="null"/>, a zero-length string or contains only whitespace characters.</exception>
  220. /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <see langword="null"/>.</exception>
  221. /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception>
  222. public ConnectionInfo(string host, string username, params AuthenticationMethod[] authenticationMethods)
  223. : this(host, DefaultPort, username, ProxyTypes.None, proxyHost: null, 0, proxyUsername: null, proxyPassword: null, authenticationMethods)
  224. {
  225. }
  226. /// <summary>
  227. /// Initializes a new instance of the <see cref="ConnectionInfo"/> class.
  228. /// </summary>
  229. /// <param name="host">The host.</param>
  230. /// <param name="port">The port.</param>
  231. /// <param name="username">The username.</param>
  232. /// <param name="authenticationMethods">The authentication methods.</param>
  233. /// <exception cref="ArgumentNullException"><paramref name="host"/> is <see langword="null"/>.</exception>
  234. /// <exception cref="ArgumentException"><paramref name="username" /> is <see langword="null"/>, a zero-length string or contains only whitespace characters.</exception>
  235. /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="IPEndPoint.MinPort" /> and <see cref="IPEndPoint.MaxPort" />.</exception>
  236. /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <see langword="null"/>.</exception>
  237. /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception>
  238. public ConnectionInfo(string host, int port, string username, params AuthenticationMethod[] authenticationMethods)
  239. : this(host, port, username, ProxyTypes.None, proxyHost: null, 0, proxyUsername: null, proxyPassword: null, authenticationMethods)
  240. {
  241. }
  242. /// <summary>
  243. /// Initializes a new instance of the <see cref="ConnectionInfo" /> class.
  244. /// </summary>
  245. /// <param name="host">Connection host.</param>
  246. /// <param name="port">Connection port.</param>
  247. /// <param name="username">Connection username.</param>
  248. /// <param name="proxyType">Type of the proxy.</param>
  249. /// <param name="proxyHost">The proxy host.</param>
  250. /// <param name="proxyPort">The proxy port.</param>
  251. /// <param name="proxyUsername">The proxy username.</param>
  252. /// <param name="proxyPassword">The proxy password.</param>
  253. /// <param name="authenticationMethods">The authentication methods.</param>
  254. /// <exception cref="ArgumentNullException"><paramref name="host"/> is <see langword="null"/>.</exception>
  255. /// <exception cref="ArgumentException"><paramref name="username" /> is <see langword="null"/>, a zero-length string or contains only whitespace characters.</exception>
  256. /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="IPEndPoint.MinPort" /> and <see cref="IPEndPoint.MaxPort" />.</exception>
  257. /// <exception cref="ArgumentNullException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyHost" /> is <see langword="null"/>.</exception>
  258. /// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="IPEndPoint.MinPort" /> and <see cref="IPEndPoint.MaxPort" />.</exception>
  259. /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <see langword="null"/>.</exception>
  260. /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception>
  261. public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods)
  262. {
  263. if (host is null)
  264. {
  265. throw new ArgumentNullException(nameof(host));
  266. }
  267. port.ValidatePort("port");
  268. if (username is null)
  269. {
  270. throw new ArgumentNullException(nameof(username));
  271. }
  272. if (username.All(char.IsWhiteSpace))
  273. {
  274. throw new ArgumentException("Cannot be empty or contain only whitespace.", nameof(username));
  275. }
  276. if (proxyType != ProxyTypes.None)
  277. {
  278. if (proxyHost is null)
  279. {
  280. throw new ArgumentNullException(nameof(proxyHost));
  281. }
  282. proxyPort.ValidatePort("proxyPort");
  283. }
  284. if (authenticationMethods is null)
  285. {
  286. throw new ArgumentNullException(nameof(authenticationMethods));
  287. }
  288. if (authenticationMethods.Length == 0)
  289. {
  290. throw new ArgumentException("At least one authentication method should be specified.", nameof(authenticationMethods));
  291. }
  292. // Set default connection values
  293. Timeout = DefaultTimeout;
  294. ChannelCloseTimeout = DefaultChannelCloseTimeout;
  295. RetryAttempts = 10;
  296. MaxSessions = 10;
  297. Encoding = Encoding.UTF8;
  298. KeyExchangeAlgorithms = new Dictionary<string, Type>
  299. {
  300. { "curve25519-sha256", typeof(KeyExchangeECCurve25519) },
  301. { "curve25519-sha256@libssh.org", typeof(KeyExchangeECCurve25519) },
  302. { "ecdh-sha2-nistp256", typeof(KeyExchangeECDH256) },
  303. { "ecdh-sha2-nistp384", typeof(KeyExchangeECDH384) },
  304. { "ecdh-sha2-nistp521", typeof(KeyExchangeECDH521) },
  305. { "diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256) },
  306. { "diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1) },
  307. { "diffie-hellman-group16-sha512", typeof(KeyExchangeDiffieHellmanGroup16Sha512) },
  308. { "diffie-hellman-group14-sha256", typeof(KeyExchangeDiffieHellmanGroup14Sha256) },
  309. { "diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1) },
  310. { "diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1) },
  311. };
  312. Encryptions = new Dictionary<string, CipherInfo>
  313. {
  314. { "aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), padding: null)) },
  315. { "3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), padding: null)) },
  316. { "aes128-cbc", new CipherInfo(128, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), padding: null)) },
  317. { "aes192-cbc", new CipherInfo(192, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), padding: null)) },
  318. { "aes256-cbc", new CipherInfo(256, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), padding: null)) },
  319. { "blowfish-cbc", new CipherInfo(128, (key, iv) => new BlowfishCipher(key, new CbcCipherMode(iv), padding: null)) },
  320. { "twofish-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), padding: null)) },
  321. { "twofish192-cbc", new CipherInfo(192, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), padding: null)) },
  322. { "twofish128-cbc", new CipherInfo(128, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), padding: null)) },
  323. { "twofish256-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), padding: null)) },
  324. { "arcfour", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, dischargeFirstBytes: false)) },
  325. { "arcfour128", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, dischargeFirstBytes: true)) },
  326. { "arcfour256", new CipherInfo(256, (key, iv) => new Arc4Cipher(key, dischargeFirstBytes: true)) },
  327. { "cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), padding: null)) },
  328. { "aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), padding: null)) },
  329. { "aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), padding: null)) },
  330. };
  331. HmacAlgorithms = new Dictionary<string, HashInfo>
  332. {
  333. { "hmac-md5", new HashInfo(16*8, CryptoAbstraction.CreateHMACMD5) },
  334. { "hmac-md5-96", new HashInfo(16*8, key => CryptoAbstraction.CreateHMACMD5(key, 96)) },
  335. { "hmac-sha1", new HashInfo(20*8, CryptoAbstraction.CreateHMACSHA1) },
  336. { "hmac-sha1-96", new HashInfo(20*8, key => CryptoAbstraction.CreateHMACSHA1(key, 96)) },
  337. { "hmac-sha2-256", new HashInfo(32*8, CryptoAbstraction.CreateHMACSHA256) },
  338. { "hmac-sha2-256-96", new HashInfo(32*8, key => CryptoAbstraction.CreateHMACSHA256(key, 96)) },
  339. { "hmac-sha2-512", new HashInfo(64 * 8, CryptoAbstraction.CreateHMACSHA512) },
  340. { "hmac-sha2-512-96", new HashInfo(64 * 8, key => CryptoAbstraction.CreateHMACSHA512(key, 96)) },
  341. { "hmac-ripemd160", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) },
  342. { "hmac-ripemd160@openssh.com", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) },
  343. };
  344. HostKeyAlgorithms = new Dictionary<string, Func<byte[], KeyHostAlgorithm>>
  345. {
  346. { "ssh-ed25519", data => new KeyHostAlgorithm("ssh-ed25519", new ED25519Key(), data) },
  347. { "ecdsa-sha2-nistp256", data => new KeyHostAlgorithm("ecdsa-sha2-nistp256", new EcdsaKey(), data) },
  348. { "ecdsa-sha2-nistp384", data => new KeyHostAlgorithm("ecdsa-sha2-nistp384", new EcdsaKey(), data) },
  349. { "ecdsa-sha2-nistp521", data => new KeyHostAlgorithm("ecdsa-sha2-nistp521", new EcdsaKey(), data) },
  350. #pragma warning disable SA1107 // Code should not contain multiple statements on one line
  351. { "rsa-sha2-512", data => { var key = new RsaKey(); return new KeyHostAlgorithm("rsa-sha2-512", key, data, new RsaDigitalSignature(key, HashAlgorithmName.SHA512)); } },
  352. { "rsa-sha2-256", data => { var key = new RsaKey(); return new KeyHostAlgorithm("rsa-sha2-256", key, data, new RsaDigitalSignature(key, HashAlgorithmName.SHA256)); } },
  353. #pragma warning restore SA1107 // Code should not contain multiple statements on one line
  354. { "ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data) },
  355. { "ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data) },
  356. };
  357. CompressionAlgorithms = new Dictionary<string, Type>
  358. {
  359. { "none", null },
  360. };
  361. ChannelRequests = new Dictionary<string, RequestInfo>
  362. {
  363. { EnvironmentVariableRequestInfo.Name, new EnvironmentVariableRequestInfo() },
  364. { ExecRequestInfo.Name, new ExecRequestInfo() },
  365. { ExitSignalRequestInfo.Name, new ExitSignalRequestInfo() },
  366. { ExitStatusRequestInfo.Name, new ExitStatusRequestInfo() },
  367. { PseudoTerminalRequestInfo.Name, new PseudoTerminalRequestInfo() },
  368. { ShellRequestInfo.Name, new ShellRequestInfo() },
  369. { SignalRequestInfo.Name, new SignalRequestInfo() },
  370. { SubsystemRequestInfo.Name, new SubsystemRequestInfo() },
  371. { WindowChangeRequestInfo.Name, new WindowChangeRequestInfo() },
  372. { X11ForwardingRequestInfo.Name, new X11ForwardingRequestInfo() },
  373. { XonXoffRequestInfo.Name, new XonXoffRequestInfo() },
  374. { EndOfWriteRequestInfo.Name, new EndOfWriteRequestInfo() },
  375. { KeepAliveRequestInfo.Name, new KeepAliveRequestInfo() },
  376. };
  377. Host = host;
  378. Port = port;
  379. Username = username;
  380. ProxyType = proxyType;
  381. ProxyHost = proxyHost;
  382. ProxyPort = proxyPort;
  383. ProxyUsername = proxyUsername;
  384. ProxyPassword = proxyPassword;
  385. AuthenticationMethods = authenticationMethods;
  386. }
  387. /// <summary>
  388. /// Authenticates the specified session.
  389. /// </summary>
  390. /// <param name="session">The session to be authenticated.</param>
  391. /// <param name="serviceFactory">The factory to use for creating new services.</param>
  392. /// <exception cref="ArgumentNullException"><paramref name="session"/> is <see langword="null"/>.</exception>
  393. /// <exception cref="ArgumentNullException"><paramref name="serviceFactory"/> is <see langword="null"/>.</exception>
  394. /// <exception cref="SshAuthenticationException">No suitable authentication method found to complete authentication, or permission denied.</exception>
  395. internal void Authenticate(ISession session, IServiceFactory serviceFactory)
  396. {
  397. if (serviceFactory is null)
  398. {
  399. throw new ArgumentNullException(nameof(serviceFactory));
  400. }
  401. IsAuthenticated = false;
  402. var clientAuthentication = serviceFactory.CreateClientAuthentication();
  403. clientAuthentication.Authenticate(this, session);
  404. IsAuthenticated = true;
  405. }
  406. /// <summary>
  407. /// Signals that an authentication banner message was received from the server.
  408. /// </summary>
  409. /// <param name="sender">The session in which the banner message was received.</param>
  410. /// <param name="e">The banner message.</param>
  411. void IConnectionInfoInternal.UserAuthenticationBannerReceived(object sender, MessageEventArgs<BannerMessage> e)
  412. {
  413. AuthenticationBanner?.Invoke(this, new AuthenticationBannerEventArgs(Username, e.Message.Message, e.Message.Language));
  414. }
  415. /// <summary>
  416. /// Creates a <c>none</c> authentication method.
  417. /// </summary>
  418. /// <returns>
  419. /// A <c>none</c> authentication method.
  420. /// </returns>
  421. IAuthenticationMethod IConnectionInfoInternal.CreateNoneAuthenticationMethod()
  422. {
  423. return new NoneAuthenticationMethod(Username);
  424. }
  425. /// <summary>
  426. /// Gets the supported authentication methods for this connection.
  427. /// </summary>
  428. /// <value>
  429. /// The supported authentication methods for this connection.
  430. /// </value>
  431. IList<IAuthenticationMethod> IConnectionInfoInternal.AuthenticationMethods
  432. {
  433. #pragma warning disable S2365 // Properties should not make collection or array copies
  434. get { return AuthenticationMethods.Cast<IAuthenticationMethod>().ToList(); }
  435. #pragma warning restore S2365 // Properties should not make collection or array copies
  436. }
  437. }
  438. }