Generate session logic moved to correct place.
This commit is contained in:
parent
a3e5be7fe3
commit
f42298e7fe
5 changed files with 52 additions and 47 deletions
Binary file not shown.
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using WebsitePanel.Setup.Common;
|
||||
|
||||
namespace WebsitePanel.Setup.Actions
|
||||
{
|
||||
|
@ -114,6 +115,55 @@ namespace WebsitePanel.Setup.Actions
|
|||
}
|
||||
}
|
||||
|
||||
public class GenerateSessionValidationKeyAction : Action, IInstallAction
|
||||
{
|
||||
public const string LogStartInstallMessage = "Generating session validation key...";
|
||||
|
||||
void IInstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
try
|
||||
{
|
||||
Begin(LogStartInstallMessage);
|
||||
|
||||
Log.WriteStart(LogStartInstallMessage);
|
||||
|
||||
string path = Path.Combine(vars.InstallationFolder, "web.config");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log.WriteInfo(string.Format("File {0} not found", path));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.WriteStart("Updating configuration file (session validation key)");
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(path);
|
||||
|
||||
XmlElement sessionKey = doc.SelectSingleNode("configuration/appSettings/add[@key='SessionValidationKey']") as XmlElement;
|
||||
if (sessionKey == null)
|
||||
{
|
||||
Log.WriteInfo("SessionValidationKey setting not found");
|
||||
return;
|
||||
}
|
||||
|
||||
sessionKey.SetAttribute("value", StringUtils.GenerateRandomString(16));
|
||||
doc.Save(path);
|
||||
|
||||
Log.WriteEnd("Generated session validation key");
|
||||
InstallLog.AppendLine("- Generated session validation key");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Utils.IsThreadAbortException(ex))
|
||||
return;
|
||||
//
|
||||
Log.WriteError("Site settigs error", ex);
|
||||
//
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateDesktopShortcutsAction : Action, IInstallAction
|
||||
{
|
||||
public const string LogStartInstallMessage = "Creating shortcut...";
|
||||
|
@ -253,6 +303,7 @@ namespace WebsitePanel.Setup.Actions
|
|||
new CreateWebSiteAction(),
|
||||
new SwitchAppPoolAspNetVersion(),
|
||||
new UpdateEnterpriseServerUrlAction(),
|
||||
new GenerateSessionValidationKeyAction(),
|
||||
new SaveComponentConfigSettingsAction(),
|
||||
new CreateDesktopShortcutsAction()
|
||||
};
|
||||
|
|
|
@ -88,8 +88,7 @@ namespace WebsitePanel.Setup
|
|||
SwitchServer2AspNet40,
|
||||
SwitchEntServer2AspNet40,
|
||||
SwitchWebPortal2AspNet40,
|
||||
ConfigureSecureSessionModuleInWebConfig,
|
||||
UpdatePortalSessionValidationKey
|
||||
ConfigureSecureSessionModuleInWebConfig
|
||||
}
|
||||
|
||||
public class InstallAction
|
||||
|
|
|
@ -217,10 +217,6 @@ namespace WebsitePanel.Setup
|
|||
action.Description = "Updating site settings...";
|
||||
page3.Actions.Add(action);
|
||||
|
||||
action = new InstallAction(ActionTypes.UpdatePortalSessionValidationKey);
|
||||
action.Description = "Generate session validation key...";
|
||||
page3.Actions.Add(action);
|
||||
|
||||
action = new InstallAction(ActionTypes.UpdateConfig);
|
||||
action.Description = "Updating system configuration...";
|
||||
page3.Actions.Add(action);
|
||||
|
|
|
@ -260,9 +260,6 @@ namespace WebsitePanel.Setup
|
|||
break;
|
||||
case ActionTypes.ConfigureSecureSessionModuleInWebConfig:
|
||||
ConfigureSecureSessionModuleInWebConfig();
|
||||
break;
|
||||
case ActionTypes.UpdatePortalSessionValidationKey:
|
||||
UpdatePortalSessionValidationKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2657,44 +2654,6 @@ namespace WebsitePanel.Setup
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdatePortalSessionValidationKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
string installFolder = Wizard.SetupVariables.InstallationFolder;
|
||||
string path = Path.Combine(installFolder, "web.config");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log.WriteInfo(string.Format("File {0} not found", path));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.WriteStart("Updating configuration file (session validation key)");
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(path);
|
||||
|
||||
XmlElement sessionKey = doc.SelectSingleNode("configuration/appSettings/add[@key='SessionValidationKey']") as XmlElement;
|
||||
if (sessionKey == null)
|
||||
{
|
||||
Log.WriteInfo("SessionValidationKey setting not found");
|
||||
return;
|
||||
}
|
||||
|
||||
sessionKey.SetAttribute("value", StringUtils.GenerateRandomString(16));
|
||||
doc.Save(path);
|
||||
Log.WriteEnd("Updated configuration file");
|
||||
InstallLog.AppendLine("- Updated session validation key in the configuration file");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Utils.IsThreadAbortException(ex))
|
||||
return;
|
||||
Log.WriteError("Configuration file update error", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetServiceSettings()
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue