diff --git a/TGS.CommandLine/Program.cs b/TGS.CommandLine/Program.cs
index 262c2a4031..0e2986d944 100644
--- a/TGS.CommandLine/Program.cs
+++ b/TGS.CommandLine/Program.cs
@@ -52,7 +52,7 @@ namespace TGS.CommandLine
}
argsAsList.RemoveAt(I);
argsAsList.RemoveAt(I);
- ReplaceInterface(new ServerInterface(address, port, username, password));
+ ReplaceInterface(new ServerInterface(new RemoteLoginInfo(address, port, username, password)));
break;
}
}
@@ -230,7 +230,7 @@ namespace TGS.CommandLine
var username = Console.ReadLine();
Console.Write("Enter password: ");
var password = ReadLineSecure();
- ReplaceInterface(new ServerInterface(address, port, username, password));
+ ReplaceInterface(new ServerInterface(new RemoteLoginInfo(address, port, username, password)));
var res = currentInterface.ConnectionStatus(out string error);
if (!res.HasFlag(ConnectivityLevel.Connected))
{
diff --git a/TGS.ControlPanel/ControlPanel/ControlPanel.cs b/TGS.ControlPanel/ControlPanel/ControlPanel.cs
index a6d66c86a3..5ebbf73f1b 100644
--- a/TGS.ControlPanel/ControlPanel/ControlPanel.cs
+++ b/TGS.ControlPanel/ControlPanel/ControlPanel.cs
@@ -32,7 +32,7 @@ namespace TGS.ControlPanel
FormClosed += ControlPanel_FormClosed;
Interface = I;
if (Interface.IsRemoteConnection)
- Text = String.Format("TGS {0}: {1}:{2}", Interface.ServerVersion, Interface.HTTPSURL, Interface.HTTPSPort);
+ Text = String.Format("TGS {0}: {1}:{2}", Interface.ServerVersion, Interface.LoginInfo.IP, Interface.LoginInfo.Port);
Text = String.Format("{0} Instance: {1}", Text, I.InstanceName);
Panels.SelectedIndexChanged += Panels_SelectedIndexChanged;
Panels.SelectedIndex += Math.Min(Properties.Settings.Default.LastPageIndex, Panels.TabCount - 1);
diff --git a/TGS.ControlPanel/InstanceSelector.cs b/TGS.ControlPanel/InstanceSelector.cs
index 504b2218b9..0d8a606d74 100644
--- a/TGS.ControlPanel/InstanceSelector.cs
+++ b/TGS.ControlPanel/InstanceSelector.cs
@@ -100,7 +100,7 @@ namespace TGS.ControlPanel
activeCP.BringToFront();
return;
}
- var InstanceAccessor = new ServerInterface(masterInterface as ServerInterface);
+ var InstanceAccessor = new ServerInterface(masterInterface.LoginInfo);
try
{
ConnectivityLevel res = ConnectivityLevel.None;
diff --git a/TGS.ControlPanel/Login.cs b/TGS.ControlPanel/Login.cs
index 8b03af0ee1..4708c515bf 100644
--- a/TGS.ControlPanel/Login.cs
+++ b/TGS.ControlPanel/Login.cs
@@ -31,7 +31,7 @@ namespace TGS.ControlPanel
{
IPTextBox.Text = IPTextBox.Text.Trim();
UsernameTextBox.Text = UsernameTextBox.Text.Trim();
- using (var I = new ServerInterface(IPTextBox.Text, (ushort)PortSelector.Value, UsernameTextBox.Text, PasswordTextBox.Text))
+ using (var I = new ServerInterface(new RemoteLoginInfo(IPTextBox.Text, (ushort)PortSelector.Value, UsernameTextBox.Text, PasswordTextBox.Text)))
{
var Config = Properties.Settings.Default;
Config.RemoteIP = IPTextBox.Text;
diff --git a/TGS.Interface/RemoteLoginInfo.cs b/TGS.Interface/RemoteLoginInfo.cs
new file mode 100644
index 0000000000..c161a124cb
--- /dev/null
+++ b/TGS.Interface/RemoteLoginInfo.cs
@@ -0,0 +1,60 @@
+using System;
+
+namespace TGS.Interface
+{
+ ///
+ /// Information representing a remote server connection
+ ///
+ [Serializable]
+ public sealed class RemoteLoginInfo
+ {
+ ///
+ /// The IP address or URL of the target server
+ ///
+ public string IP { get; }
+ ///
+ /// The port to connect to the target server
+ ///
+ public ushort Port { get; }
+ ///
+ /// A Windows username for the target server
+ ///
+ public string Username { get; }
+ ///
+ /// The Windows password for
+ ///
+ internal string Password { get; }
+
+ ///
+ /// Backing field for
+ ///
+ readonly string _ip;
+ ///
+ /// Backing field for
+ ///
+ readonly ushort _port;
+ ///
+ /// Backing field for
+ ///
+ readonly string _username;
+ ///
+ /// Backing field for
+ ///
+ readonly string _password;
+
+ ///
+ /// Construct a
+ ///
+ /// The value for
+ /// The value for
+ /// The value for
+ /// The value for
+ public RemoteLoginInfo(string ip, ushort port, string username, string password)
+ {
+ _ip = ip;
+ _port = port;
+ _username = username;
+ _password = password;
+ }
+ }
+}
diff --git a/TGS.Interface/ServerInterface.cs b/TGS.Interface/ServerInterface.cs
index 833b9c5574..3fa5c99bb9 100644
--- a/TGS.Interface/ServerInterface.cs
+++ b/TGS.Interface/ServerInterface.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Security;
@@ -27,14 +26,9 @@ namespace TGS.Interface
string InstanceName { get; }
///
- /// If this is set, we will try and connect to an HTTPS server running at this address
+ /// The for the . Is for local connections
///
- string HTTPSURL { get; }
-
- ///
- /// The port used to connect to the
- ///
- ushort HTTPSPort { get; }
+ RemoteLoginInfo LoginInfo { get; }
///
/// Checks if the is setup for a remote connection
@@ -151,30 +145,12 @@ namespace TGS.Interface
public string InstanceName { get; private set; }
///
- /// If this is set, we will try and connect to an HTTPS server running at this address
+ /// Backing field for
///
- readonly string _HTTPSURL;
+ readonly RemoteLoginInfo _loginInfo;
///
- public string HTTPSURL { get { return _HTTPSURL; } }
-
- ///
- /// The port used to connect to the
- ///
- readonly ushort _HTTPSPort;
-
- ///
- public ushort HTTPSPort { get { return _HTTPSPort; } }
-
- ///
- /// Username for remote operations
- ///
- readonly string HTTPSUsername;
-
- ///
- /// Password for remote operations
- ///
- readonly string HTTPSPassword;
+ public RemoteLoginInfo LoginInfo { get { return _loginInfo; } }
///
/// Associated list of open s keyed by type name. A in this list may close or fault at any time. Must be locked before being accessed
@@ -237,24 +213,12 @@ namespace TGS.Interface
///
/// Construct an for a remote connection
///
- /// The address of the remote server
- /// The port the remote server runs on
- /// Windows account username for the remote server
- /// Windows account password for the remote server
- public ServerInterface(string address, ushort port, string username, string password)
+ /// The for a remote connection
+ public ServerInterface(RemoteLoginInfo loginInfo)
{
- _HTTPSURL = address;
- _HTTPSPort = port;
- HTTPSUsername = username;
- HTTPSPassword = password;
+ _loginInfo = loginInfo;
}
- ///
- /// Constructs an that connects to the same as some
- ///
- /// Another to copy settings from
- public ServerInterface(ServerInterface other) : this(other.HTTPSURL, other.HTTPSPort, other.HTTPSUsername, other.HTTPSPassword) { }
-
///
public ConnectivityLevel ConnectToInstance(string instanceName = null, bool skipChecks = false)
{
@@ -297,7 +261,7 @@ namespace TGS.Interface
}
///
- public bool IsRemoteConnection { get { return HTTPSURL != null; } }
+ public bool IsRemoteConnection { get { return LoginInfo != null; } }
///
/// Closes all s stored in and clears it
@@ -436,12 +400,12 @@ namespace TGS.Interface
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Mode = requireAuth ? SecurityMode.TransportWithMessageCredential : SecurityMode.Transport; //do not require auth for a connectivity check
binding.Security.Message.ClientCredentialType = requireAuth ? MessageCredentialType.UserName : MessageCredentialType.None;
- var address = new EndpointAddress(String.Format("https://{0}:{1}/{2}/{3}", HTTPSURL, HTTPSPort, accessPath, InterfaceName));
+ var address = new EndpointAddress(String.Format("https://{0}:{1}/{2}/{3}", LoginInfo.IP, LoginInfo.Password, accessPath, InterfaceName));
var res = new ChannelFactory(binding, address);
if (requireAuth)
{
- res.Credentials.UserName.UserName = HTTPSUsername;
- res.Credentials.UserName.Password = HTTPSPassword;
+ res.Credentials.UserName.UserName = LoginInfo.Username;
+ res.Credentials.UserName.Password = LoginInfo.Password;
res.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
}
return res;
diff --git a/TGS.Interface/TGS.Interface.csproj b/TGS.Interface/TGS.Interface.csproj
index fa07f5838f..7fcfc32cbb 100644
--- a/TGS.Interface/TGS.Interface.csproj
+++ b/TGS.Interface/TGS.Interface.csproj
@@ -65,6 +65,7 @@
+
diff --git a/TGS.Tests/ServiceInterface/TestInterface.cs b/TGS.Tests/ServiceInterface/TestInterface.cs
index cd4f55ac9d..79552086ef 100644
--- a/TGS.Tests/ServiceInterface/TestInterface.cs
+++ b/TGS.Tests/ServiceInterface/TestInterface.cs
@@ -52,7 +52,7 @@ namespace TGS.Interface.Tests
/// The created
ServerInterface CreateFakeRemoteInterface()
{
- return new ServerInterface("some.fake.url.420", 34752, "user", "password");
+ return new ServerInterface(new RemoteLoginInfo("some.fake.url.420", 34752, "user", "password"));
}
///
@@ -77,9 +77,11 @@ namespace TGS.Interface.Tests
public void TestCopyRemoteInterface()
{
var first = CreateFakeRemoteInterface();
- var second = new ServerInterface(first);
- Assert.AreEqual(first.HTTPSURL, second.HTTPSURL);
- Assert.AreEqual(first.HTTPSPort, second.HTTPSPort);
+ var second = new ServerInterface(first.LoginInfo);
+ Assert.AreEqual(first.LoginInfo.IP, second.LoginInfo.IP);
+ Assert.AreEqual(first.LoginInfo.Port, second.LoginInfo.Port);
+ Assert.AreEqual(first.LoginInfo.Username, second.LoginInfo.Username);
+ Assert.AreEqual(first.LoginInfo.Password, second.LoginInfo.Password);
Assert.IsTrue(second.IsRemoteConnection);
}