diff --git a/SSH.CommandSender/Dialogs/HostEditorDialog.Designer.cs b/SSH.CommandSender/Dialogs/HostEditorDialog.Designer.cs index 3e8649d..b30d9a3 100644 --- a/SSH.CommandSender/Dialogs/HostEditorDialog.Designer.cs +++ b/SSH.CommandSender/Dialogs/HostEditorDialog.Designer.cs @@ -42,8 +42,16 @@ private void InitializeComponent() this.lblPassword = new System.Windows.Forms.Label(); this.txtPassword = new System.Windows.Forms.TextBox(); this.tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel(); + this.txtPathToKeyFile = new System.Windows.Forms.TextBox(); + this.lnkTogglePassPhrase = new System.Windows.Forms.LinkLabel(); + this.txtPassPhrase = new System.Windows.Forms.TextBox(); + this.lblAuthMethod = new System.Windows.Forms.Label(); this.numericPort = new System.Windows.Forms.NumericUpDown(); this.lnkTogglePasswordField = new System.Windows.Forms.LinkLabel(); + this.comboAuthMethod = new System.Windows.Forms.ComboBox(); + this.lblPathToKey = new System.Windows.Forms.Label(); + this.lblPassPhrase = new System.Windows.Forms.Label(); + this.btnBrowseKeyPath = new System.Windows.Forms.Button(); this.tableLayoutPanelButtons.SuspendLayout(); this.tableLayoutPanelMain.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericPort)).BeginInit(); @@ -53,25 +61,23 @@ private void InitializeComponent() // this.txtName.Dock = System.Windows.Forms.DockStyle.Fill; this.txtName.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtName.Location = new System.Drawing.Point(127, 90); + this.txtName.Location = new System.Drawing.Point(127, 63); this.txtName.Margin = new System.Windows.Forms.Padding(0); this.txtName.Name = "txtName"; this.txtName.Size = new System.Drawing.Size(444, 30); this.txtName.TabIndex = 2; - this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); // // lblName // this.lblName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.lblName.AutoSize = true; - this.lblName.Location = new System.Drawing.Point(66, 90); - this.lblName.Margin = new System.Windows.Forms.Padding(0, 0, 21, 0); + this.lblName.Location = new System.Drawing.Point(51, 63); + this.lblName.Margin = new System.Windows.Forms.Padding(0, 0, 36, 0); this.lblName.Name = "lblName"; - this.lblName.Size = new System.Drawing.Size(40, 90); + this.lblName.Size = new System.Drawing.Size(40, 63); this.lblName.TabIndex = 1; this.lblName.Text = "Name:"; - this.lblName.Click += new System.EventHandler(this.lblName_Click); // // tableLayoutPanelButtons // @@ -85,13 +91,12 @@ private void InitializeComponent() this.tableLayoutPanelButtons.Controls.Add(this.btnCancel, 3, 0); this.tableLayoutPanelButtons.Controls.Add(this.btnSave, 4, 0); this.tableLayoutPanelButtons.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanelButtons.Location = new System.Drawing.Point(3, 543); + this.tableLayoutPanelButtons.Location = new System.Drawing.Point(3, 570); this.tableLayoutPanelButtons.Name = "tableLayoutPanelButtons"; this.tableLayoutPanelButtons.RowCount = 1; this.tableLayoutPanelButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanelButtons.Size = new System.Drawing.Size(629, 91); + this.tableLayoutPanelButtons.Size = new System.Drawing.Size(629, 64); this.tableLayoutPanelButtons.TabIndex = 0; - this.tableLayoutPanelButtons.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanelButtons_Paint); // // btnCancel // @@ -99,11 +104,10 @@ private void InitializeComponent() this.btnCancel.Dock = System.Windows.Forms.DockStyle.Fill; this.btnCancel.Location = new System.Drawing.Point(378, 3); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(119, 85); + this.btnCancel.Size = new System.Drawing.Size(119, 58); this.btnCancel.TabIndex = 1; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // btnSave // @@ -112,93 +116,85 @@ private void InitializeComponent() this.btnSave.Dock = System.Windows.Forms.DockStyle.Fill; this.btnSave.Location = new System.Drawing.Point(503, 3); this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(123, 85); + this.btnSave.Size = new System.Drawing.Size(123, 58); this.btnSave.TabIndex = 0; this.btnSave.Text = "Save"; this.btnSave.UseVisualStyleBackColor = false; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // lblHost // this.lblHost.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblHost.AutoSize = true; - this.lblHost.Location = new System.Drawing.Point(71, 180); - this.lblHost.Margin = new System.Windows.Forms.Padding(0, 0, 24, 0); + this.lblHost.Location = new System.Drawing.Point(57, 126); + this.lblHost.Margin = new System.Windows.Forms.Padding(0, 0, 38, 0); this.lblHost.Name = "lblHost"; this.lblHost.Size = new System.Drawing.Size(32, 17); this.lblHost.TabIndex = 3; this.lblHost.Text = "Host:"; - this.lblHost.Click += new System.EventHandler(this.lblHost_Click); // // txtHost // this.txtHost.Dock = System.Windows.Forms.DockStyle.Fill; this.txtHost.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtHost.Location = new System.Drawing.Point(127, 180); + this.txtHost.Location = new System.Drawing.Point(127, 126); this.txtHost.Margin = new System.Windows.Forms.Padding(0); this.txtHost.Name = "txtHost"; this.txtHost.Size = new System.Drawing.Size(444, 30); this.txtHost.TabIndex = 4; - this.txtHost.TextChanged += new System.EventHandler(this.txtHost_TextChanged); // // lblPort // this.lblPort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblPort.AutoSize = true; - this.lblPort.Location = new System.Drawing.Point(72, 270); - this.lblPort.Margin = new System.Windows.Forms.Padding(0, 0, 24, 0); + this.lblPort.Location = new System.Drawing.Point(58, 189); + this.lblPort.Margin = new System.Windows.Forms.Padding(0, 0, 38, 0); this.lblPort.Name = "lblPort"; this.lblPort.Size = new System.Drawing.Size(31, 17); this.lblPort.TabIndex = 5; this.lblPort.Text = "Port:"; - this.lblPort.Click += new System.EventHandler(this.lblPort_Click); // // lblUsername // this.lblUsername.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblUsername.AutoSize = true; - this.lblUsername.Location = new System.Drawing.Point(68, 360); - this.lblUsername.Margin = new System.Windows.Forms.Padding(0); + this.lblUsername.Location = new System.Drawing.Point(56, 252); + this.lblUsername.Margin = new System.Windows.Forms.Padding(0, 0, 12, 0); this.lblUsername.Name = "lblUsername"; this.lblUsername.Size = new System.Drawing.Size(59, 17); this.lblUsername.TabIndex = 7; this.lblUsername.Text = "Username:"; - this.lblUsername.Click += new System.EventHandler(this.lblUsername_Click); // // txtUsername // this.txtUsername.Dock = System.Windows.Forms.DockStyle.Fill; this.txtUsername.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtUsername.Location = new System.Drawing.Point(127, 360); + this.txtUsername.Location = new System.Drawing.Point(127, 252); this.txtUsername.Margin = new System.Windows.Forms.Padding(0); this.txtUsername.Name = "txtUsername"; this.txtUsername.Size = new System.Drawing.Size(444, 30); this.txtUsername.TabIndex = 8; - this.txtUsername.TextChanged += new System.EventHandler(this.txtUsername_TextChanged); // // lblPassword // this.lblPassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblPassword.AutoSize = true; - this.lblPassword.Location = new System.Drawing.Point(70, 450); - this.lblPassword.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0); + this.lblPassword.Location = new System.Drawing.Point(74, 473); + this.lblPassword.Margin = new System.Windows.Forms.Padding(0, 0, 13, 0); this.lblPassword.Name = "lblPassword"; - this.lblPassword.Size = new System.Drawing.Size(52, 17); + this.lblPassword.Size = new System.Drawing.Size(55, 17); this.lblPassword.TabIndex = 9; - this.lblPassword.Text = "Password"; - this.lblPassword.Click += new System.EventHandler(this.lblPassword_Click); + this.lblPassword.Text = "Password:"; // // txtPassword // this.txtPassword.Dock = System.Windows.Forms.DockStyle.Fill; this.txtPassword.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtPassword.Location = new System.Drawing.Point(127, 450); + this.txtPassword.Location = new System.Drawing.Point(127, 378); this.txtPassword.Margin = new System.Windows.Forms.Padding(0); this.txtPassword.Name = "txtPassword"; this.txtPassword.PasswordChar = '●'; this.txtPassword.Size = new System.Drawing.Size(444, 30); this.txtPassword.TabIndex = 10; - this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged); // // tableLayoutPanelMain // @@ -206,39 +202,106 @@ private void InitializeComponent() this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70F)); this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanelMain.Controls.Add(this.txtPassword, 1, 5); - this.tableLayoutPanelMain.Controls.Add(this.lblPassword, 0, 5); + this.tableLayoutPanelMain.Controls.Add(this.txtPathToKeyFile, 1, 7); + this.tableLayoutPanelMain.Controls.Add(this.lnkTogglePassPhrase, 2, 8); + this.tableLayoutPanelMain.Controls.Add(this.txtPassPhrase, 1, 8); + this.tableLayoutPanelMain.Controls.Add(this.lblAuthMethod, 0, 5); + this.tableLayoutPanelMain.Controls.Add(this.txtPassword, 1, 6); + this.tableLayoutPanelMain.Controls.Add(this.lblPassword, 0, 6); this.tableLayoutPanelMain.Controls.Add(this.txtUsername, 1, 4); this.tableLayoutPanelMain.Controls.Add(this.lblUsername, 0, 4); this.tableLayoutPanelMain.Controls.Add(this.lblPort, 0, 3); this.tableLayoutPanelMain.Controls.Add(this.txtHost, 1, 2); this.tableLayoutPanelMain.Controls.Add(this.lblHost, 0, 2); - this.tableLayoutPanelMain.Controls.Add(this.tableLayoutPanelButtons, 0, 6); + this.tableLayoutPanelMain.Controls.Add(this.tableLayoutPanelButtons, 0, 9); this.tableLayoutPanelMain.Controls.Add(this.lblName, 0, 1); this.tableLayoutPanelMain.Controls.Add(this.txtName, 1, 1); this.tableLayoutPanelMain.Controls.Add(this.numericPort, 1, 3); - this.tableLayoutPanelMain.Controls.Add(this.lnkTogglePasswordField, 2, 5); + this.tableLayoutPanelMain.Controls.Add(this.lnkTogglePasswordField, 2, 6); + this.tableLayoutPanelMain.Controls.Add(this.comboAuthMethod, 1, 5); + this.tableLayoutPanelMain.Controls.Add(this.lblPathToKey, 0, 7); + this.tableLayoutPanelMain.Controls.Add(this.lblPassPhrase, 0, 8); + this.tableLayoutPanelMain.Controls.Add(this.btnBrowseKeyPath, 2, 7); this.tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(3, 30, 3, 3); this.tableLayoutPanelMain.Name = "tableLayoutPanelMain"; - this.tableLayoutPanelMain.RowCount = 7; - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); + this.tableLayoutPanelMain.RowCount = 10; + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanelMain.Size = new System.Drawing.Size(635, 637); this.tableLayoutPanelMain.TabIndex = 0; - this.tableLayoutPanelMain.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanelMain_Paint); + // + // txtPathToKeyFile + // + this.txtPathToKeyFile.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtPathToKeyFile.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtPathToKeyFile.Location = new System.Drawing.Point(127, 441); + this.txtPathToKeyFile.Margin = new System.Windows.Forms.Padding(0); + this.txtPathToKeyFile.Name = "txtPathToKeyFile"; + this.txtPathToKeyFile.Size = new System.Drawing.Size(444, 30); + this.txtPathToKeyFile.TabIndex = 19; + // + // lnkTogglePassPhrase + // + this.lnkTogglePassPhrase.ActiveLinkColor = System.Drawing.Color.Black; + this.lnkTogglePassPhrase.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lnkTogglePassPhrase.AutoSize = true; + this.lnkTogglePassPhrase.Font = new System.Drawing.Font("Ubuntu Condensed", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.lnkTogglePassPhrase.Image = global::SSH.CommandSender.Properties.Resources.icon_opened_eye; + this.lnkTogglePassPhrase.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.lnkTogglePassPhrase.LinkArea = new System.Windows.Forms.LinkArea(0, 25); + this.lnkTogglePassPhrase.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkTogglePassPhrase.LinkColor = System.Drawing.Color.Black; + this.lnkTogglePassPhrase.Location = new System.Drawing.Point(571, 504); + this.lnkTogglePassPhrase.Margin = new System.Windows.Forms.Padding(0); + this.lnkTogglePassPhrase.Name = "lnkTogglePassPhrase"; + this.lnkTogglePassPhrase.Size = new System.Drawing.Size(54, 63); + this.lnkTogglePassPhrase.TabIndex = 18; + this.lnkTogglePassPhrase.TabStop = true; + this.lnkTogglePassPhrase.Text = " "; + this.lnkTogglePassPhrase.TextAlign = System.Drawing.ContentAlignment.TopCenter; + this.lnkTogglePassPhrase.UseCompatibleTextRendering = true; + this.lnkTogglePassPhrase.VisitedLinkColor = System.Drawing.Color.Black; + this.lnkTogglePassPhrase.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkTogglePassPhrase_LinkClicked); + // + // txtPassPhrase + // + this.txtPassPhrase.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtPassPhrase.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtPassPhrase.Location = new System.Drawing.Point(127, 504); + this.txtPassPhrase.Margin = new System.Windows.Forms.Padding(0); + this.txtPassPhrase.Name = "txtPassPhrase"; + this.txtPassPhrase.PasswordChar = '●'; + this.txtPassPhrase.Size = new System.Drawing.Size(444, 30); + this.txtPassPhrase.TabIndex = 17; + // + // lblAuthMethod + // + this.lblAuthMethod.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lblAuthMethod.AutoSize = true; + this.lblAuthMethod.Location = new System.Drawing.Point(48, 315); + this.lblAuthMethod.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0); + this.lblAuthMethod.Name = "lblAuthMethod"; + this.lblAuthMethod.Size = new System.Drawing.Size(74, 17); + this.lblAuthMethod.TabIndex = 13; + this.lblAuthMethod.Text = "Auth Method:"; // // numericPort // this.numericPort.Dock = System.Windows.Forms.DockStyle.Left; this.numericPort.Font = new System.Drawing.Font("Ubuntu Condensed", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.numericPort.Location = new System.Drawing.Point(130, 273); + this.numericPort.Location = new System.Drawing.Point(130, 192); this.numericPort.Maximum = new decimal(new int[] { 65535, 0, @@ -250,14 +313,13 @@ private void InitializeComponent() 0, 0}); this.numericPort.Name = "numericPort"; - this.numericPort.Size = new System.Drawing.Size(109, 30); + this.numericPort.Size = new System.Drawing.Size(136, 30); this.numericPort.TabIndex = 11; this.numericPort.Value = new decimal(new int[] { 22, 0, 0, 0}); - this.numericPort.ValueChanged += new System.EventHandler(this.numericPort_ValueChanged); // // lnkTogglePasswordField // @@ -271,10 +333,10 @@ private void InitializeComponent() this.lnkTogglePasswordField.LinkArea = new System.Windows.Forms.LinkArea(0, 25); this.lnkTogglePasswordField.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; this.lnkTogglePasswordField.LinkColor = System.Drawing.Color.Black; - this.lnkTogglePasswordField.Location = new System.Drawing.Point(571, 450); + this.lnkTogglePasswordField.Location = new System.Drawing.Point(571, 378); this.lnkTogglePasswordField.Margin = new System.Windows.Forms.Padding(0); this.lnkTogglePasswordField.Name = "lnkTogglePasswordField"; - this.lnkTogglePasswordField.Size = new System.Drawing.Size(54, 90); + this.lnkTogglePasswordField.Size = new System.Drawing.Size(54, 63); this.lnkTogglePasswordField.TabIndex = 12; this.lnkTogglePasswordField.TabStop = true; this.lnkTogglePasswordField.Text = " "; @@ -283,6 +345,51 @@ private void InitializeComponent() this.lnkTogglePasswordField.VisitedLinkColor = System.Drawing.Color.Black; this.lnkTogglePasswordField.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkTogglePasswordField_LinkClicked); // + // comboAuthMethod + // + this.comboAuthMethod.Dock = System.Windows.Forms.DockStyle.Fill; + this.comboAuthMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboAuthMethod.FormattingEnabled = true; + this.comboAuthMethod.Items.AddRange(new object[] { + "Password", + "Private Key File"}); + this.comboAuthMethod.Location = new System.Drawing.Point(130, 318); + this.comboAuthMethod.Name = "comboAuthMethod"; + this.comboAuthMethod.Size = new System.Drawing.Size(438, 25); + this.comboAuthMethod.TabIndex = 14; + this.comboAuthMethod.SelectedIndexChanged += new System.EventHandler(this.comboAuthMethod_SelectedIndexChanged); + // + // lblPathToKey + // + this.lblPathToKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lblPathToKey.AutoSize = true; + this.lblPathToKey.Location = new System.Drawing.Point(76, 551); + this.lblPathToKey.Margin = new System.Windows.Forms.Padding(3, 0, 12, 0); + this.lblPathToKey.Name = "lblPathToKey"; + this.lblPathToKey.Size = new System.Drawing.Size(54, 17); + this.lblPathToKey.TabIndex = 15; + this.lblPathToKey.Text = "Key Path:"; + // + // lblPassPhrase + // + this.lblPassPhrase.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lblPassPhrase.AutoSize = true; + this.lblPassPhrase.Location = new System.Drawing.Point(58, 504); + this.lblPassPhrase.Name = "lblPassPhrase"; + this.lblPassPhrase.Size = new System.Drawing.Size(66, 17); + this.lblPassPhrase.TabIndex = 16; + this.lblPassPhrase.Text = "Pass Phrase:"; + // + // btnBrowseKeyPath + // + this.btnBrowseKeyPath.Location = new System.Drawing.Point(574, 444); + this.btnBrowseKeyPath.Name = "btnBrowseKeyPath"; + this.btnBrowseKeyPath.Size = new System.Drawing.Size(58, 27); + this.btnBrowseKeyPath.TabIndex = 20; + this.btnBrowseKeyPath.Text = "Browse"; + this.btnBrowseKeyPath.UseVisualStyleBackColor = true; + this.btnBrowseKeyPath.Click += new System.EventHandler(this.btnBrowseKeyPath_Click); + // // HostEditorDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 17F); @@ -320,5 +427,13 @@ private void InitializeComponent() private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.LinkLabel lnkTogglePasswordField; + private System.Windows.Forms.Label lblAuthMethod; + private System.Windows.Forms.ComboBox comboAuthMethod; + private System.Windows.Forms.Label lblPathToKey; + private System.Windows.Forms.Label lblPassPhrase; + private System.Windows.Forms.TextBox txtPassPhrase; + private System.Windows.Forms.LinkLabel lnkTogglePassPhrase; + private System.Windows.Forms.TextBox txtPathToKeyFile; + private System.Windows.Forms.Button btnBrowseKeyPath; } } \ No newline at end of file diff --git a/SSH.CommandSender/Dialogs/HostEditorDialog.cs b/SSH.CommandSender/Dialogs/HostEditorDialog.cs index 0ad3d52..eef9fde 100644 --- a/SSH.CommandSender/Dialogs/HostEditorDialog.cs +++ b/SSH.CommandSender/Dialogs/HostEditorDialog.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Newtonsoft.Json; using SSH.CommandSender.Domain; using SSH.CommandSender.Properties; @@ -34,9 +35,7 @@ private void BindControls() this.txtName.Text = this.HostDetails.Name; this.txtHost.Text = this.HostDetails.Host; this.numericPort.Value = this.HostDetails.Port; - this.txtUsername.Text = this.HostDetails.Username; - this.txtPassword.Text = this.HostDetails.Password; - + BindAuth(); this.txtName.DataBindings.Add("Text", this.HostDetails, "Name", false, DataSourceUpdateMode.OnValidation); @@ -45,10 +44,82 @@ private void BindControls() this.numericPort.DataBindings.Add("Value", this.HostDetails, "Port", false, DataSourceUpdateMode.OnValidation); - this.txtUsername.DataBindings.Add("Text", this.HostDetails, "Username", false, - DataSourceUpdateMode.OnValidation); - this.txtPassword.DataBindings.Add("Text", this.HostDetails, "Password", false, + this.txtUsername.DataBindings.Add("Text", this.HostDetails.AuthenticationDetails, "Username", false, DataSourceUpdateMode.OnValidation); + + + + } + + private void BindAuth() + { + this.txtUsername.Text = this.HostDetails.AuthenticationDetails.Username; + switch (this.HostDetails.AuthenticationDetails) + { + case SshHostDetails.PasswordAuth passwordAuth: + + comboAuthMethod.SelectedIndex = 0; + this.txtPassword.Text = passwordAuth.Password; + + if (txtPassword.DataBindings.Count == 0) + { + this.txtPassword.DataBindings.Add("Text", this.HostDetails.AuthenticationDetails as SshHostDetails.PasswordAuth, "Password", false, + DataSourceUpdateMode.OnValidation); + } + + HideRowInPanel(tableLayoutPanelMain, new List() {7, 8}); + + break; + case SshHostDetails.PrivateKeyFileAuth privateKeyFileAuth: + comboAuthMethod.SelectedIndex = 1; + txtPassPhrase.Text = privateKeyFileAuth.PassPhrase; + txtPathToKeyFile.Text = privateKeyFileAuth.PathToKeyFile; + + if (txtPassPhrase.DataBindings.Count == 0) + { + this.txtPassPhrase.DataBindings.Add("Text", this.HostDetails.AuthenticationDetails as SshHostDetails.PrivateKeyFileAuth, "PassPhrase", false, + DataSourceUpdateMode.OnValidation); + } + + if (txtPathToKeyFile.DataBindings.Count == 0) + { + this.txtPathToKeyFile.DataBindings.Add("Text", this.HostDetails.AuthenticationDetails as SshHostDetails.PrivateKeyFileAuth, "PathToKeyFile", false, + DataSourceUpdateMode.OnValidation); + } + HideRowInPanel(tableLayoutPanelMain, new List() { 6 }); + + break; + } + + //HideRowInPanel(tableLayoutPanelMain, 6); + } + + private void HideRowInPanel(TableLayoutPanel tableLayoutPanel, List rowIndexes) + { + for (int i = 0; i < tableLayoutPanel.RowCount; i++) + { + if (rowIndexes.Any(x => x == i)) + { + tableLayoutPanel.RowStyles[i].SizeType = SizeType.Absolute; + tableLayoutPanel.RowStyles[i].Height = 0; + foreach (Control control in tableLayoutPanel.Controls) + { + if (rowIndexes.Any(x => x == tableLayoutPanel.GetRow(control))) + { + control.Hide(); + } + else + { + control.Show(); + } + } + } + else + { + tableLayoutPanel.RowStyles[i].SizeType = SizeType.Percent; + tableLayoutPanel.RowStyles[i].Height = 50; + } + } } private void lnkTogglePasswordField_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -69,74 +140,59 @@ private void lnkTogglePasswordField_LinkClicked(object sender, LinkLabelLinkClic } } - private void txtName_TextChanged(object sender, EventArgs e) + private void lnkTogglePassPhrase_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HostEditorDialog)); - } - - private void lblName_Click(object sender, EventArgs e) - { - - } - - private void tableLayoutPanelButtons_Paint(object sender, PaintEventArgs e) - { - - } - - private void btnCancel_Click(object sender, EventArgs e) - { - - } - - private void btnSave_Click(object sender, EventArgs e) - { - - } - - private void lblHost_Click(object sender, EventArgs e) - { - - } - - private void txtHost_TextChanged(object sender, EventArgs e) - { - - } - - private void lblPort_Click(object sender, EventArgs e) - { - - } - - private void lblUsername_Click(object sender, EventArgs e) - { - - } - - private void txtUsername_TextChanged(object sender, EventArgs e) - { - - } - - private void lblPassword_Click(object sender, EventArgs e) - { - - } - - private void txtPassword_TextChanged(object sender, EventArgs e) - { + if (txtPassPhrase.PasswordChar == '●') + { + txtPassPhrase.PasswordChar = '\0'; + this.lnkTogglePasswordField.Image = ((System.Drawing.Image)(resources.GetObject("icon-closed-eye"))); + } + else + { + txtPassPhrase.PasswordChar = '●'; + this.lnkTogglePasswordField.Image = ((System.Drawing.Image)(resources.GetObject("icon-opened-eye"))); + } } - private void tableLayoutPanelMain_Paint(object sender, PaintEventArgs e) + private void btnBrowseKeyPath_Click(object sender, EventArgs e) { - + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + openFileDialog.Filter = "All files (*.*)|*.*"; + openFileDialog.FilterIndex = 1; + openFileDialog.RestoreDirectory = true; + openFileDialog.Multiselect = false; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (openFileDialog.FileName != null && openFileDialog.FileName.Length > 0) + { + txtPathToKeyFile.Text = openFileDialog.FileName; + (this.HostDetails.AuthenticationDetails as SshHostDetails.PrivateKeyFileAuth).PathToKeyFile = openFileDialog.FileName; + } + + } + } } - private void numericPort_ValueChanged(object sender, EventArgs e) + private void comboAuthMethod_SelectedIndexChanged(object sender, EventArgs e) { + if (comboAuthMethod.SelectedIndex == 0) + { + //pass auth + this.HostDetails.AuthenticationDetails = new SshHostDetails.PasswordAuth(this.HostDetails.AuthenticationDetails.Username, string.Empty); + } + else + { + //key file auth + this.HostDetails.AuthenticationDetails = + new SshHostDetails.PrivateKeyFileAuth(this.HostDetails.AuthenticationDetails.Username, string.Empty, string.Empty); + } + BindAuth(); } } } diff --git a/SSH.CommandSender/Dialogs/HostEditorDialog.resx b/SSH.CommandSender/Dialogs/HostEditorDialog.resx index 2b00c80..ff0e39d 100644 --- a/SSH.CommandSender/Dialogs/HostEditorDialog.resx +++ b/SSH.CommandSender/Dialogs/HostEditorDialog.resx @@ -1799,11 +1799,4 @@ AACgVQAAoFUAAKBFAACoVQAAoFUAAL/9AAC//QAAgAEAAIABAACAAQAA//8AAP//AAA= - - - ..\Assets\icon-closed-eye.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Assets\icon-opened-eye.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file diff --git a/SSH.CommandSender/Domain/AuthJsonConverter.cs b/SSH.CommandSender/Domain/AuthJsonConverter.cs new file mode 100644 index 0000000..063d8be --- /dev/null +++ b/SSH.CommandSender/Domain/AuthJsonConverter.cs @@ -0,0 +1,31 @@ +using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace SSH.CommandSender.Domain +{ + public class AuthJsonConverter : JsonConverter + { + public override void WriteJson(JsonWriter writer, SshHostDetails.Auth value, JsonSerializer serializer) + { + serializer.Serialize(writer, value); + } + + public override SshHostDetails.Auth ReadJson(JsonReader reader, Type objectType, SshHostDetails.Auth existingValue, bool hasExistingValue, JsonSerializer serializer) + { + var jObject = JObject.Load(reader); + if (jObject["PathToKeyFile"] == null) + { + return new SshHostDetails.PasswordAuth(jObject["Username"].Value(), + jObject["Password"].Value()); + } + else + { + return new SshHostDetails.PrivateKeyFileAuth(jObject["Username"].Value(), + jObject["PathToKeyFile"].Value(), jObject["PassPhrase"].Value()); + + } + + } + } +} \ No newline at end of file diff --git a/SSH.CommandSender/Domain/SshHostDetails.cs b/SSH.CommandSender/Domain/SshHostDetails.cs index 725a6a0..5b5a70b 100644 --- a/SSH.CommandSender/Domain/SshHostDetails.cs +++ b/SSH.CommandSender/Domain/SshHostDetails.cs @@ -1,28 +1,100 @@ using System; +using Newtonsoft.Json; +using Renci.SshNet; namespace SSH.CommandSender.Domain { public class SshHostDetails : ICloneable { + public abstract class Auth + { + public string Username { get; set; } + + public Auth(string username) + { + Username = username; + } + + public abstract SshClient CreateSshClient(string host, ushort port); + + public abstract bool Validate(); + } + + public class PrivateKeyFileAuth : Auth + { + public string PathToKeyFile { get; set; } + public string PassPhrase { get; set; } + + public PrivateKeyFileAuth(string username, string pathToKeyFile, string passPhrase) : base(username) + { + PathToKeyFile = pathToKeyFile; + PassPhrase = passPhrase; + } + + public override SshClient CreateSshClient(string host, ushort port) + { + return new SshClient(host, port, Username, new PrivateKeyFile(this.PathToKeyFile, this.PassPhrase)); + + } + + public override bool Validate() + { + return string.IsNullOrWhiteSpace(this.Username) == false && + string.IsNullOrWhiteSpace(this.PathToKeyFile) == false; + } + } + + public class PasswordAuth : Auth + { + public string Password { get; set; } + + public PasswordAuth(string username, string password) : base(username) + { + Password = password; + } + + public override SshClient CreateSshClient(string host, ushort port) + { + return new SshClient(host, port, Username, Password); + } + + public override bool Validate() + { + return string.IsNullOrWhiteSpace(this.Username) == false; + } + } public string Name { get; set; } public string Host { get; set; } - public ushort Port { get; } - public string Username { get; set; } - public string Password { get; set; } + public ushort Port { get; set; } - public SshHostDetails(string name = "", string host = "",string username = "", string password = "", ushort port = 22) + [JsonConverter(typeof(AuthJsonConverter))] + public Auth AuthenticationDetails { get; set; } + + public SshHostDetails(string name = "", string host = "", ushort port = 22, Auth authenticationDetails = null) { Name = name; Host = host; Port = port; - Username = username; - Password = password; + + if (authenticationDetails == null) + { + AuthenticationDetails = new PasswordAuth(string.Empty, string.Empty); + } + else + { + AuthenticationDetails = authenticationDetails; + } } + public SshClient CreateSshClient() + { + return AuthenticationDetails.CreateSshClient(Host,Port); + + } public object Clone() { - return new SshHostDetails(this.Name, this.Host, this.Username, this.Password, this.Port); + return new SshHostDetails(this.Name, this.Host, this.Port, AuthenticationDetails); } } } \ No newline at end of file diff --git a/SSH.CommandSender/Properties/AssemblyInfo.cs b/SSH.CommandSender/Properties/AssemblyInfo.cs index e4b89f9..02522e3 100644 --- a/SSH.CommandSender/Properties/AssemblyInfo.cs +++ b/SSH.CommandSender/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.6")] -[assembly: AssemblyFileVersion("1.0.0.6")] +[assembly: AssemblyVersion("1.0.0.7")] +[assembly: AssemblyFileVersion("1.0.0.7")] diff --git a/SSH.CommandSender/SSH.CommandSender.csproj b/SSH.CommandSender/SSH.CommandSender.csproj index 47a4d34..7e6fb57 100644 --- a/SSH.CommandSender/SSH.CommandSender.csproj +++ b/SSH.CommandSender/SSH.CommandSender.csproj @@ -68,6 +68,7 @@ HostEditorDialog.cs + diff --git a/SSH.CommandSender/SSHCommandSender.cs b/SSH.CommandSender/SSHCommandSender.cs index b3c5bb7..8cc59c1 100644 --- a/SSH.CommandSender/SSHCommandSender.cs +++ b/SSH.CommandSender/SSHCommandSender.cs @@ -439,7 +439,7 @@ private void ShowHostEditorDialog(string windowTitle, SshHostDetails host, bool var relevantHost = hostEditorDialog.HostDetails; if (string.IsNullOrWhiteSpace(relevantHost.Name) == false && string.IsNullOrWhiteSpace(relevantHost.Host) == false && - string.IsNullOrWhiteSpace(relevantHost.Username) == false && relevantHost.Port > 0) + relevantHost.AuthenticationDetails.Validate() && relevantHost.Port > 0) { if (appedToList) { @@ -527,7 +527,7 @@ private void RunTasks() })); try { - using (var client = new SshClient(server.Host, server.Port, server.Username, server.Password)) + using (var client = server.CreateSshClient()) { WriteLogThreadSafety(page, $"Trying to connect to {server.Host}:{server.Port}");