From c6d686691fbfbfc2c800ee21e85597653a85880e Mon Sep 17 00:00:00 2001 From: drieseng Date: Thu, 4 Feb 2016 20:35:09 +0100 Subject: [PATCH] Remove TFS templates, and obsolete files imported by the migration from Codeplex Removes TFS templates, and files that were importing into master by the Github migration tool for TFS. --- .../DefaultTemplate.11.1.xaml | 543 ---------------- .../LabDefaultTemplate.11.xaml | 208 ------- BuildProcessTemplates/UpgradeTemplate.xaml | 76 --- src/..svnbridge/.svnbridge | 3 - src/..svnbridge/SSH.NET.nupkg | 1 - src/Renci.SshClient.Tests/ConnectionData.cs | 18 - .../SftpClientTests/SftpClientTest.cs | 11 - src/Renci.SshClient.Tests/ShellTest.cs | 244 -------- .../ChannelOpeningEventArgs.cs | 11 - .../Channels/ChannelSessionExec.cs | 219 ------- .../Channels/ChannelSessionSftp.cs | 580 ------------------ .../Channels/ChannelSessionShell.cs | 99 --- src/Renci.SshClient/Common/BlockingStack.cs | 158 ----- .../Common/ConnectingEventArgs.cs | 54 -- .../Common/DataReceivedEventArgs.cs | 14 - src/Renci.SshClient/Common/FtpFileInfo.cs | 29 - .../Common/MessageReceivedEventArgs.cs | 15 - src/Renci.SshClient/Connection.cs | 96 --- .../Extensibility.AddAuthenticationMethod.aml | 96 --- .../Content/Extensibility.AddEncryption.aml | 96 --- .../Extensibility.AddHashAlgorithm.aml | 96 --- .../Documentation/Content/Extensibility.aml | 21 - .../Documentation/Content/HowTo.Sftp.aml | 50 -- .../Content/HowTo.SshCommand.Run.aml | 68 -- .../Content/HowTo.SshCommand.aml | 50 -- .../Documentation/Content/HowTo.aml | 50 -- .../Documentation/Content/Introduction.aml | 48 -- .../Messages/Authentication/Methods.cs | 10 - .../ChannelOpenDirectTcpIPMessage.cs | 33 - ...hannelRequestEnvironmentVariableMessage.cs | 30 - .../ChannelRequestExecMessage.cs | 26 - .../ChannelRequestExitSignalMessage.cs | 38 -- .../ChannelRequestExitStatusMessage.cs | 23 - .../ChannelRequestPseudoTerminalMessage.cs | 44 -- .../ChannelRequestShellMessage.cs | 19 - .../ChannelRequestSignalMessage.cs | 26 - .../ChannelRequestSubsystemMessage.cs | 26 - .../ChannelRequestWindowChangeMessage.cs | 38 -- .../ChannelRequestX11ForwardingMessage.cs | 38 -- .../ChannelRequestXonXoffMessage.cs | 26 - .../Connection/ChannelRequestNames.cs | 50 -- src/Renci.SshClient/Messages/MessageTypes.cs | 161 ----- .../RequestSuccessEventArgs.cs | 9 - src/Renci.SshClient/Security/CipherAES128.cs | 124 ---- .../Security/KeyExchangeCompletedEventArgs.cs | 8 - .../Security/KeyExchangeFailedEventArgs.cs | 14 - .../KeyExchangeSendMessageEventArgs.cs | 15 - src/Renci.SshClient/Security/PrivateKey.cs | 39 -- src/Renci.SshClient/Security/PrivateKeyDsa.cs | 192 ------ src/Renci.SshClient/Security/PrivateKeyRsa.cs | 197 ------ src/Renci.SshClient/Security/Signature.cs | 16 - src/Renci.SshClient/Security/SignatureDss.cs | 91 --- src/Renci.SshClient/Security/SignatureRsa.cs | 81 --- .../Security/UserAuthentication.cs | 94 --- .../Security/UserAuthenticationHost.cs | 18 - .../UserAuthenticationKeyboardInteractive.cs | 127 ---- .../Security/UserAuthenticationNone.cs | 82 --- .../Security/UserAuthenticationPassword.cs | 128 ---- .../Security/UserAuthenticationPublicKey.cs | 177 ------ .../Services/ConnectionService.cs | 19 - src/Renci.SshClient/Services/Service.cs | 22 - .../Services/UserAuthenticationService.cs | 155 ----- src/Renci.SshClient/SessionInfo.cs | 72 --- src/Renci.SshClient/SessionSSHv2.cs | 199 ------ src/Renci.SshClient/Settings.cs | 69 --- src/Renci.SshClient/Sftp.cs | 273 --------- src/Renci.SshClient/Sftp/FileStatusCommand.cs | 35 -- src/Renci.SshClient/Sftp/Messages/FSetStat.cs | 29 - .../Sftp/SftpFileAttributes.cs | 7 - src/Renci.SshClient/SftpAsyncResult.cs | 58 -- src/Renci.SshClient/SshBase.cs | 69 --- src/Renci.SshClient/UserAuthentication.cs | 20 - 72 files changed, 5981 deletions(-) delete mode 100644 BuildProcessTemplates/DefaultTemplate.11.1.xaml delete mode 100644 BuildProcessTemplates/LabDefaultTemplate.11.xaml delete mode 100644 BuildProcessTemplates/UpgradeTemplate.xaml delete mode 100644 src/..svnbridge/.svnbridge delete mode 100644 src/..svnbridge/SSH.NET.nupkg delete mode 100644 src/Renci.SshClient.Tests/ConnectionData.cs delete mode 100644 src/Renci.SshClient.Tests/SftpClientTests/SftpClientTest.cs delete mode 100644 src/Renci.SshClient.Tests/ShellTest.cs delete mode 100644 src/Renci.SshClient/ChannelOpeningEventArgs.cs delete mode 100644 src/Renci.SshClient/Channels/ChannelSessionExec.cs delete mode 100644 src/Renci.SshClient/Channels/ChannelSessionSftp.cs delete mode 100644 src/Renci.SshClient/Channels/ChannelSessionShell.cs delete mode 100644 src/Renci.SshClient/Common/BlockingStack.cs delete mode 100644 src/Renci.SshClient/Common/ConnectingEventArgs.cs delete mode 100644 src/Renci.SshClient/Common/DataReceivedEventArgs.cs delete mode 100644 src/Renci.SshClient/Common/FtpFileInfo.cs delete mode 100644 src/Renci.SshClient/Common/MessageReceivedEventArgs.cs delete mode 100644 src/Renci.SshClient/Connection.cs delete mode 100644 src/Renci.SshClient/Documentation/Content/Extensibility.AddAuthenticationMethod.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/Extensibility.AddEncryption.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/Extensibility.AddHashAlgorithm.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/Extensibility.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/HowTo.Sftp.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.Run.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/HowTo.aml delete mode 100644 src/Renci.SshClient/Documentation/Content/Introduction.aml delete mode 100644 src/Renci.SshClient/Messages/Authentication/Methods.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelOpenDirectTcpIPMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestEnvironmentVariableMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExecMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitSignalMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitStatusMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestPseudoTerminalMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestShellMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSignalMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSubsystemMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestWindowChangeMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestX11ForwardingMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestXonXoffMessage.cs delete mode 100644 src/Renci.SshClient/Messages/Connection/ChannelRequestNames.cs delete mode 100644 src/Renci.SshClient/Messages/MessageTypes.cs delete mode 100644 src/Renci.SshClient/RequestSuccessEventArgs.cs delete mode 100644 src/Renci.SshClient/Security/CipherAES128.cs delete mode 100644 src/Renci.SshClient/Security/KeyExchangeCompletedEventArgs.cs delete mode 100644 src/Renci.SshClient/Security/KeyExchangeFailedEventArgs.cs delete mode 100644 src/Renci.SshClient/Security/KeyExchangeSendMessageEventArgs.cs delete mode 100644 src/Renci.SshClient/Security/PrivateKey.cs delete mode 100644 src/Renci.SshClient/Security/PrivateKeyDsa.cs delete mode 100644 src/Renci.SshClient/Security/PrivateKeyRsa.cs delete mode 100644 src/Renci.SshClient/Security/Signature.cs delete mode 100644 src/Renci.SshClient/Security/SignatureDss.cs delete mode 100644 src/Renci.SshClient/Security/SignatureRsa.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthentication.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthenticationHost.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthenticationKeyboardInteractive.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthenticationNone.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthenticationPassword.cs delete mode 100644 src/Renci.SshClient/Security/UserAuthenticationPublicKey.cs delete mode 100644 src/Renci.SshClient/Services/ConnectionService.cs delete mode 100644 src/Renci.SshClient/Services/Service.cs delete mode 100644 src/Renci.SshClient/Services/UserAuthenticationService.cs delete mode 100644 src/Renci.SshClient/SessionInfo.cs delete mode 100644 src/Renci.SshClient/SessionSSHv2.cs delete mode 100644 src/Renci.SshClient/Settings.cs delete mode 100644 src/Renci.SshClient/Sftp.cs delete mode 100644 src/Renci.SshClient/Sftp/FileStatusCommand.cs delete mode 100644 src/Renci.SshClient/Sftp/Messages/FSetStat.cs delete mode 100644 src/Renci.SshClient/Sftp/SftpFileAttributes.cs delete mode 100644 src/Renci.SshClient/SftpAsyncResult.cs delete mode 100644 src/Renci.SshClient/SshBase.cs delete mode 100644 src/Renci.SshClient/UserAuthentication.cs diff --git a/BuildProcessTemplates/DefaultTemplate.11.1.xaml b/BuildProcessTemplates/DefaultTemplate.11.1.xaml deleted file mode 100644 index 60eac4b8..00000000 --- a/BuildProcessTemplates/DefaultTemplate.11.1.xaml +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - [New Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings()] - [False] - [New Microsoft.TeamFoundation.Build.Workflow.Activities.TestSpecList(New Microsoft.TeamFoundation.Build.Workflow.Activities.AgileTestPlatformSpec("**\*test*.dll"))] - ["$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)"] - [False] - [True] - [True] - [Microsoft.TeamFoundation.Build.Workflow.Activities.CleanWorkspaceOption.All] - - - - [Microsoft.TeamFoundation.Build.Workflow.Activities.CodeAnalysisOption.AsConfigured] - [True] - [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto] - [True] - [New Microsoft.TeamFoundation.Build.Workflow.Activities.SourceAndSymbolServerSettings(True, Nothing)] - [True] - - - - [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }] - [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal] - - - - - - - All - 11.0 - Assembly references and imported namespaces serialized as XML namespaces - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BuildProcessTemplates/LabDefaultTemplate.11.xaml b/BuildProcessTemplates/LabDefaultTemplate.11.xaml deleted file mode 100644 index 542717f2..00000000 --- a/BuildProcessTemplates/LabDefaultTemplate.11.xaml +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - 11.0 - - - - - - 920,3702 - Assembly references and imported namespaces serialized as XML namespaces - - - - - - - - - - - - - - - - - - - - - True - - - - - - - [LabWorkflowParameters.BuildDetails.BuildUri] - - - [ChildBuildDetail.Uri] - - - - - - - - - - - - [BuildLocation] - - - [If(LabWorkflowParameters.BuildDetails.Configuration Is Nothing, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsEmpty Or (SelectedBuildDetail.Information.GetNodesByType(Microsoft.TeamFoundation.Build.Common.InformationTypes.ConfigurationSummary, True)).Count = 1, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsPlatformEmptyOrAnyCpu, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Platform + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration)))] - - - - - - - - - - - - [LabEnvironmentUri] - - - [LabWorkflowParameters.EnvironmentDetails.LabEnvironmentUri.ToString()] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [PostDeploymentSnapshotName] - - - [If(LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True,String.Format("{0}_{1}_{2}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildNumber,BuildDetail.BuildNumber),String.Format("{0}_{1}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildDetail.BuildNumber))] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [BuildStatus] - - - [Microsoft.TeamFoundation.Build.Client.BuildStatus.PartiallySucceeded] - - - - - - - [BuildStatus] - - - [Microsoft.TeamFoundation.Build.Client.BuildStatus.Failed] - - - - - - - - - - - - \ No newline at end of file diff --git a/BuildProcessTemplates/UpgradeTemplate.xaml b/BuildProcessTemplates/UpgradeTemplate.xaml deleted file mode 100644 index 8ae69238..00000000 --- a/BuildProcessTemplates/UpgradeTemplate.xaml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }] - - - - [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto] - [False] - [False] - - - - - - - - - - [Microsoft.TeamFoundation.VersionControl.Client.RecursionType.OneLevel] - [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal] - - - - All - Assembly references and imported namespaces serialized as XML namespaces - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/..svnbridge/.svnbridge b/src/..svnbridge/.svnbridge deleted file mode 100644 index ab80b684..00000000 --- a/src/..svnbridge/.svnbridge +++ /dev/null @@ -1,3 +0,0 @@ -svn:ignoreZlib -Test - \ No newline at end of file diff --git a/src/..svnbridge/SSH.NET.nupkg b/src/..svnbridge/SSH.NET.nupkg deleted file mode 100644 index 08149303..00000000 --- a/src/..svnbridge/SSH.NET.nupkg +++ /dev/null @@ -1 +0,0 @@ -svn:mime-typeapplication/octet-stream \ No newline at end of file diff --git a/src/Renci.SshClient.Tests/ConnectionData.cs b/src/Renci.SshClient.Tests/ConnectionData.cs deleted file mode 100644 index 0e7b0c9b..00000000 --- a/src/Renci.SshClient.Tests/ConnectionData.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace Renci.SshClient.Tests -{ - public static class ConnectionData - { - public static string Host { get { return "oleg-centos.edc.renci.org"; } } - - public static int Port { get { return 22; } } - - public static string Username { get { return "tester"; } } - - public static string Password { get { return "tester"; } } - - public static string RsaKeyFilePath { get { return @"RSA key path"; } } - - public static string DssKeyFilePath { get { return @"DSS key path"; } } - } -} diff --git a/src/Renci.SshClient.Tests/SftpClientTests/SftpClientTest.cs b/src/Renci.SshClient.Tests/SftpClientTests/SftpClientTest.cs deleted file mode 100644 index 8a3a87f9..00000000 --- a/src/Renci.SshClient.Tests/SftpClientTests/SftpClientTest.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Renci.SshClient.Tests -{ - class SftpClientTest - { - } -} diff --git a/src/Renci.SshClient.Tests/ShellTest.cs b/src/Renci.SshClient.Tests/ShellTest.cs deleted file mode 100644 index 072932ea..00000000 --- a/src/Renci.SshClient.Tests/ShellTest.cs +++ /dev/null @@ -1,244 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Renci.SshClient.Tests -{ - /// - /// Summary description for UnitTest1 - /// - [TestClass] - public class ShellTest - { - public ShellTest() - { - // - // TODO: Add constructor logic here - // - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - #region Additional test attributes - // - // You can use the following additional attributes as you write your tests: - // - // Use ClassInitialize to run code before running the first test in the class - // [ClassInitialize()] - // public static void MyClassInitialize(TestContext testContext) { } - // - // Use ClassCleanup to run code after all tests in a class have run - // [ClassCleanup()] - // public static void MyClassCleanup() { } - // - // Use TestInitialize to run code before running each test - // [TestInitialize()] - // public void MyTestInitialize() { } - // - // Use TestCleanup to run code after each test has run - // [TestCleanup()] - // public void MyTestCleanup() { } - // - #endregion - - [TestMethod] - public void TestConnectUsingPassword() - { - var s = CreateShellUsingPassword(); - s.Connect(); - s.Disconnect(); - } - - [TestMethod] - public void TestExecuteSingleCommand() - { - var s = CreateShellUsingPassword(); - s.Connect(); - var result = ExecuteTestCommand(s); - s.Disconnect(); - - Assert.IsTrue(result); - } - - [TestMethod] - public void TestReconnecting() - { - var s = CreateShellUsingPassword(); - s.Connect(); - var result = ExecuteTestCommand(s); - s.Disconnect(); - - Assert.IsTrue(result); - - s.Connect(); - result = ExecuteTestCommand(s); - s.Disconnect(); - - Assert.IsTrue(result); - } - - [TestMethod] - public void TestMultipleThreadMultipleSessions_10000() - { - var s = CreateShellUsingPassword(); - s.Connect(); - System.Threading.Tasks.Parallel.For(0, 10000, - (counter) => - { - var result = ExecuteTestCommand(s); - Debug.WriteLine(string.Format("TestMultipleThreadMultipleConnections #{0}", counter)); - Assert.IsTrue(result); - } - ); - - s.Disconnect(); - } - - [TestMethod] - public void TestMultipleThreadMultipleConnections_10000() - { - try - { - System.Threading.Tasks.Parallel.For(0, 10000, - () => - { - var s = CreateShellUsingPassword(); - s.Connect(); - return s; - }, - (int counter, ParallelLoopState pls, SshClient s) => - { - var result = ExecuteTestCommand(s); - Debug.WriteLine(string.Format("TestMultipleThreadMultipleConnections #{0}", counter)); - Assert.IsTrue(result); - return s; - }, - (SshClient s) => - { - s.Disconnect(); - } - ); - } - catch (Exception exp) - { - Assert.Fail(exp.ToString()); - } - } - - [TestMethod] - public void TestExtendedOutput() - { - var s = CreateShellUsingPassword(); - s.Connect(); - var cmd = s.CreateCommand("echo 12345; echo 654321 >&2"); - cmd.Execute(); - var extendedData = Encoding.ASCII.GetString(cmd.ExtendedOutputStream.ToArray()); - s.Disconnect(); - - Assert.AreEqual("12345\n", cmd.Result); - Assert.AreEqual("654321\n", extendedData); - } - - [TestMethod] - public void TestInvalidCommandExecution() - { - var s = CreateShellUsingPassword(); - s.Connect(); - - var cmd = s.CreateCommand(";"); - cmd.Execute(); - if (string.IsNullOrEmpty(cmd.Error)) - { - Assert.Fail("Operation should fail"); - } - Assert.IsTrue(cmd.ExitStatus > 0); - - s.Disconnect(); - } - - [TestMethod] - public void TestInvalidCommandThenValidCommandExecution() - { - var s = CreateShellUsingPassword(); - s.Connect(); - var cmd = s.CreateCommand(";"); - cmd.Execute(); - if (string.IsNullOrEmpty(cmd.Error)) - { - Assert.Fail("Operation should fail"); - } - Assert.IsTrue(cmd.ExitStatus > 0); - - var result = ExecuteTestCommand(s); - s.Disconnect(); - - Assert.IsTrue(result); - } - - [TestMethod] - public void TestRsaKeyConnection() - { - var s = CreateShellUsingRSAKey(); - s.Connect(); - var result = ExecuteTestCommand(s); - s.Disconnect(); - Assert.IsTrue(result); - } - - [TestMethod] - public void TestDssKeyConnection() - { - var s = CreateShellUsingRSAKey(); - s.Connect(); - var result = ExecuteTestCommand(s); - s.Disconnect(); - Assert.IsTrue(result); - } - - private static SshClient CreateShellUsingPassword() - { - return new SshClient(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, ConnectionData.Password); - } - - private static SshClient CreateShellUsingRSAKey() - { - return new SshClient(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, new PrivateKeyFile(ConnectionData.RsaKeyFilePath)); - } - - private static SshClient CreateShellUsingDSSKey() - { - return new SshClient(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, new PrivateKeyFile(ConnectionData.DssKeyFilePath)); - } - - private static bool ExecuteTestCommand(SshClient s) - { - var testValue = Guid.NewGuid().ToString(); - var command = string.Format("echo {0}", testValue); - //var command = string.Format("echo {0};sleep 2s", testValue); - var cmd = s.CreateCommand(command); - var result = cmd.Execute(); - result = result.Substring(0, result.Length - 1); // Remove \n chararacter returned by command - return result.Equals(testValue); - } - - - } -} diff --git a/src/Renci.SshClient/ChannelOpeningEventArgs.cs b/src/Renci.SshClient/ChannelOpeningEventArgs.cs deleted file mode 100644 index 765ff52e..00000000 --- a/src/Renci.SshClient/ChannelOpeningEventArgs.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using Renci.SshClient.Messages.Connection; - -namespace Renci.SshClient -{ - internal class ChannelOpeningEventArgs : EventArgs - { - public ChannelOpenMessage Message { get; set; } - - } -} diff --git a/src/Renci.SshClient/Channels/ChannelSessionExec.cs b/src/Renci.SshClient/Channels/ChannelSessionExec.cs deleted file mode 100644 index 2ac617a5..00000000 --- a/src/Renci.SshClient/Channels/ChannelSessionExec.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Connection; - -namespace Renci.SshClient.Channels -{ - internal class ChannelSessionExec : ChannelSession - { - /// - /// Holds channel data stream - /// - private Stream _channelData; - - /// - /// Holds channel extended data stream - /// - private Stream _channelExtendedData; - - private ChannelAsyncResult _asyncResult; - - private AsyncCallback _callback; - - /// - /// Gets or sets a value indicating whether this channel has error. - /// - /// true if this instance has error; otherwise, false. - public bool HasError { get; set; } - - /// - /// Gets or sets the exit status. - /// - /// The exit status. - public uint ExitStatus { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - public ChannelSessionExec() - : base() - { - - } - - /// - /// Begins the execute. - /// - /// The command. - /// The output. - /// The extended output. - /// The callback. - /// The state. - /// - internal ChannelAsyncResult BeginExecute(string command, Stream output, Stream extendedOutput, AsyncCallback callback, object state) - { - // Prevent from executing BeginExecute before calling EndExecute - if (this._asyncResult != null) - { - throw new InvalidOperationException(""); - } - - // Create new AsyncResult object - this._asyncResult = new ChannelAsyncResult(this) - { - AsyncWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset), - IsCompleted = false, - AsyncState = state, - }; - - this._callback = callback; - this._channelData = output; - this._channelExtendedData = extendedOutput; - - this.Open(); - - // Send channel command request - this.SendExecRequest(command); - - return _asyncResult; - } - - /// - /// Ends the execute. - /// - /// The result. - internal void EndExecute(IAsyncResult result) - { - ChannelAsyncResult channelAsyncResult = result as ChannelAsyncResult; - - if (channelAsyncResult.Channel != this) - { - throw new InvalidOperationException("Invalid IAsyncResult parameter"); - } - - // Make sure that operation completed if not wait for it to finish - this.WaitHandle(this._asyncResult.AsyncWaitHandle); - - this.Close(); - - this._asyncResult = null; - } - - /// - /// Called when channel is closed - /// - protected override void OnClose() - { - base.OnClose(); - - if (this._channelData != null) - { - this._channelData.Flush(); - } - - if (this._channelExtendedData != null) - { - this._channelExtendedData.Flush(); - } - - this._asyncResult.IsCompleted = true; - if (this._callback != null) - { - // TODO: Execute this method on different thread since it will be run on message listener - this._callback(this._asyncResult); - } - ((EventWaitHandle)_asyncResult.AsyncWaitHandle).Set(); - } - - /// - /// Called when channel receives data. - /// - /// The data. - protected override void OnData(string data) - { - base.OnData(data); - - if (this._channelData != null) - { - foreach (var b in data) - { - this._channelData.WriteByte((byte)b); - } - } - - if (this._asyncResult != null) - { - this._asyncResult.BytesReceived += data.Length; - } - } - - /// - /// Called when channel receives extended data. - /// - /// The data. - /// The data type code. - protected override void OnExtendedData(string data, uint dataTypeCode) - { - base.OnExtendedData(data, dataTypeCode); - - if (this._channelExtendedData != null) - { - this._channelExtendedData.Write(data.GetSshBytes().ToArray(), 0, data.Length); - //foreach (var b in data) - //{ - // this._channelExtendedData.WriteByte((byte)b); - //} - } - - if (dataTypeCode == 1) - { - this.HasError = true; - } - } - - /// - /// Called when channel request command is called. - /// - /// Name of the request. - /// if set to true then need to send reply to server. - /// The command. - /// Name of the subsystem. - /// The exit status. - protected override void OnRequest(RequestInfo info) - { - base.OnRequest(info); - - Message replyMessage = new ChannelFailureMessage() - { - LocalChannelNumber = this.LocalChannelNumber, - }; - - if (info is ExitStatusRequestInfo) - { - ExitStatusRequestInfo exitStatusInfo = info as ExitStatusRequestInfo; - - this.ExitStatus = exitStatusInfo.ExitStatus; - - replyMessage = new ChannelSuccessMessage() - { - LocalChannelNumber = this.LocalChannelNumber, - }; - } - - if (info.WantReply) - { - this.SendMessage(replyMessage); - } - } - - /// - /// Called when object is being disposed. - /// - protected override void OnDisposing() - { - } - } -} diff --git a/src/Renci.SshClient/Channels/ChannelSessionSftp.cs b/src/Renci.SshClient/Channels/ChannelSessionSftp.cs deleted file mode 100644 index 8284fd17..00000000 --- a/src/Renci.SshClient/Channels/ChannelSessionSftp.cs +++ /dev/null @@ -1,580 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using Renci.SshClient.Common; -using Renci.SshClient.Messages.Sftp; - -namespace Renci.SshClient.Channels -{ - // TODO: Add Begin* and End* methods for async calls - - internal class ChannelSessionSftp : ChannelSession - { - private EventWaitHandle _channelRequestSuccessWaitHandle = new AutoResetEvent(false); - - private EventWaitHandle _responseMessageReceivedWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); - - private uint _requestId; - - private SftpMessage _responseMessage; - - private string _remoteCurrentDir; - - private string _localCurentDir; - - private StringBuilder _packetData; - - // TODO: Repalce with SFTP specific async class if needed - private CommandAsyncResult _asyncResult; - - public ChannelSessionSftp() - : base() - { - - } - - public override void Open() - { - base.Open(); - - // Send channel command request - this.SendSubsystemRequest("sftp"); - - this.WaitHandle(this._channelRequestSuccessWaitHandle); - - this.SendMessage(new InitMessage - { - Version = 3, - }); - - var versionMessage = this.ReceiveMessage(); - - if (versionMessage == null) - { - throw new InvalidOperationException("Version message expected."); - } - - if (versionMessage.Version != 3) - { - throw new NotSupportedException(string.Format("Server SFTP version {0} is not supported.", versionMessage.Version)); - } - - // Get default current directories - var files = this.GetRealPath("."); - - this._remoteCurrentDir = files.First().Name; - this._localCurentDir = Directory.GetCurrentDirectory(); - } - - public void UploadFile(Stream source, string destination) - { - this.Open(); - - string handle = string.Empty; - - try - { - handle = this.OpenRemoteFile(destination, Flags.Write | Flags.CreateNewOrOpen | Flags.Truncate); - - var buffer = new byte[1024]; - ulong offset = 0; - var bytesRead = 0; - while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) - { - this.RemoteWrite(handle, offset, buffer.Take(bytesRead).GetSshString()); - offset += (ulong)buffer.Length; - } - } - finally - { - if (!string.IsNullOrEmpty(handle)) - this.CloseRemoteHandle(handle); - } - - this.Close(); - } - - internal void DownloadFile(string fileName, Stream destination) - { - this.Open(); - - string handle = string.Empty; - - try - { - handle = this.OpenRemoteFile(fileName, Flags.Read); - - ulong offset = 0; - uint bufferSize = 1024; - string data; - - while ((data = this.RemoteRead(handle, offset, bufferSize)) != null) - { - var fileData = data.GetSshBytes().ToArray(); - destination.Write(fileData, 0, fileData.Length); - destination.Flush(); - offset += (ulong)fileData.Length; - } - - } - finally - { - if (!string.IsNullOrEmpty(handle)) - this.CloseRemoteHandle(handle); - } - - this.Close(); - } - - public void CreateDirectory(string directoryName) - { - this.Open(); - - this.CreateRemoteDirectory(directoryName); - - this.Close(); - } - - public void RemoveDirectory(string directoryName) - { - this.Open(); - - this.RemoveRemoteDirectory(directoryName); - - this.Close(); - } - - public void RemoveFile(string fileName) - { - this.Open(); - - this.RemoveRemoteFile(fileName); - - this.Close(); - } - - public void RenameFile(string oldFileName, string newFileName) - { - this.Open(); - - this.RenameRemoteFile(oldFileName, newFileName); - - this.Close(); - } - - public IEnumerable ListDirectory(string path) - { - // Open channel - this.Open(); - - string handle = string.Empty; - IEnumerable files = null; - - try - { - // Open directory - handle = this.OpenRemoteDirectory(path); - - // Read directory data - files = this.ReadRemoteDirectory(handle); - } - finally - { - // Close directory - if (!string.IsNullOrEmpty(handle)) - this.CloseRemoteHandle(handle); - } - - // Read directory - this.Close(); - - return files; - - } - - protected override void OnSuccess() - { - base.OnSuccess(); - - this._channelRequestSuccessWaitHandle.Set(); - } - - - protected override void OnData(string data) - { - base.OnData(data); - - if (this._packetData == null) - { - var packetLength = (uint)(data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]); - - this._packetData = new StringBuilder((int)packetLength, (int)packetLength); - this._packetData.Append(data.GetSshBytes().Skip(4).GetSshString()); - } - else - { - this._packetData.Append(data); - } - - if (this._packetData.Length < this._packetData.MaxCapacity) - { - // Wait for more packet data - return; - } - - - dynamic sftpMessage = SftpMessage.Load(this._packetData.ToString().GetSshBytes()); - - this._packetData = null; - - if (sftpMessage.RequestId != null) - { - if (sftpMessage.RequestId != this._requestId) - { - throw new InvalidOperationException("Invalid request id."); - } - - this._requestId++; - } - - this._responseMessage = sftpMessage; - - this._responseMessageReceivedWaitHandle.Set(); - } - - private T ReceiveMessage() where T : SftpMessage - { - var message = this.ReceiveMessage() as T; - - if (message == null) - { - throw new InvalidOperationException(string.Format("Message of type '{0}' expected in this context.", typeof(T).Name)); - } - return message; - - } - - private SftpMessage ReceiveMessage() - { - this.WaitHandle(this._responseMessageReceivedWaitHandle); - - var statusMessage = this._responseMessage as StatusMessage; - - if (statusMessage != null) - { - // Handle error status messages - switch (statusMessage.StatusCode) - { - case StatusCodes.Ok: - break; - case StatusCodes.Eof: - break; - case StatusCodes.NoSuchFile: - throw new FileNotFoundException("File or directory not found on the remote server."); - case StatusCodes.PermissionDenied: - throw new NotImplementedException(); - case StatusCodes.Failure: - throw new InvalidOperationException("Operation failed."); - case StatusCodes.BadMessage: - throw new NotImplementedException(); - case StatusCodes.NoConnection: - throw new NotImplementedException(); - case StatusCodes.ConnectionLost: - throw new NotImplementedException(); - case StatusCodes.OperationUnsupported: - throw new NotSupportedException("Operation is not supported."); - default: - break; - } - } - - return this._responseMessage; - } - - private void SendMessage(SftpMessage sftpMessage) - { - sftpMessage.RequestId = this._requestId; - var message = new SftpDataMessage - { - LocalChannelNumber = this.RemoteChannelNumber, - Message = sftpMessage, - }; - - this.SendMessage(message); - - this._responseMessageReceivedWaitHandle.Reset(); - } - - private string OpenRemoteFile(string fileName, Flags flags) - { - this.SendMessage(new OpenMessage - { - Filename = fileName, - Flags = flags, - }); - - var handleMessage = this.ReceiveMessage(); - - return handleMessage.Handle; - } - - private string RemoteRead(string handle, ulong offset, uint length) - { - this.SendMessage(new ReadMessage - { - Handle = handle, - Offset = offset, - Length = length, - }); - - var message = this.ReceiveMessage(); - - var statusMessage = message as StatusMessage; - var dataMessage = message as DataMessage; - - if (statusMessage != null) - { - if (statusMessage.StatusCode == StatusCodes.Eof) - { - return null; - } - - throw new InvalidOperationException("Invalid status code."); - } - else if (dataMessage != null) - { - if (this._asyncResult != null) - { - this._asyncResult.BytesReceived += dataMessage.Data.Length; - } - return dataMessage.Data; - } - else - { - throw new InvalidOperationException(string.Format("Message type '{0}' is not valid in this context.", message.SftpMessageType)); - } - } - - private void RemoteWrite(string handle, ulong offset, string data) - { - this.SendMessage(new WriteMessage - { - Handle = handle, - Offset = offset, - Data = data, - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - - if (this._asyncResult != null) - { - this._asyncResult.BytesSent += data.Length; - } - - } - - private void RemoveRemoteFile(string fileName) - { - this.SendMessage(new RemoveMessage - { - Filename = fileName, - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private void RenameRemoteFile(string oldFileName, string newFileName) - { - this.SendMessage(new RenameMessage - { - OldPath = oldFileName, - NewPath = newFileName, - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private void CreateRemoteDirectory(string directoryName) - { - this.SendMessage(new MkDirMessage - { - Path = directoryName, - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private void RemoveRemoteDirectory(string directoryName) - { - this.SendMessage(new RmDirMessage - { - Path = directoryName, - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private string OpenRemoteDirectory(string path) - { - this.SendMessage(new OpenDirMessage - { - Path = path, - }); - - var handleMessage = this.ReceiveMessage(); - - return handleMessage.Handle; - } - - private IEnumerable ReadRemoteDirectory(string handle) - { - this.SendMessage(new ReadDirMessage - { - Handle = handle, - }); - - var message = this.ReceiveMessage(); - - return message.Files; - } - - private void CloseRemoteHandle(string handle) - { - this.SendMessage(new CloseMessage - { - Handle = handle, - }); - - var status = this.ReceiveMessage(); - var attempts = 0; - // If close fails wait a litle a try to close it again, in case server flushed data into the file during close - while (status.StatusCode != StatusCodes.Ok && attempts++ < this.ConnectionInfo.RetryAttempts) - { - Thread.Sleep(50); - status = this.ReceiveMessage(); - } - - if (status.StatusCode != StatusCodes.Ok) - { - throw new InvalidOperationException(string.Format("File handle cannot be closed after {0} attempts.", attempts)); - } - } - - private Attributes GetRemoteFileAttributes(string filename) - { - this.SendMessage(new StatMessage - { - Path = filename, - }); - - var message = this.ReceiveMessage(); - - return message.Attributes; - } - - private Attributes GetRemoteLinkFileAttributes(string filename) - { - this.SendMessage(new LStatMessage - { - Path = filename, - }); - - var message = this.ReceiveMessage(); - - return message.Attributes; - } - - private Attributes GetRemoteOpenFileAttributes(string handle) - { - this.SendMessage(new FStatMessage - { - Handle = handle, - }); - - var message = this.ReceiveMessage(); - - return message.Attributes; - } - - private void SetRemoteFileAttributes(string filename, Attributes attributes) - { - this.SendMessage(new SetStatMessage - { - Path = filename, - Attributes = attributes - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private void SetRemoteOpenFileAttributes(string handle, Attributes attributes) - { - this.SendMessage(new FSetStatMessage - { - Handle = handle, - Attributes = attributes - }); - - var message = this.ReceiveMessage(); - - this.EnsureStatusCode(message, StatusCodes.Ok); - } - - private IEnumerable GetRealPath(string path) - { - this.SendMessage(new RealPathMessage - { - Path = path, - }); - - var message = this.ReceiveMessage(); - - return message.Files; - - } - - private void EnsureStatusCode(StatusMessage message, StatusCodes code) - { - if (message.StatusCode == code) - { - return; - } - else - { - throw new InvalidOperationException("Invalid status code."); - } - } - - #region IDisposable Members - - protected override void OnDisposing() - { - // Dispose managed resources. - if (this._channelRequestSuccessWaitHandle != null) - { - this._channelRequestSuccessWaitHandle.Dispose(); - } - if (this._responseMessageReceivedWaitHandle != null) - { - this._responseMessageReceivedWaitHandle.Dispose(); - } - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Channels/ChannelSessionShell.cs b/src/Renci.SshClient/Channels/ChannelSessionShell.cs deleted file mode 100644 index 4bcb9037..00000000 --- a/src/Renci.SshClient/Channels/ChannelSessionShell.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.IO; -using System.Linq; -using System.Threading; -using Renci.SshClient.Messages.Connection; - -namespace Renci.SshClient.Channels -{ - internal class ChannelSessionShell : ChannelSession - { - - private EventWaitHandle _success = new AutoResetEvent(false); - - /// - /// Holds channel data stream - /// - private Stream _channelData; - - /// - /// Holds channel extended data stream - /// - private Stream _channelExtendedData; - - public void Start(Stream output, Stream extendedOutput) - { - this.Open(); - - this._channelData = output; - this._channelExtendedData = extendedOutput; - - this.SendPseudoTerminalRequest("xterm", 80, 24, 640, 240, ""); - - _success.WaitOne(); - - this.SendShellRequest(); - } - - public void Stop() - { - // Close channel - this.Close(); - } - - protected override void OnSuccess() - { - base.OnSuccess(); - - _success.Set(); - } - - protected override void OnFailure() - { - base.OnFailure(); - } - - protected override void OnData(string data) - { - base.OnData(data); - - this._channelData.Write(data.GetSshBytes().ToArray(), 0, data.Length); - this._channelData.Flush(); - } - - protected override void OnExtendedData(string data, uint dataTypeCode) - { - base.OnExtendedData(data, dataTypeCode); - - // TODO: dataTypeCode is not handled - this._channelExtendedData.Write(data.GetSshBytes().ToArray(), 0, data.Length); - this._channelExtendedData.Flush(); - } - - public void Send(string data) - { - this.SendMessage(new ChannelDataMessage - { - LocalChannelNumber = this.RemoteChannelNumber, - Data = data, - }); - } - - public class ShellStream : MemoryStream - { - public ShellStream() - { - - } - - public override void Write(byte[] buffer, int offset, int count) - { - base.Write(buffer, offset, count); - } - - public override void WriteByte(byte value) - { - base.WriteByte(value); - } - } - } -} diff --git a/src/Renci.SshClient/Common/BlockingStack.cs b/src/Renci.SshClient/Common/BlockingStack.cs deleted file mode 100644 index de4c50b7..00000000 --- a/src/Renci.SshClient/Common/BlockingStack.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Threading; - -namespace Renci.SshClient.Common -{ - public class BlockingStack : IEnumerable, ICollection, IEnumerable - { - private Stack _stack; - - public BlockingStack() - { - this._stack = new Stack(); - } - - public BlockingStack(IEnumerable collection) - { - this._stack = new Stack(collection); - } - - public BlockingStack(int capacity) - { - this._stack = new Stack(capacity); - } - - // Summary: - // Gets the number of elements contained in the System.Collections.Generic.Stack. - // - // Returns: - // The number of elements contained in the System.Collections.Generic.Stack. - public int Count - { - get - { - return this._stack.Count; - } - } - - public void Clear() - { - lock (this) - { - this._stack.Clear(); - Monitor.PulseAll(this); - } - } - - public bool Contains(T item) - { - return this._stack.Contains(item); - } - - public void CopyTo(T[] array, int arrayIndex) - { - lock (this) - { - this._stack.CopyTo(array, arrayIndex); - Monitor.PulseAll(this); - } - } - - public T Peek() - { - return this._stack.Peek(); - } - - public T Pop() - { - lock (this) - { - var result = this._stack.Pop(); - Monitor.PulseAll(this); - return result; - } - } - - public T WaitAndPop() - { - lock (this) - { - // Wait for item to be added to the stack - while (this._stack.Count == 0) - { - Monitor.Wait(this); - } - var result = this._stack.Pop(); - Monitor.PulseAll(this); - return result; - } - } - - public void Push(T item) - { - lock (this) - { - this._stack.Push(item); - Monitor.PulseAll(this); - } - } - - public T[] ToArray() - { - lock (this) - { - var result = this._stack.ToArray(); - Monitor.PulseAll(this); - return result; - } - } - - public void TrimExcess() - { - lock (this) - { - this._stack.TrimExcess(); - Monitor.PulseAll(this); - } - } - - #region ICollection Members - - public void CopyTo(System.Array array, int index) - { - throw new System.NotImplementedException(); - } - - public bool IsSynchronized - { - get { return true; } - } - - public object SyncRoot - { - get { return this; } - } - - #endregion - - - #region IEnumerable Members - - public IEnumerator GetEnumerator() - { - return this._stack.GetEnumerator(); - } - - #endregion - - #region IEnumerable Members - - IEnumerator IEnumerable.GetEnumerator() - { - return this._stack.GetEnumerator(); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Common/ConnectingEventArgs.cs b/src/Renci.SshClient/Common/ConnectingEventArgs.cs deleted file mode 100644 index 8cc14d83..00000000 --- a/src/Renci.SshClient/Common/ConnectingEventArgs.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Renci.SshClient.Common -{ - public class ConnectingEventArgs : EventArgs - { - public IDictionary KeyExchangeAlgorithms { get; private set; } - - public IDictionary Encryptions { get; private set; } - - public IDictionary HmacAlgorithms { get; private set; } - - public IDictionary HostKeyAlgorithms { get; private set; } - - public IDictionary SupportedAuthenticationMethods { get; private set; } - - public IDictionary CompressionAlgorithms { get; private set; } - - public string Host { get; set; } - - public int Port { get; set; } - - public string Username { get; set; } - - public string Password { get; set; } - - public ICollection KeyFiles { get; set; } - - public TimeSpan Timeout { get; set; } - - public int RetryAttempts { get; set; } - - public int MaxSessions { get; set; } - - public ConnectingEventArgs( - IDictionary keyExchangeAlgorithms, - IDictionary encryptions, - IDictionary hmacAlgorithms, - IDictionary hostKeyAlgorithms, - IDictionary supportedAuthenticationMethods, - IDictionary compressionAlgorithms) - { - this.KeyExchangeAlgorithms = keyExchangeAlgorithms; - this.Encryptions = encryptions; - this.HmacAlgorithms = hmacAlgorithms; - this.HostKeyAlgorithms = hostKeyAlgorithms; - this.SupportedAuthenticationMethods = supportedAuthenticationMethods; - this.CompressionAlgorithms = compressionAlgorithms; - } - } -} diff --git a/src/Renci.SshClient/Common/DataReceivedEventArgs.cs b/src/Renci.SshClient/Common/DataReceivedEventArgs.cs deleted file mode 100644 index 3ec0e6ec..00000000 --- a/src/Renci.SshClient/Common/DataReceivedEventArgs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Renci.SshClient.Common -{ - internal class DataReceivedEventArgs : EventArgs - { - public string Data { get; private set; } - - public DataReceivedEventArgs(string data) - { - this.Data = data; - } - } -} diff --git a/src/Renci.SshClient/Common/FtpFileInfo.cs b/src/Renci.SshClient/Common/FtpFileInfo.cs deleted file mode 100644 index 7a479415..00000000 --- a/src/Renci.SshClient/Common/FtpFileInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Renci.SshClient.Common -{ - public class FtpFileInfo - { - public string Name { get; set; } - - public string FullName { get; set; } - - public DateTime? CreationTime { get; set; } - - public DateTime? LastAccessTime { get; set; } - - public DateTime? LastModifyTime { get; set; } - - public ulong? Size { get; set; } - - public uint? UserId { get; set; } - - public uint? GroupId { get; set; } - - public uint? Permissions { get; set; } - - public IDictionary Extentions { get; set; } - - } -} diff --git a/src/Renci.SshClient/Common/MessageReceivedEventArgs.cs b/src/Renci.SshClient/Common/MessageReceivedEventArgs.cs deleted file mode 100644 index c5b59e21..00000000 --- a/src/Renci.SshClient/Common/MessageReceivedEventArgs.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using Renci.SshClient.Messages; - -namespace Renci.SshClient.Common -{ - internal class MessageReceivedEventArgs : EventArgs - { - public Message Message { get; private set; } - - public MessageReceivedEventArgs(Message message) - { - this.Message = message; - } - } -} diff --git a/src/Renci.SshClient/Connection.cs b/src/Renci.SshClient/Connection.cs deleted file mode 100644 index 5c6a5b2c..00000000 --- a/src/Renci.SshClient/Connection.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace Renci.SshClient -{ - public class Connection - { - private Session _session; - - public ConnectionInfo ConnectionInfo { get; private set; } - - private Shell _shell; - public Shell Shell - { - get - { - if (this._shell == null) - { - this._shell = new Shell(this._session); - } - return this._shell; - } - } - - private Sftp _sftp; - - public Sftp Sftp - { - get - { - if (this._sftp == null) - { - this._sftp = new Sftp(this._session); - } - return this._sftp; - } - } - - - public Connection(ConnectionInfo connectionInfo) - { - this.ConnectionInfo = connectionInfo; - this._session = Session.CreateSession(this.ConnectionInfo); - } - - public Connection(string host, int port, string username, string password) - : this(new ConnectionInfo - { - Host = host, - Port = port, - Username = username, - Password = password, - }) - { - } - - public Connection(string host, string username, string password) - : this(new ConnectionInfo - { - Host = host, - Username = username, - Password = password, - }) - { - } - - public Connection(string host, int port, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo - { - Host = host, - Port = port, - Username = username, - KeyFile = keyFile, - }) - { - } - - public Connection(string host, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo - { - Host = host, - Username = username, - KeyFile = keyFile, - }) - { - } - - - public void Connect() - { - this._session.Connect(); - } - - public void Disconnect() - { - this._session.Disconnect(); - } - } -} diff --git a/src/Renci.SshClient/Documentation/Content/Extensibility.AddAuthenticationMethod.aml b/src/Renci.SshClient/Documentation/Content/Extensibility.AddAuthenticationMethod.aml deleted file mode 100644 index 0b213804..00000000 --- a/src/Renci.SshClient/Documentation/Content/Extensibility.AddAuthenticationMethod.aml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - Required introduction - - - - - Procedure title - - - - First step - - - - - Second step - - - - - - -
- Optional section title - - - Procedure #2 - - - - First step - - - - - Second step - - - - - - -
- - - - -
-
\ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/Extensibility.AddEncryption.aml b/src/Renci.SshClient/Documentation/Content/Extensibility.AddEncryption.aml deleted file mode 100644 index 83e3d974..00000000 --- a/src/Renci.SshClient/Documentation/Content/Extensibility.AddEncryption.aml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - Required introduction - - - - - Procedure title - - - - First step - - - - - Second step - - - - - - -
- Optional section title - - - Procedure #2 - - - - First step - - - - - Second step - - - - - - -
- - - - -
-
\ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/Extensibility.AddHashAlgorithm.aml b/src/Renci.SshClient/Documentation/Content/Extensibility.AddHashAlgorithm.aml deleted file mode 100644 index 90218463..00000000 --- a/src/Renci.SshClient/Documentation/Content/Extensibility.AddHashAlgorithm.aml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - Required introduction - - - - - Procedure title - - - - First step - - - - - Second step - - - - - - -
- Optional section title - - - Procedure #2 - - - - First step - - - - - Second step - - - - - - -
- - - - -
-
\ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/Extensibility.aml b/src/Renci.SshClient/Documentation/Content/Extensibility.aml deleted file mode 100644 index 6377bdce..00000000 --- a/src/Renci.SshClient/Documentation/Content/Extensibility.aml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - Required introduction - - - - "In This Section" info - - - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/HowTo.Sftp.aml b/src/Renci.SshClient/Documentation/Content/HowTo.Sftp.aml deleted file mode 100644 index d84d16c4..00000000 --- a/src/Renci.SshClient/Documentation/Content/HowTo.Sftp.aml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - Required introduction - - - - - - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.Run.aml b/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.Run.aml deleted file mode 100644 index 22fd4e42..00000000 --- a/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.Run.aml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - Optional summary abstract - - - Required introduction - - - - Procedure title - - - - First step - - - - - Second step - - - - Optional conclusion - - Optional code example - - Optional discussion of error handling and other - issues related to writing solid code. - Optional discussion of security issues. - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.aml b/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.aml deleted file mode 100644 index 276d75c2..00000000 --- a/src/Renci.SshClient/Documentation/Content/HowTo.SshCommand.aml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - Required introduction - - - - - - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/HowTo.aml b/src/Renci.SshClient/Documentation/Content/HowTo.aml deleted file mode 100644 index 0b1008d5..00000000 --- a/src/Renci.SshClient/Documentation/Content/HowTo.aml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - Required introduction - - - - - - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Documentation/Content/Introduction.aml b/src/Renci.SshClient/Documentation/Content/Introduction.aml deleted file mode 100644 index e7baf7c1..00000000 --- a/src/Renci.SshClient/Documentation/Content/Introduction.aml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - Optional summary abstract - - - Required introduction - - Optional description of content in this section - - - Optional external resources section - - - - - \ No newline at end of file diff --git a/src/Renci.SshClient/Messages/Authentication/Methods.cs b/src/Renci.SshClient/Messages/Authentication/Methods.cs deleted file mode 100644 index 361973ad..00000000 --- a/src/Renci.SshClient/Messages/Authentication/Methods.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Renci.SshClient.Messages.Authentication -{ - public enum Methods - { - None, - PublicKey, - Password, - Hostbased - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelOpenDirectTcpIPMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelOpenDirectTcpIPMessage.cs deleted file mode 100644 index d9a95ef1..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelOpenDirectTcpIPMessage.cs +++ /dev/null @@ -1,33 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelOpenDirectTcpIPMessage : ChannelOpenMessage - { - public string HostToConnect { get; private set; } - - public uint PortToConnect { get; private set; } - - public string OriginatorIP { get; private set; } - - public uint OriginatorPort { get; private set; } - - protected override void LoadData() - { - base.LoadData(); - this.HostToConnect = this.ReadString(); - this.PortToConnect = this.ReadUInt32(); - this.OriginatorIP = this.ReadString(); - this.OriginatorPort = this.ReadUInt32(); - } - - protected override void SaveData() - { - base.SaveData(); - this.Write(this.HostToConnect); - this.Write(this.PortToConnect); - this.Write(this.OriginatorIP); - this.Write(this.OriginatorPort); - - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestEnvironmentVariableMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestEnvironmentVariableMessage.cs deleted file mode 100644 index ceb10fc6..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestEnvironmentVariableMessage.cs +++ /dev/null @@ -1,30 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestEnvironmentVariableMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "env"; - - public string VariableName { get; set; } - - public string VariableValue { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.VariableName = this.ReadString(); - this.VariableValue = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.VariableName); - this.Write(this.VariableValue); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExecMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExecMessage.cs deleted file mode 100644 index 51fe229b..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExecMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestExecMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "exec"; - - public string Command { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.Command = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.Command); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitSignalMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitSignalMessage.cs deleted file mode 100644 index af1ce2e9..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitSignalMessage.cs +++ /dev/null @@ -1,38 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestExitSignalMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "exit-signal"; - - public string SignalName { get; set; } - - public bool CoreDumped { get; set; } - - public string ErrorMessage { get; set; } - - public string Language { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.SignalName = this.ReadString(); - this.CoreDumped = this.ReadBoolean(); - this.ErrorMessage = this.ReadString(); - this.Language = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.SignalName); - this.Write(this.CoreDumped); - this.Write(this.ErrorMessage); - this.Write(this.Language); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitStatusMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitStatusMessage.cs deleted file mode 100644 index a84f840e..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestExitStatusMessage.cs +++ /dev/null @@ -1,23 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestExitStatusMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "exit-status"; - - public uint ExitStatus { get; set; } - - protected override void LoadData() - { - base.LoadData(); - this.ExitStatus = this.ReadUInt32(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - base.SaveData(); - this.Write(this.ExitStatus); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestPseudoTerminalMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestPseudoTerminalMessage.cs deleted file mode 100644 index 587d1bc5..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestPseudoTerminalMessage.cs +++ /dev/null @@ -1,44 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestPseudoTerminalMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "pty-req"; - - public string EnvironmentVariable { get; set; } - - public uint Columns { get; set; } - - public uint Rows { get; set; } - - public uint PixelWidth { get; set; } - - public uint PixelHeight { get; set; } - - public string TerminalMode { get; set; } - - protected override void LoadData() - { - base.LoadData(); - this.EnvironmentVariable = this.ReadString(); - this.Columns = this.ReadUInt32(); - this.Rows = this.ReadUInt32(); - this.PixelWidth = this.ReadUInt32(); - this.PixelHeight = this.ReadUInt32(); - this.TerminalMode = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - base.SaveData(); - this.Write(this.EnvironmentVariable); - this.Write(this.Columns); - this.Write(this.Rows); - this.Write(this.Rows); - this.Write(this.PixelHeight); - this.Write(this.TerminalMode); - - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestShellMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestShellMessage.cs deleted file mode 100644 index 2eeb4a72..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestShellMessage.cs +++ /dev/null @@ -1,19 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestShellMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "shell"; - - protected override void LoadData() - { - base.LoadData(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - base.SaveData(); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSignalMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSignalMessage.cs deleted file mode 100644 index dcee7d7e..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSignalMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestSignalMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "signal"; - - public string SignalName { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.SignalName = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.SignalName); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSubsystemMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSubsystemMessage.cs deleted file mode 100644 index 34ddabe4..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestSubsystemMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestSubsystemMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "subsystem"; - - public string SubsystemName { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.SubsystemName = this.ReadString(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.SubsystemName); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestWindowChangeMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestWindowChangeMessage.cs deleted file mode 100644 index 06aac41b..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestWindowChangeMessage.cs +++ /dev/null @@ -1,38 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestWindowChangeMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "window-change"; - - public uint Columns { get; set; } - - public uint Rows { get; set; } - - public uint Width { get; set; } - - public uint Height { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.Columns = this.ReadUInt32(); - this.Rows = this.ReadUInt32(); - this.Width = this.ReadUInt32(); - this.Height = this.ReadUInt32(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.Columns); - this.Write(this.Rows); - this.Write(this.Width); - this.Write(this.Height); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestX11ForwardingMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestX11ForwardingMessage.cs deleted file mode 100644 index 7e34813e..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestX11ForwardingMessage.cs +++ /dev/null @@ -1,38 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestX11ForwardingMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "x11-req"; - - public bool IsSingleConnection { get; set; } - - public string AuthenticationProtocol { get; set; } - - public string AuthenticationCookie { get; set; } - - public uint ScreenNumber { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.IsSingleConnection = this.ReadBoolean(); - this.AuthenticationProtocol = this.ReadString(); - this.AuthenticationCookie = this.ReadString(); - this.ScreenNumber = this.ReadUInt32(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.IsSingleConnection); - this.Write(this.AuthenticationProtocol); - this.Write(this.AuthenticationCookie); - this.Write(this.ScreenNumber); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestXonXoffMessage.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestXonXoffMessage.cs deleted file mode 100644 index ad1a1c04..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequest/ChannelRequestXonXoffMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace Renci.SshClient.Messages.Connection -{ - internal class ChannelRequestXonXoffMessage : ChannelRequestMessage - { - public const string REQUEST_NAME = "xon-xoff"; - - public bool ClientCanDo { get; set; } - - protected override void LoadData() - { - base.LoadData(); - - this.ClientCanDo = this.ReadBoolean(); - } - - protected override void SaveData() - { - this.RequestName = REQUEST_NAME; - - base.SaveData(); - - this.Write(this.ClientCanDo); - } - } -} diff --git a/src/Renci.SshClient/Messages/Connection/ChannelRequestNames.cs b/src/Renci.SshClient/Messages/Connection/ChannelRequestNames.cs deleted file mode 100644 index 8ad83d0d..00000000 --- a/src/Renci.SshClient/Messages/Connection/ChannelRequestNames.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Renci.SshClient.Messages.Connection -{ - internal enum ChannelRequestNames - { - /// - /// pty-req - /// - PseudoTerminal, - /// - /// x11-req - /// - X11Forwarding, - /// - /// env - /// - EnvironmentVariable, - /// - /// shell - /// - Shell, - /// - /// exec - /// - Exec, - /// - /// subsystem - /// - Subsystem, - /// - /// window-change - /// - WindowChange, - /// - /// xon-xoff - /// - XonXoff, - /// - /// signal - /// - Signal, - /// - /// exit-status - /// - ExitStatus, - /// - /// exit-signal - /// - ExitSignal - } -} diff --git a/src/Renci.SshClient/Messages/MessageTypes.cs b/src/Renci.SshClient/Messages/MessageTypes.cs deleted file mode 100644 index 6d014abc..00000000 --- a/src/Renci.SshClient/Messages/MessageTypes.cs +++ /dev/null @@ -1,161 +0,0 @@ -namespace Renci.SshClient.Messages -{ - /// - /// - /// - public enum MessageTypes : byte - { - /// - /// {35A90EBF-F421-44A3-BE3A-47C72AFE47FE} - /// - None = 0, - /// - /// SSH_MSG_DISCONNECT - /// - Disconnect = 1, - /// - /// SSH_MSG_IGNORE - /// - Ignore = 2, - /// - /// SSH_MSG_UNIMPLEMENTED - /// - Unimplemented = 3, - /// - /// SSH_MSG_DEBUG - /// - Debug = 4, - /// - /// SSH_MSG_SERVICE_REQUEST - /// - ServiceRequest = 5, - /// - /// SSH_MSG_SERVICE_ACCEPT - /// - ServiceAcceptRequest = 6, - - /// - /// SSH_MSG_KEXINIT - /// - KeyExchangeInit = 20, - /// - /// SSH_MSG_NEWKEYS - /// - NewKeys = 21, - /// - /// SSH_MSG_KEXDH_INIT - /// - DiffieHellmanKeyExchangeInit = 30, - /// - /// SSH_MSG_KEXDH_REPLY - /// - KeyExchangeDhReply = 31, - /// - /// SSH_MSG_KEX_DH_GEX_GROUP - /// - KeyExchangeDhGroupExchangeGroup = 31, - /// - /// SSH_MSG_KEX_DH_GEX_INIT - /// - KeyExchangeDhGroupExchangeInit = 32, - /// - /// SSH_MSG_KEX_DH_GEX_REPLY - /// - KeyExchangeDhGroupExchangeReply = 33, - /// - /// SSH_MSG_KEX_DH_GEX_REQUEST - /// - KeyExchangeDhGroupExchangeRequest = 34, - - /// - /// SSH_MSG_USERAUTH_REQUEST - /// - UserAuthenticationRequest = 50, - /// - /// SSH_MSG_USERAUTH_FAILURE - /// - UserAuthenticationFailure = 51, - /// - /// SSH_MSG_USERAUTH_SUCCESS - /// - UserAuthenticationSuccess = 52, - /// - /// SSH_MSG_USERAUTH_BANNER - /// - UserAuthenticationBanner = 53, - /// - /// SSH_MSG_USERAUTH_INFO_REQUEST - /// - UserAuthenticationInformationRequest = 60, - /// - /// SSH_MSG_USERAUTH_INFO_RESPONSE - /// - UserAuthenticationInformationResponse = 61, - /// - /// SSH_MSG_USERAUTH_PK_OK - /// - UserAuthenticationPublicKey = 60, - /// - /// SSH_MSG_USERAUTH_PASSWD_CHANGEREQ - /// - UserAuthenticationPasswordChangeRequired = 60, - - - /// - /// SSH_MSG_GLOBAL_REQUEST - /// - GlobalRequest = 80, - /// - /// SSH_MSG_REQUEST_SUCCESS - /// - RequestSuccess = 81, - /// - /// SSH_MSG_REQUEST_FAILURE - /// - RequestFailure = 82, - /// - /// SSH_MSG_CHANNEL_OPEN - /// - ChannelOpen = 90, - /// - /// SSH_MSG_CHANNEL_OPEN_CONFIRMATION - /// - ChannelOpenConfirmation = 91, - /// - /// SSH_MSG_CHANNEL_OPEN_FAILURE - /// - ChannelOpenFailure = 92, - /// - /// SSH_MSG_CHANNEL_WINDOW_ADJUST - /// - ChannelWindowAdjust = 93, - /// - /// SSH_MSG_CHANNEL_DATA - /// - ChannelData = 94, - /// - /// SSH_MSG_CHANNEL_EXTENDED_DATA - /// - ChannelExtendedData = 95, - /// - /// SSH_MSG_CHANNEL_EOF - /// - ChannelEof = 96, - /// - /// SSH_MSG_CHANNEL_CLOSE - /// - ChannelClose = 97, - /// - /// SSH_MSG_CHANNEL_REQUEST - /// - ChannelRequest = 98, - /// - /// SSH_MSG_CHANNEL_SUCCESS - /// - ChannelSuccess = 99, - /// - /// SSH_MSG_CHANNEL_FAILURE - /// - ChannelFailure = 100, - } -} diff --git a/src/Renci.SshClient/RequestSuccessEventArgs.cs b/src/Renci.SshClient/RequestSuccessEventArgs.cs deleted file mode 100644 index 78e17fea..00000000 --- a/src/Renci.SshClient/RequestSuccessEventArgs.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Renci.SshClient -{ - internal class RequestSuccessEventArgs : EventArgs - { - public uint BoundPort { get; set; } - } -} diff --git a/src/Renci.SshClient/Security/CipherAES128.cs b/src/Renci.SshClient/Security/CipherAES128.cs deleted file mode 100644 index 534743cd..00000000 --- a/src/Renci.SshClient/Security/CipherAES128.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; - -namespace Renci.SshClient.Security -{ - internal class CipherAES128 : Cipher, IDisposable - { - private SymmetricAlgorithm _algorithm; - - private ICryptoTransform _encryptor; - - private ICryptoTransform _decryptor; - - public override string Name - { - get { return "aes128-cbc"; } - } - - public override int KeySize - { - get - { - return this._algorithm.KeySize; - } - } - - public override int BlockSize - { - get - { - return this._algorithm.BlockSize / 8; - } - } - - public CipherAES128() - { - this._algorithm = new System.Security.Cryptography.RijndaelManaged(); - this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC; - this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None; - } - - public override IEnumerable Encrypt(IEnumerable data) - { - if (this._encryptor == null) - { - this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()); - } - - var input = data.ToArray(); - var output = new byte[input.Length]; - var writtenBytes = this._encryptor.TransformBlock(input, 0, input.Length, output, 0); - - if (writtenBytes < input.Length) - { - throw new InvalidOperationException("Encryption error."); - } - - return output; - } - - public override IEnumerable Decrypt(IEnumerable data) - { - if (this._decryptor == null) - { - this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()); - } - - var input = data.ToArray(); - var output = new byte[input.Length]; - var writtenBytes = this._decryptor.TransformBlock(input, 0, input.Length, output, 0); - - if (writtenBytes < input.Length) - { - throw new InvalidOperationException("Encryption error."); - } - - return output; - } - - #region IDisposable Members - - private bool disposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._algorithm != null) - { - this._algorithm.Dispose(); - } - } - - // Note disposing has been done. - disposed = true; - } - } - - ~CipherAES128() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Security/KeyExchangeCompletedEventArgs.cs b/src/Renci.SshClient/Security/KeyExchangeCompletedEventArgs.cs deleted file mode 100644 index 7595ad57..00000000 --- a/src/Renci.SshClient/Security/KeyExchangeCompletedEventArgs.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Renci.SshClient.Security -{ - internal class KeyExchangeCompletedEventArgs : EventArgs - { - } -} diff --git a/src/Renci.SshClient/Security/KeyExchangeFailedEventArgs.cs b/src/Renci.SshClient/Security/KeyExchangeFailedEventArgs.cs deleted file mode 100644 index 263933be..00000000 --- a/src/Renci.SshClient/Security/KeyExchangeFailedEventArgs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Renci.SshClient.Security -{ - internal class KeyExchangeFailedEventArgs : EventArgs - { - public string Message { get; private set; } - - public KeyExchangeFailedEventArgs(string message) - { - this.Message = message; - } - } -} diff --git a/src/Renci.SshClient/Security/KeyExchangeSendMessageEventArgs.cs b/src/Renci.SshClient/Security/KeyExchangeSendMessageEventArgs.cs deleted file mode 100644 index 18a73899..00000000 --- a/src/Renci.SshClient/Security/KeyExchangeSendMessageEventArgs.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using Renci.SshClient.Messages; - -namespace Renci.SshClient.Security -{ - internal class KeyExchangeSendMessageEventArgs : EventArgs - { - public KeyExchangeSendMessageEventArgs(Message message) - { - this.Message = message; - } - - public Message Message { get; private set; } - } -} diff --git a/src/Renci.SshClient/Security/PrivateKey.cs b/src/Renci.SshClient/Security/PrivateKey.cs deleted file mode 100644 index 82b7ec40..00000000 --- a/src/Renci.SshClient/Security/PrivateKey.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using Renci.SshClient.Common; - -namespace Renci.SshClient.Security -{ - internal abstract class PrivateKey - { - public abstract string AlgorithmName { get; } - - protected IEnumerable Data { get; private set; } - - public abstract IEnumerable PublicKey { get; } - - public PrivateKey(IEnumerable data) - { - this.Data = data; - } - - public abstract IEnumerable GetSignature(IEnumerable sessionId); - - protected class SignatureKeyData : SshData - { - public string AlgorithmName { get; set; } - - public IEnumerable Signature { get; set; } - - protected override void LoadData() - { - } - - protected override void SaveData() - { - this.Write(this.AlgorithmName); - this.Write(this.Signature.GetSshString()); - } - } - - } -} diff --git a/src/Renci.SshClient/Security/PrivateKeyDsa.cs b/src/Renci.SshClient/Security/PrivateKeyDsa.cs deleted file mode 100644 index f8dd8a08..00000000 --- a/src/Renci.SshClient/Security/PrivateKeyDsa.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using Renci.SshClient.Common; - -namespace Renci.SshClient.Security -{ - internal class PrivateKeyDsa : PrivateKey - { - private byte[] _pValue; - - private byte[] _qValue; - - private byte[] _gValue; - - private byte[] _publicKeyValue; - - private byte[] _privateKeyValue; - - private IEnumerable _publicKey; - /// - /// Gets the public key. - /// - /// The public key. - public override IEnumerable PublicKey - { - get - { - if (this._publicKey == null) - { - this._publicKey = new DsaPublicKeyData - { - P = this._pValue, - Q = this._qValue, - G = this._gValue, - Public = this._publicKeyValue, - }.GetBytes(); - - } - return this._publicKey; - } - } - - public override string AlgorithmName - { - get { return "ssh-dss"; } - } - - - public PrivateKeyDsa(IEnumerable data) - : base(data) - { - if (!this.ParseDSAPrivateKey()) - { - throw new InvalidDataException("DSA Key is not valid"); - } - } - - public override IEnumerable GetSignature(IEnumerable sessionId) - { - var data = sessionId.ToArray(); - using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider()) - using (var cs = new System.Security.Cryptography.CryptoStream(System.IO.Stream.Null, sha1, System.Security.Cryptography.CryptoStreamMode.Write)) - { - DSAParameters DSAKeyInfo = new DSAParameters(); - - DSAKeyInfo.X = this._privateKeyValue.TrimLeadinZero().ToArray(); - DSAKeyInfo.P = this._pValue.TrimLeadinZero().ToArray(); - DSAKeyInfo.Q = this._qValue.TrimLeadinZero().ToArray(); - DSAKeyInfo.G = this._gValue.TrimLeadinZero().ToArray(); - - cs.Write(data, 0, data.Length); - - cs.Close(); - - var DSA = new System.Security.Cryptography.DSACryptoServiceProvider(); - DSA.ImportParameters(DSAKeyInfo); - var DSAFormatter = new RSAPKCS1SignatureFormatter(DSA); - DSAFormatter.SetHashAlgorithm("SHA1"); - - var signature = DSAFormatter.CreateSignature(sha1); - - return new SignatureKeyData - { - AlgorithmName = this.AlgorithmName, - Signature = signature, - }.GetBytes(); - } - - } - - private bool ParseDSAPrivateKey() - { - // --------- Set up stream to decode the asn.1 encoded RSA private key ------ - using (var ms = new MemoryStream(this.Data.ToArray())) - using (var binr = new BinaryReader(ms)) //wrap Memory Stream with BinaryReader for easy reading - { - byte bt = 0; - ushort twobytes = 0; - int elems = 0; - - twobytes = binr.ReadUInt16(); - if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) - binr.ReadByte(); //advance 1 byte - else if (twobytes == 0x8230) - binr.ReadInt16(); //advance 2 bytes - else - return false; - - twobytes = binr.ReadUInt16(); - if (twobytes != 0x0102) //version number - return false; - bt = binr.ReadByte(); - if (bt != 0x00) - return false; - - //------ all private key components are Integer sequences ---- - elems = GetIntegerSize(binr); - this._pValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._qValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._gValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._publicKeyValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._privateKeyValue = binr.ReadBytes(elems); - } - - return true; - } - - private static int GetIntegerSize(BinaryReader binr) - { - byte bt = 0; - byte lowbyte = 0x00; - byte highbyte = 0x00; - int count = 0; - bt = binr.ReadByte(); - if (bt != 0x02) //expect integer - return 0; - bt = binr.ReadByte(); - - if (bt == 0x81) - count = binr.ReadByte(); // data size in next byte - else - if (bt == 0x82) - { - highbyte = binr.ReadByte(); // data size in next 2 bytes - lowbyte = binr.ReadByte(); - byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; - count = BitConverter.ToInt32(modint, 0); - } - else - { - count = bt; // we already have the data size - } - - return count; - } - - private class DsaPublicKeyData : SshData - { - public IEnumerable P { get; set; } - - public IEnumerable Q { get; set; } - - public IEnumerable G { get; set; } - - public IEnumerable Public { get; set; } - - protected override void LoadData() - { - } - - protected override void SaveData() - { - this.Write("ssh-dss"); - this.Write(this.P.GetSshString()); - this.Write(this.Q.GetSshString()); - this.Write(this.G.GetSshString()); - this.Write(this.Public.GetSshString()); - } - } - } -} diff --git a/src/Renci.SshClient/Security/PrivateKeyRsa.cs b/src/Renci.SshClient/Security/PrivateKeyRsa.cs deleted file mode 100644 index 7b8c3bcb..00000000 --- a/src/Renci.SshClient/Security/PrivateKeyRsa.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using Renci.SshClient.Common; - -namespace Renci.SshClient.Security -{ - internal class PrivateKeyRsa : PrivateKey - { - private byte[] _modulus; - private byte[] _eValue; - private byte[] _dValue; - private byte[] _pValue; - private byte[] _qValue; - private byte[] _dpValue; - private byte[] _dqValue; - private byte[] _iqValue; - - private IEnumerable _publicKey; - /// - /// Gets the public key. - /// - /// The public key. - public override IEnumerable PublicKey - { - get - { - if (this._publicKey == null) - { - this._publicKey = new RsaPublicKeyData - { - E = this._eValue, - Modulus = this._modulus, - }.GetBytes(); - - } - return this._publicKey; - } - } - - public override string AlgorithmName - { - get { return "ssh-rsa"; } - } - - - public PrivateKeyRsa(IEnumerable data) - : base(data) - { - if (!this.ParseRSAPrivateKey()) - { - throw new InvalidDataException("RSA Key is not valid"); - } - } - - public override IEnumerable GetSignature(IEnumerable sessionId) - { - var data = sessionId.ToArray(); - using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider()) - using (var cs = new System.Security.Cryptography.CryptoStream(System.IO.Stream.Null, sha1, System.Security.Cryptography.CryptoStreamMode.Write)) - { - RSAParameters RSAKeyInfo = new RSAParameters(); - - RSAKeyInfo.Exponent = _eValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.D = _dValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.Modulus = _modulus.TrimLeadinZero().ToArray(); - RSAKeyInfo.P = _pValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.Q = _qValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.DP = _dpValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.DQ = _dqValue.TrimLeadinZero().ToArray(); - RSAKeyInfo.InverseQ = _iqValue.TrimLeadinZero().ToArray(); - - cs.Write(data, 0, data.Length); - - cs.Close(); - - var RSA = new System.Security.Cryptography.RSACryptoServiceProvider(); - RSA.ImportParameters(RSAKeyInfo); - var RSAFormatter = new RSAPKCS1SignatureFormatter(RSA); - RSAFormatter.SetHashAlgorithm("SHA1"); - - var signature = RSAFormatter.CreateSignature(sha1); - - return new SignatureKeyData - { - AlgorithmName = this.AlgorithmName, - Signature = signature, - }.GetBytes(); - } - - } - - private bool ParseRSAPrivateKey() - { - // --------- Set up stream to decode the asn.1 encoded RSA private key ------ - using (var ms = new MemoryStream(this.Data.ToArray())) - using (var binr = new BinaryReader(ms)) //wrap Memory Stream with BinaryReader for easy reading - { - byte bt = 0; - ushort twobytes = 0; - int elems = 0; - - twobytes = binr.ReadUInt16(); - if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) - binr.ReadByte(); //advance 1 byte - else if (twobytes == 0x8230) - binr.ReadInt16(); //advance 2 bytes - else - return false; - - twobytes = binr.ReadUInt16(); - if (twobytes != 0x0102) //version number - return false; - bt = binr.ReadByte(); - if (bt != 0x00) - return false; - - - //------ all private key components are Integer sequences ---- - elems = GetIntegerSize(binr); - this._modulus = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._eValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._dValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._pValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._qValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._dpValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._dqValue = binr.ReadBytes(elems); - - elems = GetIntegerSize(binr); - this._iqValue = binr.ReadBytes(elems); - - return true; - } - } - - private static int GetIntegerSize(BinaryReader binr) - { - byte bt = 0; - byte lowbyte = 0x00; - byte highbyte = 0x00; - int count = 0; - bt = binr.ReadByte(); - if (bt != 0x02) //expect integer - return 0; - bt = binr.ReadByte(); - - if (bt == 0x81) - count = binr.ReadByte(); // data size in next byte - else - if (bt == 0x82) - { - highbyte = binr.ReadByte(); // data size in next 2 bytes - lowbyte = binr.ReadByte(); - byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; - count = BitConverter.ToInt32(modint, 0); - } - else - { - count = bt; // we already have the data size - } - - return count; - } - - private class RsaPublicKeyData : SshData - { - public IEnumerable Modulus { get; set; } - - public IEnumerable E { get; set; } - - protected override void LoadData() - { - } - - protected override void SaveData() - { - this.Write("ssh-rsa"); - this.Write(this.E.GetSshString()); - this.Write(this.Modulus.GetSshString()); - } - } - } -} diff --git a/src/Renci.SshClient/Security/Signature.cs b/src/Renci.SshClient/Security/Signature.cs deleted file mode 100644 index 0b95987c..00000000 --- a/src/Renci.SshClient/Security/Signature.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; - -namespace Renci.SshClient.Security -{ - internal abstract class Signature : Algorithm - { - protected IEnumerable Data { get; private set; } - - public Signature(IEnumerable data) - { - this.Data = data; - } - - public abstract bool ValidateSignature(IEnumerable hash, IEnumerable signature); - } -} diff --git a/src/Renci.SshClient/Security/SignatureDss.cs b/src/Renci.SshClient/Security/SignatureDss.cs deleted file mode 100644 index 46c2610c..00000000 --- a/src/Renci.SshClient/Security/SignatureDss.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; - -namespace Renci.SshClient.Security -{ - internal class SignatureDss : Signature - { - public override string Name - { - get { return "ssh-dss"; } - } - - public SignatureDss(IEnumerable data) - : base(data) - { - - } - - public override bool ValidateSignature(IEnumerable hash, IEnumerable signature) - { - var pLength = BitConverter.ToUInt32(this.Data.Take(4).Reverse().ToArray(), 0); - - var pData = this.Data.Skip(4).Take((int)pLength).ToArray(); - - var qLength = BitConverter.ToUInt32(this.Data.Skip(4 + (int)pLength).Take(4).Reverse().ToArray(), 0); - - var qData = this.Data.Skip(4 + (int)pLength + 4).Take((int)qLength).ToArray(); - - var gLength = BitConverter.ToUInt32(this.Data.Skip(4 + (int)pLength + 4 + (int)qLength).Take(4).Reverse().ToArray(), 0); - - var gData = this.Data.Skip(4 + (int)pLength + 4 + (int)qLength + 4).Take((int)gLength).ToArray(); - - var xLength = BitConverter.ToUInt32(this.Data.Skip(4 + (int)pLength + 4 + (int)qLength + 4 + (int)gLength).Take(4).Reverse().ToArray(), 0); - - var xData = this.Data.Skip(4 + (int)pLength + 4 + (int)qLength + 4 + (int)xLength + 4).Take((int)xLength).ToArray(); - - using (var sha1 = new SHA1CryptoServiceProvider()) - { - using (var cs = new CryptoStream(System.IO.Stream.Null, sha1, CryptoStreamMode.Write)) - { - var data = hash.ToArray(); - cs.Write(data, 0, data.Length); - cs.Close(); - } - - using (var dsa = new DSACryptoServiceProvider()) - { - dsa.ImportParameters(new DSAParameters - { - X = xData.TrimLeadinZero().ToArray(), - P = pData.TrimLeadinZero().ToArray(), - Q = qData.TrimLeadinZero().ToArray(), - G = gData.TrimLeadinZero().ToArray(), - }); - var dsaDeformatter = new DSASignatureDeformatter(dsa); - dsaDeformatter.SetHashAlgorithm("SHA1"); - - long i = 0; - long j = 0; - byte[] tmp; - - var sig = signature.ToArray(); - if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0) - { - long i1 = (sig[i++] << 24) & 0xff000000; - long i2 = (sig[i++] << 16) & 0x00ff0000; - long i3 = (sig[i++] << 8) & 0x0000ff00; - long i4 = (sig[i++]) & 0x000000ff; - j = i1 | i2 | i3 | i4; - - i += j; - - i1 = (sig[i++] << 24) & 0xff000000; - i2 = (sig[i++] << 16) & 0x00ff0000; - i3 = (sig[i++] << 8) & 0x0000ff00; - i4 = (sig[i++]) & 0x000000ff; - j = i1 | i2 | i3 | i4; - - tmp = new byte[j]; - Array.Copy(sig, i, tmp, 0, j); - sig = tmp; - } - - return dsaDeformatter.VerifySignature(sha1, sig); - } - } - } - } -} diff --git a/src/Renci.SshClient/Security/SignatureRsa.cs b/src/Renci.SshClient/Security/SignatureRsa.cs deleted file mode 100644 index e2700a1a..00000000 --- a/src/Renci.SshClient/Security/SignatureRsa.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; - -namespace Renci.SshClient.Security -{ - internal class SignatureRsa : Signature - { - public override string Name - { - get { return "ssh-rsa"; } - } - - public SignatureRsa(IEnumerable data) - : base(data) - { - - } - - public override bool ValidateSignature(IEnumerable hash, IEnumerable signature) - { - var exponentLength = BitConverter.ToUInt32(this.Data.Take(4).Reverse().ToArray(), 0); - - var exponentData = this.Data.Skip(4).Take((int)exponentLength).ToArray(); - - var modulusLength = BitConverter.ToUInt32(this.Data.Skip(4 + (int)exponentLength).Take(4).Reverse().ToArray(), 0); - - var modulusData = this.Data.Skip(4 + (int)exponentLength + 4).Take((int)modulusLength).ToArray(); - - using (var sha1 = new SHA1CryptoServiceProvider()) - { - using (var cs = new CryptoStream(System.IO.Stream.Null, sha1, CryptoStreamMode.Write)) - { - var data = hash.ToArray(); - cs.Write(data, 0, data.Length); - cs.Close(); - } - - using (var rsa = new RSACryptoServiceProvider()) - { - rsa.ImportParameters(new RSAParameters - { - Exponent = exponentData, - Modulus = modulusData.TrimLeadinZero().ToArray(), - }); - var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); - rsaDeformatter.SetHashAlgorithm("SHA1"); - - long i = 0; - long j = 0; - byte[] tmp; - - var sig = signature.ToArray(); - if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0) - { - long i1 = (sig[i++] << 24) & 0xff000000; - long i2 = (sig[i++] << 16) & 0x00ff0000; - long i3 = (sig[i++] << 8) & 0x0000ff00; - long i4 = (sig[i++]) & 0x000000ff; - j = i1 | i2 | i3 | i4; - - i += j; - - i1 = (sig[i++] << 24) & 0xff000000; - i2 = (sig[i++] << 16) & 0x00ff0000; - i3 = (sig[i++] << 8) & 0x0000ff00; - i4 = (sig[i++]) & 0x000000ff; - j = i1 | i2 | i3 | i4; - - tmp = new byte[j]; - Array.Copy(sig, i, tmp, 0, j); - sig = tmp; - } - - return rsaDeformatter.VerifySignature(sha1, sig); - } - } - } - } -} diff --git a/src/Renci.SshClient/Security/UserAuthentication.cs b/src/Renci.SshClient/Security/UserAuthentication.cs deleted file mode 100644 index d9ae72e7..00000000 --- a/src/Renci.SshClient/Security/UserAuthentication.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; -using System; -using Renci.SshClient.Common; -using System.Threading; - -namespace Renci.SshClient.Security -{ - internal abstract class UserAuthentication - { - public abstract string Name { get; } - - public bool IsAuthenticated { get; private set; } - - public string ErrorMessage { get; private set; } - - public event EventHandler Authenticating; - - protected Session Session { get; private set; } - - protected string Username { get; private set; } - - public bool Authenticate(string username, Session session) - { - this.Username = username; - this.Session = session; - - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationFailure); - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationSuccess); - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationBanner); - - this.Session.UserAuthenticationFailureReceived += Session_UserAuthenticationFailureReceived; - this.Session.UserAuthenticationSuccessReceived += Session_UserAuthenticationSuccessMessageReceived; - this.Session.UserAuthenticationBannerReceived += Session_UserAuthenticationBannerMessageReceived; - this.Session.MessageReceived += Session_MessageReceived; - - this.OnAuthenticate(); - - this.Session.UserAuthenticationFailureReceived -= Session_UserAuthenticationFailureReceived; - this.Session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessMessageReceived; - this.Session.UserAuthenticationBannerReceived -= Session_UserAuthenticationBannerMessageReceived; - this.Session.MessageReceived -= Session_MessageReceived; - - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationFailure); - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationSuccess); - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationBanner); - - return this.IsAuthenticated; - } - - protected abstract void OnAuthenticate(); - - protected virtual void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) - { - this.ErrorMessage = e.Message.Message; - this.IsAuthenticated = false; - } - - protected virtual void Session_UserAuthenticationSuccessMessageReceived(object sender, MessageEventArgs e) - { - this.IsAuthenticated = true; - } - - protected virtual void Session_UserAuthenticationBannerMessageReceived(object sender, MessageEventArgs e) - { - RaiseAuthenticating(new AuthenticationBannerEventArgs(this.Username, e.Message.Message, e.Message.Language)); - } - - protected void RaiseAuthenticating(AuthenticationEventArgs args) - { - if (this.Authenticating != null) - { - this.Authenticating(this, args); - } - } - - protected void SendMessage(Message message) - { - this.Session.SendMessage(message); - } - - protected void WaitHandle(WaitHandle eventWaitHandle) - { - this.Session.WaitHandle(eventWaitHandle); - } - - - - protected virtual void Session_MessageReceived(object sender, MessageEventArgs e) - { - } - - } -} diff --git a/src/Renci.SshClient/Security/UserAuthenticationHost.cs b/src/Renci.SshClient/Security/UserAuthenticationHost.cs deleted file mode 100644 index 0dd29b2b..00000000 --- a/src/Renci.SshClient/Security/UserAuthenticationHost.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Renci.SshClient.Security -{ - internal class UserAuthenticationHost : UserAuthentication - { - public override string Name - { - get - { - return "hostbased"; - } - } - - protected override bool Run() - { - throw new System.NotImplementedException(); - } - } -} diff --git a/src/Renci.SshClient/Security/UserAuthenticationKeyboardInteractive.cs b/src/Renci.SshClient/Security/UserAuthenticationKeyboardInteractive.cs deleted file mode 100644 index f5f8bffe..00000000 --- a/src/Renci.SshClient/Security/UserAuthenticationKeyboardInteractive.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; -using Renci.SshClient.Common; -using System.Threading.Tasks; - -namespace Renci.SshClient.Security -{ - internal class UserAuthenticationKeyboardInteractive : UserAuthentication, IDisposable - { - private EventWaitHandle _authenticationCompleted = new AutoResetEvent(false); - - private Exception _exception; - - public override string Name - { - get - { - return "keyboard-interactive"; - } - } - - protected override void OnAuthenticate() - { - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationInformationRequest); - - this.Session.SendMessage(new RequestMessageKeyboardInteractive(ServiceNames.Connection, this.Session.ConnectionInfo.Username)); - - this.WaitHandle(this._authenticationCompleted); - - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationInformationRequest); - - if (this._exception != null) - { - throw this._exception; - } - } - - protected override void Session_UserAuthenticationSuccessMessageReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationSuccessMessageReceived(sender, e); - this._authenticationCompleted.Set(); - } - - protected override void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationFailureReceived(sender, e); - this._authenticationCompleted.Set(); - } - - protected override void Session_MessageReceived(object sender, MessageEventArgs e) - { - var informationRequestMessage = e.Message as InformationRequestMessage; - if (informationRequestMessage != null) - { - var eventArgs = new AuthenticationPromptEventArgs(this.Username, informationRequestMessage.Instruction, informationRequestMessage.Language, informationRequestMessage.Prompts); - - var eventTask = Task.Factory.StartNew(() => - { - try - { - this.RaiseAuthenticating(eventArgs); - - var informationResponse = new InformationResponseMessage(); - - foreach (var response in from r in eventArgs.Prompts orderby r.Id ascending select r.Response) - { - informationResponse.Responses.Add(response); - } - - // Send information response message - this.SendMessage(informationResponse); - } - catch (Exception exp) - { - this._exception = exp; - this._authenticationCompleted.Set(); - } - }); - } - } - - #region IDisposable Members - - private bool isDisposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this.isDisposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._authenticationCompleted != null) - { - this._authenticationCompleted.Dispose(); - } - } - - // Note disposing has been done. - isDisposed = true; - } - } - - ~UserAuthenticationKeyboardInteractive() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Security/UserAuthenticationNone.cs b/src/Renci.SshClient/Security/UserAuthenticationNone.cs deleted file mode 100644 index e6a35139..00000000 --- a/src/Renci.SshClient/Security/UserAuthenticationNone.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Threading; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; -using System.Collections.Generic; - -namespace Renci.SshClient.Security -{ - internal class UserAuthenticationNone : UserAuthentication, IDisposable - { - private EventWaitHandle _authenticationCompleted = new AutoResetEvent(false); - - public override string Name - { - get { return "none"; } - } - - public IEnumerable Methods { get; private set; } - - protected override void OnAuthenticate() - { - this.SendMessage(new RequestMessage(ServiceNames.Connection, this.Username)); - - this.WaitHandle(this._authenticationCompleted); - } - - protected override void Session_UserAuthenticationSuccessMessageReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationSuccessMessageReceived(sender, e); - this._authenticationCompleted.Set(); - } - - protected override void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationFailureReceived(sender, e); - this.Methods = e.Message.AllowedAuthentications; - this._authenticationCompleted.Set(); - } - - #region IDisposable Members - - private bool _isDisposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this._isDisposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._authenticationCompleted != null) - { - this._authenticationCompleted.Dispose(); - } - } - - // Note disposing has been done. - _isDisposed = true; - } - } - - ~UserAuthenticationNone() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Security/UserAuthenticationPassword.cs b/src/Renci.SshClient/Security/UserAuthenticationPassword.cs deleted file mode 100644 index c4da178b..00000000 --- a/src/Renci.SshClient/Security/UserAuthenticationPassword.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Threading; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; -using System.Threading.Tasks; -using Renci.SshClient.Common; - -namespace Renci.SshClient.Security -{ - internal class UserAuthenticationPassword : UserAuthentication, IDisposable - { - private EventWaitHandle _authenticationCompleted = new AutoResetEvent(false); - - private Exception _exception; - - private PasswordConnectionInfo _connectionInfo; - - public override string Name - { - get - { - return "password"; - } - } - - protected override void OnAuthenticate() - { - this._connectionInfo = this.Session.ConnectionInfo as PasswordConnectionInfo; - - if (this._connectionInfo == null) - return; - - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationPasswordChangeRequired); - - this.SendMessage(new RequestMessagePassword(ServiceNames.Connection, this.Username, this._connectionInfo.Password)); - - this.WaitHandle(this._authenticationCompleted); - - if (this._exception != null) - { - throw this._exception; - } - } - - protected override void Session_UserAuthenticationSuccessMessageReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationSuccessMessageReceived(sender, e); - this._authenticationCompleted.Set(); - } - - protected override void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationFailureReceived(sender, e); - this._authenticationCompleted.Set(); - } - - protected override void Session_MessageReceived(object sender, MessageEventArgs e) - { - base.Session_MessageReceived(sender, e); - - if (e.Message is PasswordChangeRequiredMessage) - { - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationPasswordChangeRequired); - - var eventTask = Task.Factory.StartNew(() => - { - try - { - var eventArgs = new AuthenticationPasswordChangeEventArgs(this.Username); - - // Raise an event to allow user to supply a new password - this.RaiseAuthenticating(eventArgs); - - // Send new authentication request with new password - this.SendMessage(new RequestMessagePassword(ServiceNames.Connection, this.Username, this._connectionInfo.Password, eventArgs.NewPassword)); - } - catch (Exception exp) - { - this._exception = exp; - this._authenticationCompleted.Set(); - } - }); - } - } - - #region IDisposable Members - - private bool isDisposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this.isDisposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._authenticationCompleted != null) - { - this._authenticationCompleted.Dispose(); - } - } - - // Note disposing has been done. - isDisposed = true; - } - } - - ~UserAuthenticationPassword() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Security/UserAuthenticationPublicKey.cs b/src/Renci.SshClient/Security/UserAuthenticationPublicKey.cs deleted file mode 100644 index e656c6e1..00000000 --- a/src/Renci.SshClient/Security/UserAuthenticationPublicKey.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Threading; -using Renci.SshClient.Common; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; - -namespace Renci.SshClient.Security -{ - internal class UserAuthenticationPublicKey : UserAuthentication, IDisposable - { - private EventWaitHandle _publicKeyRequestMessageResponseWaitHandle = new ManualResetEvent(false); - - private bool _isSignatureRequired; - - public override string Name - { - get - { - return "publickey"; - } - } - - protected override void OnAuthenticate() - { - var privateKeyConnectionInfo = this.Session.ConnectionInfo as PrivateKeyConnectionInfo; - - if (privateKeyConnectionInfo == null) - return; - - if (privateKeyConnectionInfo.KeyFiles == null) - return; - - this.Session.RegisterMessageType(MessageTypes.UserAuthenticationPublicKey); - - foreach (var keyFile in privateKeyConnectionInfo.KeyFiles) - { - this._publicKeyRequestMessageResponseWaitHandle.Reset(); - this._isSignatureRequired = false; - - var message = new RequestMessagePublicKey(ServiceNames.Connection,this.Username, keyFile.AlgorithmName, keyFile.PublicKey); - - if (privateKeyConnectionInfo.KeyFiles.Count < 2) - { - // If only one key file provided then send signature for very first request - var signatureData = new SignatureData(message, this.Session.SessionId.GetSshString()).GetBytes(); - - message.Signature = keyFile.GetSignature(signatureData); - } - - // Send public key authentication request - this.SendMessage(message); - - this.WaitHandle(this._publicKeyRequestMessageResponseWaitHandle); - - if (this._isSignatureRequired) - { - this._publicKeyRequestMessageResponseWaitHandle.Reset(); - - var signatureMessage = new RequestMessagePublicKey(ServiceNames.Connection, this.Session.ConnectionInfo.Username, keyFile.AlgorithmName, keyFile.PublicKey); - - var signatureData = new SignatureData(message, this.Session.SessionId.GetSshString()).GetBytes(); - - signatureMessage.Signature = keyFile.GetSignature(signatureData); - - // Send public key authentication request with signature - this.SendMessage(signatureMessage); - } - - this.WaitHandle(this._publicKeyRequestMessageResponseWaitHandle); - - if (this.IsAuthenticated) - { - break; - } - } - - this.Session.UnRegisterMessageType(MessageTypes.UserAuthenticationPublicKey); - } - - protected override void Session_UserAuthenticationSuccessMessageReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationSuccessMessageReceived(sender, e); - - this._publicKeyRequestMessageResponseWaitHandle.Set(); - } - - protected override void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) - { - base.Session_UserAuthenticationFailureReceived(sender, e); - this._publicKeyRequestMessageResponseWaitHandle.Set(); - } - - protected override void Session_MessageReceived(object sender, MessageEventArgs e) - { - base.Session_MessageReceived(sender, e); - - var publicKeyMessage = e.Message as PublicKeyMessage; - if (publicKeyMessage != null) - { - this._isSignatureRequired = true; - this._publicKeyRequestMessageResponseWaitHandle.Set(); - } - } - - private class SignatureData : SshData - { - private RequestMessagePublicKey _message; - - private string _sessionId; - - public SignatureData(RequestMessagePublicKey message, string sessionId) - { - this._message = message; - this._sessionId = sessionId; - } - - protected override void LoadData() - { - throw new System.NotImplementedException(); - } - - protected override void SaveData() - { - this.Write(this._sessionId); - this.Write((byte)this._message.MessageType); - this.Write(this._message.Username); - this.Write("ssh-connection"); - this.Write("publickey"); - this.Write((byte)1); - this.Write(this._message.PublicKeyAlgorithmName); - this.Write(this._message.PublicKeyData.GetSshString()); - } - } - - #region IDisposable Members - - private bool _isDisposed = false; - - public void Dispose() - { - Dispose(true); - - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if (!this._isDisposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if (disposing) - { - // Dispose managed resources. - if (this._publicKeyRequestMessageResponseWaitHandle != null) - { - this._publicKeyRequestMessageResponseWaitHandle.Dispose(); - } - } - - // Note disposing has been done. - _isDisposed = true; - } - } - - ~UserAuthenticationPublicKey() - { - // Do not re-create Dispose clean-up code here. - // Calling Dispose(false) is optimal in terms of - // readability and maintainability. - Dispose(false); - } - - #endregion - } -} diff --git a/src/Renci.SshClient/Services/ConnectionService.cs b/src/Renci.SshClient/Services/ConnectionService.cs deleted file mode 100644 index 8719d78e..00000000 --- a/src/Renci.SshClient/Services/ConnectionService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using Renci.SshClient.Messages; - -namespace Renci.SshClient.Services -{ - internal class ConnectionService : Service - { - public override ServiceNames ServiceName - { - get { throw new NotImplementedException(); } - } - - public ConnectionService(Session session) - : base(session) - { - - } - } -} diff --git a/src/Renci.SshClient/Services/Service.cs b/src/Renci.SshClient/Services/Service.cs deleted file mode 100644 index 23ebe0fb..00000000 --- a/src/Renci.SshClient/Services/Service.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Renci.SshClient.Messages; - -namespace Renci.SshClient.Services -{ - internal abstract class Service - { - public abstract ServiceNames ServiceName { get; } - - protected Session Session { get; private set; } - - public Service(Session session) - { - this.Session = session; - } - - protected void SendMessage(Message message) - { - this.Session.SendMessage(message); - } - - } -} diff --git a/src/Renci.SshClient/Services/UserAuthenticationService.cs b/src/Renci.SshClient/Services/UserAuthenticationService.cs deleted file mode 100644 index bc903553..00000000 --- a/src/Renci.SshClient/Services/UserAuthenticationService.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Renci.SshClient.Common; -using Renci.SshClient.Messages; -using Renci.SshClient.Messages.Authentication; -using Renci.SshClient.Messages.Transport; -using Renci.SshClient.Security; - -namespace Renci.SshClient.Services -{ - internal class UserAuthenticationService : Service - { - private IList _executedMethods = new List(); - - private EventWaitHandle _serviceAccepted = new AutoResetEvent(false); - - private EventWaitHandle _authenticationCompleted = new AutoResetEvent(false); - - public override ServiceNames ServiceName - { - get { return ServiceNames.UserAuthentication; } - } - - public EventWaitHandle AuthenticationCompletedHandle { get; private set; } - - public string ErrorMessage { get; private set; } - - public bool IsAuthenticated { get; private set; } - - public UserAuthenticationService(Session session) - : base(session) - { - this.AuthenticationCompletedHandle = new AutoResetEvent(false); - } - - public void AuthenticateUser() - { - // Register Authentication response messages - Message.RegisterMessageType(MessageTypes.UserAuthenticationFailure); - Message.RegisterMessageType(MessageTypes.UserAuthenticationSuccess); - Message.RegisterMessageType(MessageTypes.UserAuthenticationBanner); - - // Attach event handlers to handle messages - this.Session.MessageReceived += SessionInfo_MessageReceived; - - // Request user authorization service - this.SendMessage(new ServiceRequestMessage - { - ServiceName = ServiceNames.UserAuthentication, - }); - - // Wait for service to be accepted - this.Session.WaitHandle(this._serviceAccepted); - - // Start by quering supported authentication methods - this.SendMessage(new RequestMessage - { - Username = this.Session.ConnectionInfo.Username, - ServiceName = ServiceNames.Connection, - }); - - // Wait for authentication to be completed - this.Session.WaitHandle(this._authenticationCompleted); - - this.Session.MessageReceived -= SessionInfo_MessageReceived; - - Message.UnRegisterMessageType(MessageTypes.UserAuthenticationFailure); - Message.UnRegisterMessageType(MessageTypes.UserAuthenticationSuccess); - Message.UnRegisterMessageType(MessageTypes.UserAuthenticationBanner); - } - - private void SessionInfo_MessageReceived(object sender, MessageReceivedEventArgs e) - { - this.HandleMessage((dynamic)e.Message); - } - - private void HandleMessage(T message) - { - // Ignore messages that cannot be handled by this module - } - - private void HandleMessage(ServiceAcceptMessage message) - { - if (message.ServiceName == ServiceNames.UserAuthentication) - { - this._serviceAccepted.Set(); - } - } - - private void HandleMessage(SuccessMessage message) - { - this.AuthenticationSucceded(); - } - - private void HandleMessage(FailureMessage message) - { - if (message.PartialSuccess) - { - this.AuthenticationFailed(message.Message); - return; - } - - // Get method that was not executed yet - var methodsToTry = message.AllowedAuthentications.Except(this._executedMethods); - - if (methodsToTry.Count() == 0) - { - this.AuthenticationFailed(string.Format("User '{0}' cannot be authorized.", this.Session.ConnectionInfo.Username)); - return; - } - - // Execute authentication method - foreach (var methodName in methodsToTry) - { - UserAuthentication userAuthentication = null; - - if (methodName == "publickey") - { - userAuthentication = new UserAuthenticationPublicKey(this.Session); - } - else if (methodName == "password") - { - userAuthentication = new UserAuthenticationPassword(this.Session); - } - this._executedMethods.Add(methodName); - if (userAuthentication != null) - { - if (userAuthentication.Start()) - break; - } - } - } - - private void HandleMessage(BannerMessage message) - { - } - - private void AuthenticationFailed(string message) - { - this.IsAuthenticated = false; - this.ErrorMessage = message; - this._authenticationCompleted.Set(); - } - - private void AuthenticationSucceded() - { - this.IsAuthenticated = true; - this._authenticationCompleted.Set(); - } - - - - } -} diff --git a/src/Renci.SshClient/SessionInfo.cs b/src/Renci.SshClient/SessionInfo.cs deleted file mode 100644 index 279ec2d3..00000000 --- a/src/Renci.SshClient/SessionInfo.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Renci.SshClient.Common; -using Renci.SshClient.Messages; - -namespace Renci.SshClient -{ - public delegate void SendMessage(Message message); - - internal class SessionInfo - { - private SendMessage _sendMessage; - - private EventWaitHandle _disconnectWaitHandle = new AutoResetEvent(false); - - private int _waitTimeout; - - public ConnectionInfo ConnectionInfo { get; private set; } - - public IEnumerable SessionId { get; set; } - - public string ServerVersion { get; set; } - - public string ClientVersion { get; set; } - - public SessionInfo(SendMessage sendMessage, ConnectionInfo connectionInfo, int waitTimeout) - { - this._sendMessage = sendMessage; - this._waitTimeout = waitTimeout; - this.ConnectionInfo = connectionInfo; - } - - public event EventHandler MessageReceived; - - public void RaiseMessageReceived(object sender, MessageReceivedEventArgs args) - { - if (this.MessageReceived != null) - { - this.MessageReceived(sender, args); - } - } - - public void SendMessage(Message message) - { - this._sendMessage(message); - } - - public void Disconnect() - { - this._disconnectWaitHandle.Set(); - } - - public void WaitHandle(EventWaitHandle waitHandle) - { - var waitHandles = new EventWaitHandle[] - { - this._disconnectWaitHandle, - waitHandle, - }; - var index = EventWaitHandle.WaitAny(waitHandles); - - //var index = EventWaitHandle.WaitAny(waitHandles, this._waitTimeout); - - //if (index > waitHandles.Length) - //{ - // // TODO: Issue timeout disconnect message if approapriate - // throw new TimeoutException(); - //} - } - } -} diff --git a/src/Renci.SshClient/SessionSSHv2.cs b/src/Renci.SshClient/SessionSSHv2.cs deleted file mode 100644 index cefd08b8..00000000 --- a/src/Renci.SshClient/SessionSSHv2.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using Renci.SshClient.Messages; - -namespace Renci.SshClient -{ - internal class SessionSSHv2 : Session - { - private static RNGCryptoServiceProvider _randomizer = new System.Security.Cryptography.RNGCryptoServiceProvider(); - - private UInt32 _outboundPacketSequence = 0; - private UInt32 _inboundPacketSequence = 0; - - internal SessionSSHv2(ConnectionInfo connectionInfo, Socket socket, string serverVersion) - : base(connectionInfo, socket, serverVersion) - { - } - - internal override void SendMessage(Message message) - { - if (!this.IsConnected) - return; - - // TODO: Refactor so we lock only _outboundPacketSequence and _inboundPacketSequence relevant operations - - // Messages can be sent by different thread so we need to synchronize it - lock (this) // Lock on session - { - var paddingMultiplier = this.ClientCipher == null ? (byte)8 : (byte)this.ClientCipher.BlockSize; // Should be recalculate base on cipher min lenght if sipher specified - - // TODO: Maximum uncomporessed payload 32768 - // TOOO: If compression specified then compress only payload - - var messageData = message.GetBytes(); - - var packetLength = messageData.Count() + 4 + 1; // add length bytes and padding byte - byte paddingLength = (byte)((-packetLength) & (paddingMultiplier - 1)); - if (paddingLength < paddingMultiplier) - { - paddingLength += paddingMultiplier; - } - - // Build Packet data - var packetData = new List(); - - // Add packet padding length - packetData.Add(paddingLength); - - // Add packet payload - packetData.AddRange(messageData); - - // Add random padding - var paddingBytes = new byte[paddingLength]; - _randomizer.GetBytes(paddingBytes); - packetData.AddRange(paddingBytes); - - // Insert packet length - packetData.InsertRange(0, BitConverter.GetBytes((uint)(packetData.Count())).Reverse()); - - // Calculate packet hash - var hashData = new List(); - hashData.AddRange(BitConverter.GetBytes((this._outboundPacketSequence)).Reverse()); - hashData.AddRange(packetData); - - // Encrypt packet data - var encryptedData = packetData.ToList(); - if (this.ClientCipher != null) - { - //encryptedData = new List(this.Encrypt(packetData)); - encryptedData = new List(this.ClientCipher.Encrypt(packetData)); - } - - // Add message authentication code (MAC) - if (this.ClientMac != null) - { - var hash = this.ClientMac.ComputeHash(hashData.ToArray()); - - encryptedData.AddRange(hash); - } - - if (encryptedData.Count > Session.MAXIMUM_PACKET_SIZE) - { - throw new InvalidOperationException("Packet is too big. Maximum packet size is 35000 bytes."); - } - - this.Write(encryptedData.ToArray()); - - this._outboundPacketSequence++; - } - } - - protected override Message ReceiveMessage() - { - if (!this.IsConnected) - return null; - - // No lock needed since all messages read by only one thread - - List decryptedData; - - //var blockSize = this.Decryption == null ? (byte)8 : (byte)this.Decryption.InputBlockSize; - var blockSize = this.ServerCipher == null ? (byte)8 : (byte)this.ServerCipher.BlockSize; - - // Read packet lenght first - var data = new List(this.Read(blockSize)); - - if (this.ServerCipher == null) - { - decryptedData = data.ToList(); - } - else - { - //decryptedData = new List(this.Decrypt(data)); - decryptedData = new List(this.ServerCipher.Decrypt(data)); - } - - var packetLength = BitConverter.ToUInt32(decryptedData.Take(4).Reverse().ToArray(), 0); - - // Test packet minimum and maximum boundaries - if (packetLength < Math.Max((byte)16, blockSize) - 4 || packetLength > Session.MAXIMUM_PACKET_SIZE - 4) - throw new InvalidOperationException(string.Format("Bad packet length {0}", packetLength)); - - // Read rest of the packet data - int bytesToRead = (int)(packetLength - (blockSize - 4)); - - while (bytesToRead > 0) - { - data = new List(this.Read(blockSize)); - - if (this.ServerCipher == null) - { - decryptedData.AddRange(data); - } - else - { - //decryptedData.AddRange(this.Decrypt(data)); - decryptedData.AddRange(this.ServerCipher.Decrypt(data)); - } - bytesToRead -= blockSize; - } - - // Validate message against MAC - if (this.ServerMac != null) - { - var serverHash = this.Read(this.ServerMac.HashSize / 8); - - var clientHashData = new List(); - clientHashData.AddRange(BitConverter.GetBytes(this._inboundPacketSequence).Reverse()); - clientHashData.AddRange(decryptedData); - - // Calculate packet hash - var clientHash = this.ServerMac.ComputeHash(clientHashData.ToArray()); - - if (!serverHash.IsEqualTo(clientHash)) - { - throw new InvalidOperationException("MAC error"); - } - } - - // TODO: Issue new keys after x number of packets - this._inboundPacketSequence++; - - var paddingLength = decryptedData[4]; - - return this.LoadMessage(decryptedData.Skip(5).Take((int)(packetLength - paddingLength - 1))); - } - - private bool ValidateHash(List decryptedData, byte[] serverHash, uint packetSequence) - { - var clientHashData = new List(); - clientHashData.AddRange(BitConverter.GetBytes(packetSequence).Reverse()); - clientHashData.AddRange(decryptedData); - - var clientHash = this.ServerMac.ComputeHash(clientHashData.ToArray()); - if (!serverHash.IsEqualTo(clientHash)) - { - return false; - } - return true; - } - - //private IEnumerable Encrypt(List data) - //{ - // var temp = new byte[data.Count]; - // this.Encryption.TransformBlock(data.ToArray(), 0, data.Count, temp, 0); - // return temp; - //} - - //private IEnumerable Decrypt(List data) - //{ - // var temp = new byte[data.Count]; - // this.Decryption.TransformBlock(data.ToArray(), 0, data.Count, temp, 0); - // return temp; - //} - } -} diff --git a/src/Renci.SshClient/Settings.cs b/src/Renci.SshClient/Settings.cs deleted file mode 100644 index 0073bae2..00000000 --- a/src/Renci.SshClient/Settings.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using Renci.SshClient.Compression; -using Renci.SshClient.Security; - -namespace Renci.SshClient -{ - internal static class Settings - { - //public static IDictionary> KeyExchangeAlgorithms { get; private set; } - - //public static IDictionary> Encryptions { get; private set; } - - //public static IDictionary, HMAC>> HmacAlgorithms { get; private set; } - - //public static IDictionary> CompressionAlgorithms { get; private set; } - - //public static IDictionary> HostKeyAlgorithms { get; private set; } - - //public static IDictionary> SupportedAuthenticationMethods { get; private set; } - - static Settings() - { - //Settings.KeyExchangeAlgorithms = new Dictionary>() - //{ - // {"diffie-hellman-group1-sha1", () => { return new KeyExchangeDiffieHellman();}} - // //"diffie-hellman-group-exchange-sha1" - //}; - - //Settings.Encryptions = new Dictionary>() - //{ - // {"3des-cbc", () => { return new CipherTripleDES();}}, - // {"aes128-cbc", () => { return new CipherAES128CBC();}}, - // {"aes192-cbc", () => { return new CipherAES192CBC();}}, - // {"aes256-cbc", () => { return new CipherAES256CBC();}}, - //}; - - - //Settings.HmacAlgorithms = new Dictionary, HMAC>>() - //{ - // {"hmac-md5", (key) => { return new System.Security.Cryptography.HMACMD5(key.Take(16).ToArray());}}, - // {"hmac-sha1", (key) => { return new System.Security.Cryptography.HMACSHA1(key.Take(20).ToArray());}}, - //}; - - //Settings.HostKeyAlgorithms = new Dictionary>() - //{ - // {"ssh-rsa", () => { return new CryptoPublicKeyRsa();}}, - // {"ssh-dsa", () => { return new CryptoPublicKeyDss();}}, // TODO: Need to be tested - //}; - - //Settings.SupportedAuthenticationMethods = new Dictionary>() - //{ - // {"none", (session)=> {return new UserAuthenticationNone(session);}}, - // {"publickey", (session)=> {return new UserAuthenticationPublicKey(session);}}, - // {"password", (session)=> {return new UserAuthenticationPassword(session);}}, - //}; - - //Settings.CompressionAlgorithms = new Dictionary>() - //{ - // {"none", (session) => { return null;}}, - // {"zlib", (session) => { return new Zlib(session);}}, - // {"zlib@openssh.com", (session) => { return new ZlibOpenSsh(session);}}, - //}; - - } - } -} diff --git a/src/Renci.SshClient/Sftp.cs b/src/Renci.SshClient/Sftp.cs deleted file mode 100644 index 898d7ca4..00000000 --- a/src/Renci.SshClient/Sftp.cs +++ /dev/null @@ -1,273 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using Renci.SshClient.Channels; -using Renci.SshClient.Common; -using Renci.SshClient.Messages.Sftp; - -namespace Renci.SshClient -{ - public class Sftp - { - private readonly ChannelSession _channel; - - private readonly Session _session; - - private StringBuilder _packetData; - - private uint _requestId; - - private Exception _exception; - - private EventWaitHandle _sftpVersionConfirmed = new AutoResetEvent(false); - - private EventWaitHandle _sessionErrorOccuredWaitHandle = new AutoResetEvent(false); - - private IDictionary> _requestActions; - - private string _remoteCurrentDir; - - public int OperationTimeout { get; set; } - - internal Sftp(Session session) - { - this.OperationTimeout = -1; - this._requestActions = new Dictionary>(); - this._session = session; - this._session.ErrorOccured += Session_ErrorOccured; - this._session.Disconnected += Session_Disconnected; - this._channel = session.CreateChannel(); - this._channel.DataReceived += Channel_DataReceived; - this._channel.Open(); - this._channel.SendSubsystemRequest("sftp"); - - this.SendMessage(new InitMessage - { - Version = 3, - }); - - this.WaitHandle(this._sftpVersionConfirmed); - - this.SendMessage(new RealPathMessage - { - Path = ".", - }, (m) => - { - var nameMessage = m as NameMessage; - if (nameMessage != null) - { - this._remoteCurrentDir = nameMessage.Files.First().Name; - } - else - { - throw new InvalidOperationException(""); - } - }); - } - - public IAsyncResult BeginListDirectory(string path, AsyncCallback callback, object state) - { - var asyncResult = new SftpAsyncResult(this._channel, callback, state); - - this.SendMessage(new OpenDirMessage(path), (m) => - { - var message = m as HandleMessage; - if (message == null) - throw new InvalidOperationException("Handle message is not expected."); - - this.SendMessage(new ReadDirMessage(message.Handle), (m1) => - { - var message1 = m1 as NameMessage; - if (message1 == null) - throw new InvalidOperationException("Handle message is not expected."); - asyncResult.Names = message1.Files; - asyncResult.IsCompleted = true; - }); - }); - - return asyncResult; - - - } - - public IEnumerable EndListDirectory(IAsyncResult result) - { - var r = result as SftpAsyncResult; - if (r == null) - { - throw new ArgumentException("Invalid IAsyncResult parameter."); - } - - r.AsyncWaitHandle.WaitOne(); - - return r.Names; - } - - - private void Channel_DataReceived(object sender, Common.ChannelDataEventArgs e) - { - if (this._packetData == null) - { - var packetLength = (uint)(e.Data[0] << 24 | e.Data[1] << 16 | e.Data[2] << 8 | e.Data[3]); - - this._packetData = new StringBuilder((int)packetLength, (int)packetLength); - this._packetData.Append(e.Data.GetSshBytes().Skip(4).GetSshString()); - } - else - { - this._packetData.Append(e.Data); - } - - if (this._packetData.Length < this._packetData.MaxCapacity) - { - // Wait for more packet data - return; - } - - dynamic sftpMessage = SftpMessage.Load(this._packetData.ToString().GetSshBytes()); - - this._packetData = null; - - this.HandleMessage(sftpMessage); - } - - private void HandleMessage(InitMessage message) - { - throw new InvalidOperationException("Init message should not be received by client."); - } - - private void HandleMessage(VersionMessage message) - { - if (message.Version == 3) - { - this._sftpVersionConfirmed.Set(); - } - else - { - throw new NotSupportedException(string.Format("Server SFTP version {0} is not supported.", message.Version)); - } - } - - private void HandleMessage(SftpRequestMessage message) - { - if (this._requestActions.ContainsKey(message.RequestId)) - { - var action = this._requestActions[message.RequestId]; - action(message); - this._requestActions.Remove(message.RequestId); - } - else - { - throw new InvalidOperationException(string.Format("Request #{0} is invalid.", message.RequestId)); - } - } - - private void Session_Disconnected(object sender, EventArgs e) - { - } - - private void Session_ErrorOccured(object sender, ErrorEventArgs e) - { - this._exception = e.GetException(); - - this._sessionErrorOccuredWaitHandle.Set(); - } - - private void SendMessage(SftpMessage sftpMessage) - { - var message = new SftpDataMessage - { - LocalChannelNumber = this._channel.RemoteChannelNumber, - Message = sftpMessage, - }; - - this._session.SendMessage(message); - } - - private void SendMessage(SftpRequestMessage sftpMessage, Action action) - { - sftpMessage.RequestId = this._requestId++; - - var message = new SftpDataMessage - { - LocalChannelNumber = this._channel.RemoteChannelNumber, - Message = sftpMessage, - }; - - this._session.SendMessage(message); - - this._requestActions.Add(sftpMessage.RequestId, action); - } - - private void WaitHandle(WaitHandle waitHandle) - { - var waitHandles = new WaitHandle[] - { - this._sessionErrorOccuredWaitHandle, - waitHandle, - }; - - var index = EventWaitHandle.WaitAny(waitHandles, this.OperationTimeout); - - if (index < 1) - { - throw this._exception; - } - else if (index > 1) - { - // throw time out error - throw new SshOperationTimeoutException(string.Format("Sftp operation has timed out.")); - } - } - - - //public void UploadFile(Stream source, string fileName) - //{ - // this.Channel.UploadFile(source, fileName); - //} - - //public void UploadFile(string source, string fileName) - //{ - // using (var sourceFile = File.OpenRead(source)) - // { - // this.Channel.UploadFile(sourceFile, fileName); - // } - //} - - //public void DownloadFile(string fileName, Stream destination) - //{ - // this.Channel.DownloadFile(fileName, destination); - //} - - //public void DownloadFile(string fileName, string destination) - //{ - // using (var destinationFile = File.Create(destination)) - // { - // this.Channel.DownloadFile(fileName, destinationFile); - // } - //} - - //public void RemoveFile(string fileName) - //{ - // this.Channel.RemoveFile(fileName); - //} - - //public void RenameFile(string oldFileName, string newFileName) - //{ - // this.Channel.RenameFile(oldFileName, newFileName); - //} - - //public void CreateDirectory(string directoryName) - //{ - // this.Channel.CreateDirectory(directoryName); - //} - - //public void RemoveDirectory(string directoryName) - //{ - // this.Channel.RemoveDirectory(directoryName); - //} - } -} diff --git a/src/Renci.SshClient/Sftp/FileStatusCommand.cs b/src/Renci.SshClient/Sftp/FileStatusCommand.cs deleted file mode 100644 index 5366ba8b..00000000 --- a/src/Renci.SshClient/Sftp/FileStatusCommand.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Renci.SshClient.Sftp.Messages; - -namespace Renci.SshClient.Sftp -{ - internal class FileStatusCommand : SftpCommand - { - private string _path; - - public SftpFile SftpFile { get; private set; } - - public FileStatusCommand(SftpSession sftpSession, string path) - : base(sftpSession) - { - this._path = path; - } - - protected override void OnExecute() - { - this.SendStatMessage(this._path); - } - - protected override void OnAttributes(Attributes attributes) - { - base.OnAttributes(attributes); - - this.SftpFile = new SftpFile(this._path, attributes); - - this.CompleteExecution(); - } - } -} diff --git a/src/Renci.SshClient/Sftp/Messages/FSetStat.cs b/src/Renci.SshClient/Sftp/Messages/FSetStat.cs deleted file mode 100644 index c2d54005..00000000 --- a/src/Renci.SshClient/Sftp/Messages/FSetStat.cs +++ /dev/null @@ -1,29 +0,0 @@ - -namespace Renci.SshClient.Sftp.Messages -{ - internal class FSetStat : SftpRequestMessage - { - public override SftpMessageTypes SftpMessageType - { - get { return SftpMessageTypes.FSetStat; } - } - - public string Handle { get; set; } - - public SftpFileAttributes Attributes { get; set; } - - protected override void LoadData() - { - base.LoadData(); - this.Handle = this.ReadString(); - this.Attributes = this.ReadAttributes(); - } - - protected override void SaveData() - { - base.SaveData(); - this.Write(this.Handle); - this.Write(this.Attributes); - } - } -} diff --git a/src/Renci.SshClient/Sftp/SftpFileAttributes.cs b/src/Renci.SshClient/Sftp/SftpFileAttributes.cs deleted file mode 100644 index dd74a8a3..00000000 --- a/src/Renci.SshClient/Sftp/SftpFileAttributes.cs +++ /dev/null @@ -1,7 +0,0 @@ - -namespace Renci.SshClient.Sftp -{ - public class SftpFileAttributes - { - } -} diff --git a/src/Renci.SshClient/SftpAsyncResult.cs b/src/Renci.SshClient/SftpAsyncResult.cs deleted file mode 100644 index ac657d83..00000000 --- a/src/Renci.SshClient/SftpAsyncResult.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Renci.SshClient.Common; - -namespace Renci.SshClient -{ - public class SftpAsyncResult : IAsyncResult - { - private bool _isCompleted; - - private Channels.ChannelSession _channelSession; - - private AsyncCallback _callback; - - private EventWaitHandle _completedWaitHandle = new ManualResetEvent(false); - - public IList Names { get; internal set; } - - internal SftpAsyncResult(Channels.ChannelSession channelSession, AsyncCallback callback, object state) - { - this._channelSession = channelSession; - this._callback = callback; - this.AsyncState = state; - this.AsyncWaitHandle = _completedWaitHandle; - } - - #region IAsyncResult Members - - public object AsyncState { get; private set; } - - public WaitHandle AsyncWaitHandle { get; private set; } - - public bool CompletedSynchronously { get; private set; } - - public bool IsCompleted - { - get - { - return this._isCompleted; - } - internal set - { - this._isCompleted = value; - if (value) - { - if (this._callback != null) - { - this._callback(this); - } - this._completedWaitHandle.Set(); - } - } - } - - #endregion - } -} diff --git a/src/Renci.SshClient/SshBase.cs b/src/Renci.SshClient/SshBase.cs deleted file mode 100644 index 85c9b240..00000000 --- a/src/Renci.SshClient/SshBase.cs +++ /dev/null @@ -1,69 +0,0 @@ - -namespace Renci.SshClient -{ - public abstract class SshBase - { - public ConnectionInfo ConnectionInfo { get; private set; } - - internal Session Session { get; private set; } - - public SshBase(ConnectionInfo connectionInfo) - { - this.ConnectionInfo = connectionInfo; - this.Session = new Session(this.ConnectionInfo); - } - - public SshBase(string host, int port, string username, string password) - : this(new ConnectionInfo - { - Host = host, - Port = port, - Username = username, - Password = password, - }) - { - } - - public SshBase(string host, string username, string password) - : this(new ConnectionInfo - { - Host = host, - Username = username, - Password = password, - }) - { - } - - public SshBase(string host, int port, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo - { - Host = host, - Port = port, - Username = username, - KeyFile = keyFile, - }) - { - } - - public SshBase(string host, string username, PrivateKeyFile keyFile) - : this(new ConnectionInfo - { - Host = host, - Username = username, - KeyFile = keyFile, - }) - { - } - - public void Connect() - { - this.Session.Connect(); - } - - public virtual void Disconnect() - { - this.Session.Disconnect(); - } - - } -} diff --git a/src/Renci.SshClient/UserAuthentication.cs b/src/Renci.SshClient/UserAuthentication.cs deleted file mode 100644 index 62aba982..00000000 --- a/src/Renci.SshClient/UserAuthentication.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Renci.SshClient -{ - public class UserAuthentication2 - { - private Session _session; - - public string Username { get; set; } - - internal UserAuthentication2(Session session) - { - this._session = session; - this.Username = session.ConnectionInfo.Username; - } - } -}