modified export form to handle the new credential management system

This commit is contained in:
David Sparer
2017-03-06 15:04:48 -07:00
parent 8b44815b70
commit f433b911a0
9 changed files with 81 additions and 27 deletions

View File

@@ -3,7 +3,9 @@ using System.Xml.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Credential;
using mRemoteNG.Security;
using NSubstitute;
using NUnit.Framework;
@@ -76,6 +78,7 @@ namespace mRemoteNGTests.Config.Serializers
Username = "myuser",
Domain = "superdomain",
Password = "pass",
CredentialRecord = Substitute.For<ICredentialRecord>(),
Hostname = "somehost",
ExtApp = "myextapp",
PreExtApp = "preext1",
@@ -108,6 +111,7 @@ namespace mRemoteNGTests.Config.Serializers
yield return new TestCaseData("RDGatewayPassword", ConnectionInfo);
yield return new TestCaseData("VNCProxyUsername", ConnectionInfo);
yield return new TestCaseData("VNCProxyPassword", ConnectionInfo);
yield return new TestCaseData("CredentialId", ConnectionInfo);
}
}

View File

@@ -53,6 +53,7 @@ namespace mRemoteNGTests.Config.Serializers
Assert.That(connectionNode, Is.Not.Null);
}
[TestCase("CredentialId", "")]
[TestCase("InheritAutomaticResize", "False")]
public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue)
{

View File

@@ -20,7 +20,7 @@ namespace mRemoteNG.App
{
try
{
var saveSecurity = new SaveFilter();
var saveFilter = new SaveFilter();
using (var exportForm = new ExportForm())
{
@@ -50,12 +50,13 @@ namespace mRemoteNG.App
break;
}
saveSecurity.SaveUsername = exportForm.IncludeUsername;
saveSecurity.SavePassword = exportForm.IncludePassword;
saveSecurity.SaveDomain = exportForm.IncludeDomain;
saveSecurity.SaveInheritance = exportForm.IncludeInheritance;
saveFilter.SaveUsername = exportForm.IncludeUsername;
saveFilter.SavePassword = exportForm.IncludePassword;
saveFilter.SaveDomain = exportForm.IncludeDomain;
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveSecurity, exportTarget);
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
}
}

View File

@@ -11,7 +11,7 @@ namespace mRemoteNG.Config.Serializers
{
private readonly ICryptographyProvider _cryptographyProvider;
private readonly SecureString _encryptionKey;
private readonly SaveFilter _saveFilter = new SaveFilter();
private readonly SaveFilter _saveFilter;
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
@@ -41,7 +41,9 @@ namespace mRemoteNG.Config.Serializers
element.Add(new XAttribute("Panel", connectionInfo.Panel));
element.Add(new XAttribute("Id", connectionInfo.ConstantID));
element.Add(new XAttribute("CredentialId", connectionInfo.CredentialRecord?.Id.ToString() ?? ""));
element.Add(_saveFilter.SaveCredentialId
? new XAttribute("CredentialId", connectionInfo.CredentialRecord?.Id.ToString() ?? "")
: new XAttribute("CredentialId", ""));
element.Add(new XAttribute("Hostname", connectionInfo.Hostname));
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));

View File

@@ -258,6 +258,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to Assigned Credential.
/// </summary>
internal static string strAssignedCredential {
get {
return ResourceManager.GetString("strAssignedCredential", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Automatically get session information.
/// </summary>

View File

@@ -2505,4 +2505,7 @@ mRemoteNG will now quit and begin with the installation.</value>
<data name="strLogToAppDir" xml:space="preserve">
<value>Log to application directory</value>
</data>
<data name="strAssignedCredential" xml:space="preserve">
<value>Assigned Credential</value>
</data>
</root>

View File

@@ -9,7 +9,8 @@ namespace mRemoteNG.Security
SaveUsername = true;
SavePassword = true;
SaveDomain = true;
SaveInheritance = true;
SaveCredentialId = true;
SaveInheritance = true;
}
public bool SaveUsername { get; set; }
@@ -18,6 +19,8 @@ namespace mRemoteNG.Security
public bool SaveDomain { get; set; }
public bool SaveCredentialId { get; set; }
public bool SaveInheritance { get; set; }
}
}

View File

@@ -18,6 +18,7 @@ namespace mRemoteNG.UI.Forms
this.txtFileName = new System.Windows.Forms.TextBox();
this.btnBrowse = new System.Windows.Forms.Button();
this.grpProperties = new System.Windows.Forms.GroupBox();
this.chkAssignedCredential = new System.Windows.Forms.CheckBox();
this.grpFile = new System.Windows.Forms.GroupBox();
this.lblFileFormat = new System.Windows.Forms.Label();
this.lblFileName = new System.Windows.Forms.Label();
@@ -131,6 +132,7 @@ namespace mRemoteNG.UI.Forms
//
// grpProperties
//
this.grpProperties.Controls.Add(this.chkAssignedCredential);
this.grpProperties.Controls.Add(this.lblUncheckProperties);
this.grpProperties.Controls.Add(this.chkInheritance);
this.grpProperties.Controls.Add(this.chkUsername);
@@ -143,6 +145,18 @@ namespace mRemoteNG.UI.Forms
this.grpProperties.TabStop = false;
this.grpProperties.Text = "Export Properties";
//
// chkAssignedCredential
//
this.chkAssignedCredential.AutoSize = true;
this.chkAssignedCredential.Checked = true;
this.chkAssignedCredential.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkAssignedCredential.Location = new System.Drawing.Point(143, 32);
this.chkAssignedCredential.Name = "chkAssignedCredential";
this.chkAssignedCredential.Size = new System.Drawing.Size(119, 17);
this.chkAssignedCredential.TabIndex = 5;
this.chkAssignedCredential.Text = "Assigned Credential";
this.chkAssignedCredential.UseVisualStyleBackColor = true;
//
// grpFile
//
this.grpFile.Controls.Add(this.lblFileFormat);
@@ -183,6 +197,7 @@ namespace mRemoteNG.UI.Forms
this.cboFileFormat.Name = "cboFileFormat";
this.cboFileFormat.Size = new System.Drawing.Size(294, 21);
this.cboFileFormat.TabIndex = 4;
this.cboFileFormat.SelectedIndexChanged += new System.EventHandler(this.cboFileformat_SelectedIndexChanged);
//
// grpItems
//
@@ -299,5 +314,7 @@ namespace mRemoteNG.UI.Forms
private System.Windows.Forms.RadioButton rdoExportSelectedFolder;
private System.Windows.Forms.RadioButton rdoExportEverything;
#endregion
}
private CheckBox chkAssignedCredential;
}
}

View File

@@ -47,20 +47,13 @@ namespace mRemoteNG.UI.Forms
{
get
{
if (rdoExportSelectedFolder.Checked)
{
if (rdoExportSelectedFolder.Checked)
return ExportScope.SelectedFolder;
}
else if (rdoExportSelectedConnection.Checked)
{
return ExportScope.SelectedConnection;
}
else
{
return ExportScope.Everything;
}
if (rdoExportSelectedConnection.Checked)
return ExportScope.SelectedConnection;
return ExportScope.Everything;
}
set
set
{
switch (value)
{
@@ -142,7 +135,13 @@ namespace mRemoteNG.UI.Forms
chkDomain.Checked = value;
}
}
public bool IncludeAssignedCredential
{
get { return chkAssignedCredential.Checked; }
set { chkAssignedCredential.Checked = value; }
}
public bool IncludeInheritance
{
get
@@ -160,19 +159,15 @@ namespace mRemoteNG.UI.Forms
public ExportForm()
{
InitializeComponent();
Runtime.FontOverride(this);
SelectedFolder = null;
SelectedConnection = null;
btnOK.Enabled = false;
}
#endregion
#region Private Methods
#region Event Handlers
private void ExportForm_Load(object sender, EventArgs e)
{
cboFileFormat.Items.Clear();
@@ -225,6 +220,24 @@ namespace mRemoteNG.UI.Forms
{
DialogResult = DialogResult.Cancel;
}
private void cboFileformat_SelectedIndexChanged(object sender, EventArgs e)
{
if (SaveFormat == ConnectionsSaver.Format.mRXML)
{
chkUsername.Enabled = false;
chkPassword.Enabled = false;
chkDomain.Enabled = false;
chkAssignedCredential.Enabled = true;
}
else
{
chkUsername.Enabled = true;
chkPassword.Enabled = true;
chkDomain.Enabled = true;
chkAssignedCredential.Enabled = false;
}
}
#endregion
private void ApplyLanguage()
@@ -245,6 +258,7 @@ namespace mRemoteNG.UI.Forms
chkUsername.Text = Language.strCheckboxUsername;
chkPassword.Text = Language.strCheckboxPassword;
chkDomain.Text = Language.strCheckboxDomain;
chkAssignedCredential.Text = Language.strAssignedCredential;
chkInheritance.Text = Language.strCheckboxInheritance;
lblUncheckProperties.Text = Language.strUncheckProperties;