CA-253936: Fix proxy authentication in the XenServerHealthCheck service

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2017-05-23 16:57:38 +01:00
parent f54cbb6164
commit ad6631f698
6 changed files with 23 additions and 12 deletions

View File

@ -259,6 +259,9 @@ namespace XenAdmin.Dialogs.OptionsPages
}
Program.ReconfigureConnectionSettings();
string protectedUsername = Properties.Settings.Default.ProxyUsername;
string protectedPassword = Properties.Settings.Default.ProxyPassword;
new TransferProxySettingsAction(
(HTTPHelper.ProxyStyle)Properties.Settings.Default.ProxySetting,
Properties.Settings.Default.ProxyAddress,
@ -267,8 +270,8 @@ namespace XenAdmin.Dialogs.OptionsPages
false,
Properties.Settings.Default.BypassProxyForServers,
Properties.Settings.Default.ProvideProxyAuthentication,
Properties.Settings.Default.ProxyUsername,
Properties.Settings.Default.ProxyPassword,
string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(protectedUsername),
string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(protectedPassword),
(HTTP.ProxyAuthenticationMethod)Properties.Settings.Default.ProxyAuthenticationMethod).RunAsync();
}

View File

@ -525,6 +525,9 @@ namespace XenAdmin
try
{
Settings.RestoreSession();
string protectedUsername = Properties.Settings.Default.ProxyUsername;
string protectedPassword = Properties.Settings.Default.ProxyPassword;
new TransferProxySettingsAction(
(HTTPHelper.ProxyStyle)Properties.Settings.Default.ProxySetting,
Properties.Settings.Default.ProxyAddress,
@ -533,8 +536,8 @@ namespace XenAdmin
true,
Properties.Settings.Default.BypassProxyForServers,
Properties.Settings.Default.ProvideProxyAuthentication,
Properties.Settings.Default.ProxyUsername,
Properties.Settings.Default.ProxyPassword,
string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(protectedUsername),
string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(protectedPassword),
(HTTP.ProxyAuthenticationMethod)Properties.Settings.Default.ProxyAuthenticationMethod).RunAsync();
}
catch (ConfigurationErrorsException ex)

View File

@ -33,6 +33,7 @@ using System;
using System.IO.Pipes;
using System.ServiceProcess;
using System.Text;
using XenAdmin.Core;
using XenAdmin.Model;
using XenAPI;
@ -82,8 +83,8 @@ namespace XenAdmin.Actions
timeOut.ToString(),
bypassProxyForServers.ToString(),
provideProxyCredentials.ToString(),
proxyUsername.ToString(),
proxyPassword.ToString(),
EncryptionUtils.ProtectForLocalMachine(proxyUsername),
EncryptionUtils.ProtectForLocalMachine(proxyPassword),
((Int32)proxyAuthenticationMethod).ToString()});
return proxySettings;

View File

@ -131,6 +131,7 @@ namespace XenServerHealthCheck.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public bool ProvideProxyAuthentication {
get {
return ((bool)(this["ProvideProxyAuthentication"]));
@ -143,6 +144,7 @@ namespace XenServerHealthCheck.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string ProxyUsername {
get {
return ((string)(this["ProxyUsername"]));
@ -155,6 +157,7 @@ namespace XenServerHealthCheck.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string ProxyPassword {
get {
return ((string)(this["ProxyPassword"]));
@ -167,6 +170,7 @@ namespace XenServerHealthCheck.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public int ProxyAuthenticationMethod {
get {
return ((int)(this["ProxyAuthenticationMethod"]));

View File

@ -27,16 +27,16 @@
<Setting Name="ConnectionTimeout" Roaming="true" Type="System.Int32" Scope="User">
<Value Profile="(Default)">20000</Value>
</Setting>
<Setting Name="ProvideProxyAuthentication" Type="System.Boolean" Scope="User">
<Setting Name="ProvideProxyAuthentication" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ProxyUsername" Type="System.String" Scope="User">
<Setting Name="ProxyUsername" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProxyPassword" Type="System.String" Scope="User">
<Setting Name="ProxyPassword" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProxyAuthenticationMethod" Type="System.Int32" Scope="User">
<Setting Name="ProxyAuthenticationMethod" Roaming="true" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
</Settings>

View File

@ -230,8 +230,8 @@ namespace XenServerHealthCheck
Properties.Settings.Default.ConnectionTimeout = Int32.Parse(proxySettings[4]);
Properties.Settings.Default.BypassProxyForServers = bool.Parse(proxySettings[5]);
Properties.Settings.Default.ProvideProxyAuthentication = bool.Parse(proxySettings[6]);
Properties.Settings.Default.ProxyUsername = proxySettings[7];
Properties.Settings.Default.ProxyPassword = proxySettings[8];
Properties.Settings.Default.ProxyUsername = EncryptionUtils.Protect(EncryptionUtils.UnprotectForLocalMachine(proxySettings[7]));
Properties.Settings.Default.ProxyPassword = EncryptionUtils.Protect(EncryptionUtils.UnprotectForLocalMachine(proxySettings[8]));
Properties.Settings.Default.ProxyAuthenticationMethod = Int32.Parse(proxySettings[9]);
break;