Added crypto key into scheduler service config
This commit is contained in:
parent
38c8ac1199
commit
9a10d75492
3 changed files with 31 additions and 4 deletions
|
@ -33,7 +33,8 @@ namespace WebsitePanel.SchedulerServiceInstaller
|
||||||
[CustomAction]
|
[CustomAction]
|
||||||
public static ActionResult FinalizeInstall(Session session)
|
public static ActionResult FinalizeInstall(Session session)
|
||||||
{
|
{
|
||||||
ChangeConnectionString(session["CONNECTIONSTRING"], session["INSTALLFOLDER"]);
|
ChangeConfigString("installer.connectionstring", session["CONNECTIONSTRING"], session["INSTALLFOLDER"]);
|
||||||
|
ChangeCryptoKey(session["INSTALLFOLDER"]);
|
||||||
InstallService(session["INSTALLFOLDER"]);
|
InstallService(session["INSTALLFOLDER"]);
|
||||||
|
|
||||||
return ActionResult.Success;
|
return ActionResult.Success;
|
||||||
|
@ -55,7 +56,26 @@ namespace WebsitePanel.SchedulerServiceInstaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ChangeConnectionString(string connectionString, string installFolder)
|
private static void ChangeCryptoKey(string installFolder)
|
||||||
|
{
|
||||||
|
string path = Path.Combine(installFolder.Replace("SchedulerService", "Enterprise Server"), "web.config");
|
||||||
|
string cryptoKey = "0123456789";
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(path))
|
||||||
|
{
|
||||||
|
string content = reader.ReadToEnd();
|
||||||
|
var pattern = new Regex(@"(?<=<add key=""WebsitePanel.CryptoKey"" .*?value\s*=\s*"")[^""]+(?="".*?>)");
|
||||||
|
Match match = pattern.Match(content);
|
||||||
|
cryptoKey = match.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangeConfigString("installer.cryptokey", cryptoKey, installFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ChangeConfigString(string searchString, string replaceValue, string installFolder)
|
||||||
{
|
{
|
||||||
string content;
|
string content;
|
||||||
string path = Path.Combine(installFolder, "WebsitePanel.SchedulerService.exe.config");
|
string path = Path.Combine(installFolder, "WebsitePanel.SchedulerService.exe.config");
|
||||||
|
@ -65,8 +85,8 @@ namespace WebsitePanel.SchedulerServiceInstaller
|
||||||
content = reader.ReadToEnd();
|
content = reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
var re = new Regex("\\$\\{" + "installer.connectionstring" + "\\}+", RegexOptions.IgnoreCase);
|
var re = new Regex("\\$\\{" + searchString + "\\}+", RegexOptions.IgnoreCase);
|
||||||
content = re.Replace(content, connectionString);
|
content = re.Replace(content, replaceValue);
|
||||||
|
|
||||||
using (var writer = new StreamWriter(path))
|
using (var writer = new StreamWriter(path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||||
</startup>
|
</startup>
|
||||||
|
<appSettings>
|
||||||
|
<!-- Encryption util settings -->
|
||||||
|
<add key="WebsitePanel.CryptoKey" value="0123456789"/>
|
||||||
|
<!-- A1D4KDHUE83NKHddF -->
|
||||||
|
<add key="WebsitePanel.EncryptionEnabled" value="true" />
|
||||||
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -327,6 +327,7 @@
|
||||||
</MSBuild>
|
</MSBuild>
|
||||||
|
|
||||||
<XmlUpdate XmlFileName="$(RootFolder)\WebsitePanel\Sources\WebsitePanel.SchedulerService\Bin\WebsitePanel.SchedulerService.exe.config" Xpath="//configuration/connectionStrings/add/@connectionString" Value="${installer.connectionstring}" />
|
<XmlUpdate XmlFileName="$(RootFolder)\WebsitePanel\Sources\WebsitePanel.SchedulerService\Bin\WebsitePanel.SchedulerService.exe.config" Xpath="//configuration/connectionStrings/add/@connectionString" Value="${installer.connectionstring}" />
|
||||||
|
<XmlUpdate XmlFileName="$(RootFolder)\WebsitePanel\Sources\WebsitePanel.SchedulerService\Bin\WebsitePanel.SchedulerService.exe.config" Xpath="//configuration/appSettings/add[@key=%22WebsitePanel.CryptoKey%22]/@value" Value="${installer.cryptokey}" />
|
||||||
|
|
||||||
<MSBuild Projects="$(RootFolder)\WebsitePanel.Installer\Sources\Setup.SchedulerService\Setup.SchedulerService.wixproj" Properties="Configuration=$(BuildConfiguration);DefineSolutionProperties=false">
|
<MSBuild Projects="$(RootFolder)\WebsitePanel.Installer\Sources\Setup.SchedulerService\Setup.SchedulerService.wixproj" Properties="Configuration=$(BuildConfiguration);DefineSolutionProperties=false">
|
||||||
<Output
|
<Output
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue