diff --git a/.gitignore b/.gitignore index dc85c3122..33033fba5 100644 --- a/.gitignore +++ b/.gitignore @@ -577,3 +577,7 @@ obj /DownloadServer/obj /BeWoTest/bin /BeWoTest/obj +/UnitTestProject472/bin +/UnitTestProject472/obj +/UnitTestProject45/bin +/UnitTestProject45/obj \ No newline at end of file diff --git a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs index 63d4eea1c..eeab1e806 100644 --- a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs @@ -45,14 +45,19 @@ namespace BeWoLauncher.Logic.Behavior } else { + DownloadController.Start(); + if (UninstallMode) + { + DownloadController.Manager.GetUninstallPlan(); ViewBehavior.ShowUninstallInfo(); + EndWaiting(); + } else Task.Run(() => { try { - DownloadController.Start(); DownloadController.Manager.GetUpdatePlan(); if (DownloadController.Manager.UpdatePlanResponse.HasToDo()) diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs index af73ba4b8..024b19a96 100644 --- a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -53,6 +53,18 @@ namespace BeWoLauncher.Logic.Utils.Download SessionInformation.Session.Version = UpdatePlanResponse.CurrentPackage.Version; } + public void GetUninstallPlan() + { + UpdatePlanResponse = new UpdatePlanResponse(); + + if (LauncherPaths.ActualPlanerLocation.Exists()) + { + if (ApplyFolder.Exists()) + if (!ApplyFolder.IsFolderEmpty()) + UpdatePlanResponse.FilesToDeleteInApply = FileController.GetAppliedFiles(ApplyFolder, false); + } + } + public void StartProcess(BackgroundWorker worker) { var report = new Action((progress, waitms) => @@ -124,7 +136,7 @@ namespace BeWoLauncher.Logic.Utils.Download Feedback((int)LauncherProgress.DownloadUpdate, new DownloadProgressEventArgs(size, file2request)); } - DownloadFolder.Unlock(); + DownloadFolder.Unlock(SkipLock); } public void Apply() { @@ -167,7 +179,7 @@ namespace BeWoLauncher.Logic.Utils.Download DownloadFolder.ClearFolder(); - ApplyFolder.Unlock(); + ApplyFolder.Unlock(SkipLock); } private void CreateUpdatePlanRequest() @@ -185,11 +197,11 @@ namespace BeWoLauncher.Logic.Utils.Download UpdatePlanRequest.ApplyPackage = FileController.GetApplyPackage(ApplyFolder); } - UpdatePlanRequest.Login = new LoginDC() + UpdatePlanRequest.Session = new SessionDC() { Username = SessionInformation.Login.Username, Password = SessionInformation.Login.Password, - CoreServerAddress = SessionInformation.Connection.CoreServerAddress, + CoreServerAddress = SessionInformation.Connection.CoreServerAddressExact, Pin = SessionInformation.Login.Pin, ClientID = SessionInformation.Login.ClientId, CheckTenant = true, diff --git a/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs b/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs index ac1a86671..11473d853 100644 --- a/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs @@ -39,16 +39,29 @@ namespace BeWoLauncher.View.Frames { InitializeComponent(); - proBar1.IsIndeterminate = false; - proBar1.Minimum = 0; - proBar1.Maximum = 100; - - proBar2.IsIndeterminate = false; - proBar2.Minimum = 0; - proBar2.Maximum = DownloadController.Manager.FilesToProcessTotal; + LauncherMode = mode; + if(mode == LauncherMode.Install || mode == LauncherMode.Update) + { + proBar1.IsIndeterminate = false; + proBar1.Minimum = 0; + proBar1.Maximum = 100; + + proBar2.IsIndeterminate = false; + proBar2.Minimum = 0; + proBar2.Maximum = DownloadController.Manager.FilesToProcessTotal; + } + else + { + proBar1.Visibility = Visibility.Collapsed; + + proBar2.IsIndeterminate = true; + proBar2.Minimum = 0; + proBar2.Maximum = DownloadController.Manager.FilesToDeleteInApplyCount; + } + keyword_mode = (int)mode; Loaded += (s, e) => Start(); diff --git a/BeWoOhneReports.sln b/BeWoOhneReports.sln index b029612d0..2883be5ae 100644 --- a/BeWoOhneReports.sln +++ b/BeWoOhneReports.sln @@ -39,16 +39,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CA77E4CE-3 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeWoTest", "BeWoTest\BeWoTest.csproj", "{767ACFAF-D6ED-4DFD-AC49-0990F23B2239}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{825B9513-40EF-48C1-A354-9D4503A3FA74}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject45", "UnitTestProject45\UnitTestProject45.csproj", "{D842A26A-C425-4E28-9A5E-A9993F949862}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject472", "UnitTestProject472\UnitTestProject472.csproj", "{9FDC0675-73D8-4C3B-AA14-425280AD8F58}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 Release|.NET = Release|.NET Release|Any CPU = Release|Any CPU Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|.NET.ActiveCfg = Debug|Any CPU @@ -56,153 +60,225 @@ Global {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|x86.ActiveCfg = Debug|Any CPU + {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Debug|x86.Build.0 = Debug|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|.NET.ActiveCfg = Release|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|Any CPU.Build.0 = Release|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|x86.ActiveCfg = Release|Any CPU + {3FEBB560-9275-413A-9767-BB68C44EEBC3}.Release|x86.Build.0 = Release|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|.NET.ActiveCfg = Debug|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|Any CPU.Build.0 = Debug|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|x86.ActiveCfg = Debug|Any CPU + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Debug|x86.Build.0 = Debug|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|.NET.ActiveCfg = Release|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|Any CPU.ActiveCfg = Release|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|Any CPU.Build.0 = Release|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|x86.ActiveCfg = Release|Any CPU + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}.Release|x86.Build.0 = Release|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|.NET.ActiveCfg = Debug|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|x86.ActiveCfg = Debug|Any CPU + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Debug|x86.Build.0 = Debug|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|.NET.ActiveCfg = Release|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|Any CPU.Build.0 = Release|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|x86.ActiveCfg = Release|Any CPU + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}.Release|x86.Build.0 = Release|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|.NET.ActiveCfg = Debug|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|x86.ActiveCfg = Debug|Any CPU + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Debug|x86.Build.0 = Debug|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|.NET.ActiveCfg = Release|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|Any CPU.Build.0 = Release|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|x86.ActiveCfg = Release|Any CPU + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}.Release|x86.Build.0 = Release|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|.NET.ActiveCfg = Debug|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|x86.ActiveCfg = Debug|Any CPU + {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Debug|x86.Build.0 = Debug|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|.NET.ActiveCfg = Release|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|Any CPU.Build.0 = Release|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|x86.ActiveCfg = Release|Any CPU + {D5E53B0F-BF5A-41E8-93E2-0F32845FC729}.Release|x86.Build.0 = Release|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|.NET.ActiveCfg = Debug|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|Any CPU.Build.0 = Debug|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|x86.ActiveCfg = Debug|Any CPU + {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Debug|x86.Build.0 = Debug|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|.NET.ActiveCfg = Release|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|Any CPU.ActiveCfg = Release|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|Any CPU.Build.0 = Release|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|x86.ActiveCfg = Release|Any CPU + {40D8B312-EA64-49E3-A31A-5E57ED4D5654}.Release|x86.Build.0 = Release|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|.NET.ActiveCfg = Debug|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|x86.ActiveCfg = Debug|Any CPU + {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Debug|x86.Build.0 = Debug|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|.NET.ActiveCfg = Release|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|Any CPU.Build.0 = Release|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|x86.ActiveCfg = Release|Any CPU + {E1154C7B-BB77-4155-9854-DAD8FC5A8BC3}.Release|x86.Build.0 = Release|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|.NET.ActiveCfg = Debug|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|Any CPU.Build.0 = Debug|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|x86.ActiveCfg = Debug|Any CPU + {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Debug|x86.Build.0 = Debug|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|.NET.ActiveCfg = Release|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|Any CPU.ActiveCfg = Release|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|Any CPU.Build.0 = Release|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|x86.ActiveCfg = Release|Any CPU + {663EFCB5-9E3E-4C76-97EE-3188E072634C}.Release|x86.Build.0 = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|.NET.ActiveCfg = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|.NET.Build.0 = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|x86.ActiveCfg = Debug|Any CPU + {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Debug|x86.Build.0 = Debug|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|.NET.ActiveCfg = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|.NET.Build.0 = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|Any CPU.Build.0 = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|x86.ActiveCfg = Release|Any CPU + {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298}.Release|x86.Build.0 = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|.NET.ActiveCfg = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|.NET.Build.0 = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|x86.ActiveCfg = Debug|Any CPU + {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Debug|x86.Build.0 = Debug|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|.NET.ActiveCfg = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|.NET.Build.0 = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|Any CPU.Build.0 = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|x86.ActiveCfg = Release|Any CPU + {E3BA193A-A64F-4CE6-91BE-F54E551797BE}.Release|x86.Build.0 = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|.NET.ActiveCfg = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|.NET.Build.0 = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|x86.ActiveCfg = Debug|Any CPU + {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Debug|x86.Build.0 = Debug|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|.NET.ActiveCfg = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|.NET.Build.0 = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|Any CPU.Build.0 = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|x86.ActiveCfg = Release|Any CPU + {18019E8C-C6DA-4B1B-9C2B-908BC14911AB}.Release|x86.Build.0 = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|.NET.ActiveCfg = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|.NET.Build.0 = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|Any CPU.Build.0 = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|x86.ActiveCfg = Debug|Any CPU + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Debug|x86.Build.0 = Debug|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|.NET.ActiveCfg = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|.NET.Build.0 = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Any CPU.ActiveCfg = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Any CPU.Build.0 = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|x86.ActiveCfg = Release|Any CPU + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|x86.Build.0 = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|.NET.ActiveCfg = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|.NET.Build.0 = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Any CPU.Build.0 = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|x86.ActiveCfg = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|x86.Build.0 = Debug|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|.NET.ActiveCfg = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|.NET.Build.0 = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Any CPU.ActiveCfg = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Any CPU.Build.0 = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|.NET.ActiveCfg = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|.NET.Build.0 = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|.NET.ActiveCfg = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|.NET.Build.0 = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Any CPU.Build.0 = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|x86.ActiveCfg = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|x86.Build.0 = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|.NET.ActiveCfg = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|.NET.Build.0 = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|x86.ActiveCfg = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Debug|x86.Build.0 = Debug|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|.NET.ActiveCfg = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|.NET.Build.0 = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|Any CPU.Build.0 = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|x86.ActiveCfg = Release|Any CPU + {D842A26A-C425-4E28-9A5E-A9993F949862}.Release|x86.Build.0 = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|.NET.ActiveCfg = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|.NET.Build.0 = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|x86.ActiveCfg = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Debug|x86.Build.0 = Debug|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|.NET.ActiveCfg = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|.NET.Build.0 = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|Any CPU.Build.0 = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|x86.ActiveCfg = Release|Any CPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BeWoTest/BeWoTest.csproj b/BeWoTest/BeWoTest.csproj index 468cac3c2..f26a65249 100644 --- a/BeWoTest/BeWoTest.csproj +++ b/BeWoTest/BeWoTest.csproj @@ -15,7 +15,7 @@ true - AnyCPU + x86 true full false @@ -94,6 +94,10 @@ + + {094331c3-ecee-4c89-bbfd-4c9ded89f0ef} + Service + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F} SharedLauncher diff --git a/Service/Security/SecurityContextInitializer.cs b/Service/Security/SecurityContextInitializer.cs index 7f0a8b709..3d6182154 100644 --- a/Service/Security/SecurityContextInitializer.cs +++ b/Service/Security/SecurityContextInitializer.cs @@ -37,7 +37,7 @@ namespace BeWo.Service.Security string lServiceInterface = lTemp[lTemp.Count - 2]; // TODO Hier kann man jetzt etwas bauen wer sich für welchen service autorisieren muss... - var skip = new string[] { "Download", "Download2", "DownloadInfo" }; + var skip = new string[] { "Download", "Download2", "DownloadInfo", "GetUpdatePlan", "GetUpdateFile" }; if (lMethodName == "IsUserValid" || lMethodName == "IsUserValidTwoFactor" || lMethodName == "ResetTenant" || lMethodName == "ResetAllTenant" || lMethodName == "GetEmailForUserName") { return null; diff --git a/Service/Service.csproj b/Service/Service.csproj index 234e2a7a3..507bcab94 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -483,8 +483,9 @@ - - + + + diff --git a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs index 19a9f8bc3..b331257a9 100644 --- a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs +++ b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs @@ -39,13 +39,11 @@ namespace BeWo.Service.ServiceImplementations { try { - if (!isUpdatePlanRequestValid(request)) - throw new InvalidUpdatePlanRequestException(); - - if (!VerifyLogin(request)) - throw new InvalidUpdatePlanRequestException("Login konnte nicht aufm Download Server verifiziert werden."); - - var response = UpdatePlanResponseBuilder.GetUpdatePlanResponse(request, Tenant); + var exception = UpdateRequestValidator.IsUpdatePlanRequestValid(request, Tenant); + if (exception is object) + throw new InvalidUpdatePlanRequestException(exception); + + var response = UpdatePlanResponseHelper.GetUpdatePlanResponse(request, Tenant); return response; } @@ -63,10 +61,11 @@ namespace BeWo.Service.ServiceImplementations { try { - if (!isUpdateFileRequestValid(request)) - throw new InvalidUpdateFileRequestException(); + var exception = UpdateRequestValidator.IsUpdateFileRequestValid(request, Tenant); + if (exception is object) + throw new InvalidUpdateFileRequestException(exception); - var response = UpdateFileResponseBuilder.GetUpdateFileResponse(request, Tenant); + var response = UpdateFileResponseHelper.GetUpdateFileResponse(request, Tenant); return response; } @@ -79,35 +78,5 @@ namespace BeWo.Service.ServiceImplementations throw new UpdateException("Update - GetUpdateFile - Exception", ex); } } - - private bool VerifyLogin(UpdatePlanRequest request) - { - SessionInformation.Login.Username = request.Login.Username; - SessionInformation.Login.Password = request.Login.Password; - SessionInformation.Login.Tenant = Tenant; - - ServiceFacade.UpdateServerAddresses(request.Login.CoreServerAddress); - - var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(request.Login.TempUsername, request.Login.Password, request.Login.Pin, request.Login.ClientID, true)); - - if (result == UserValidationResult.UserValid) - return true; - - return false; - } - - private bool isUpdatePlanRequestValid(UpdatePlanRequest request) - { - return true; - } - - private bool isUpdateFileRequestValid(UpdateFileRequest request) - { - // Check for Login - // Check for Correct Version - // Check for File Permissions - - return true; - } } } \ No newline at end of file diff --git a/Service/ServiceUtils/Paths/ServerFilePaths.cs b/Service/ServiceUtils/Paths/ServerFilePaths.cs index eeafffc6b..89b2d1cac 100644 --- a/Service/ServiceUtils/Paths/ServerFilePaths.cs +++ b/Service/ServiceUtils/Paths/ServerFilePaths.cs @@ -1,4 +1,6 @@ -using System; +using BS.SharedLauncher.Enums; +using BS.SharedLauncher.Exceptions; +using System; using System.Collections.Generic; using System.Configuration; using System.IO; @@ -30,9 +32,9 @@ namespace BeWo.Service.ServiceUtils.Paths private static string _DownloadVersionFilePath; private static string _DownloadFolderPath; private static string _LogFolderPath; - + public static string DownloadVersionFilePath => GetAppSettings(_DownloadVersionFilePath, "DownloadVersionFilePath"); - public static string DownloadFolderPath => GetAppSettings(_DownloadFolderPath, "DownloadFolderPath"); + public static string DownloadFolderPath => GetAppSettings(_DownloadFolderPath, "DownloadFolderPath") ?? @"D:\Rene\ServerBeWoDataExample2\"; public static string LogFolderPath => GetAppSettings(_LogFolderPath, "LogFolderPath"); static ServerFilePaths() @@ -59,5 +61,34 @@ namespace BeWo.Service.ServiceUtils.Paths return name; } + + public static string GetSourceFolderPath(UpdateFileSource source, string version, string tenant) + { + switch (source) + { + case BS.SharedLauncher.Enums.UpdateFileSource.Invalid: + throw new UpdateException("Invalid UpdateFileSource"); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionDefault: + return GetVersionDefaultFolderPath(version); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionTenant: + return GetVersionTenantFolderPath(version, tenant); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionUser: + break; + + case BS.SharedLauncher.Enums.UpdateFileSource.OverrideTenant: + return GetOverrideTenantFolderPath(tenant); + + case BS.SharedLauncher.Enums.UpdateFileSource.OverrideUser: + break; + default: + break; + } + + // User bekommt eigene Daten Feature + throw new NotImplementedException("#479839129"); + } } } diff --git a/Service/ServiceUtils/Update/UpdateConfigReader.cs b/Service/ServiceUtils/Update/UpdateConfigReader.cs index 70d887fb5..77523154a 100644 --- a/Service/ServiceUtils/Update/UpdateConfigReader.cs +++ b/Service/ServiceUtils/Update/UpdateConfigReader.cs @@ -1,4 +1,5 @@ -using BS.SharedLauncher.Enums; +using BeWo.Service.ServiceUtils.Paths; +using BS.SharedLauncher.Enums; using System; using System.Collections.Generic; using System.Linq; @@ -8,12 +9,34 @@ using System.Xml; namespace BeWo.Service.ServiceUtils.Update { - public class UpdateConfigReader + public static class UpdateConfigReader + { + public static Tuple GetDefaultTenantVersion(string tenant) + { + var reader = new UpdateConfigReaderClient(ServerFilePaths.GetVersionConfigFilePath(), tenant); + + return new Tuple(reader.GetDefaultVersion(), reader.GetSpecificVersion()); + } + + public static string GetValidVersion(string tenant) + { + var tuple = GetDefaultTenantVersion(tenant); + + return GetValidVersion(tuple.Item1, tuple.Item2); + } + + public static string GetValidVersion(string default_version, string tenant_version) + { + return tenant_version ?? default_version; + } + } + + internal class UpdateConfigReaderClient { private XmlDocument Document{ get; set; } private string Tenant { get; set; } - public UpdateConfigReader(string configFilePath, string tenant) + internal UpdateConfigReaderClient(string configFilePath, string tenant) { Document = new XmlDocument(); Document.Load(configFilePath); diff --git a/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs b/Service/ServiceUtils/Update/UpdateFileResponseHelper.cs similarity index 59% rename from Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs rename to Service/ServiceUtils/Update/UpdateFileResponseHelper.cs index 680e3bc07..20ecead91 100644 --- a/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs +++ b/Service/ServiceUtils/Update/UpdateFileResponseHelper.cs @@ -1,5 +1,6 @@ using BeWo.Service.ServiceUtils.Paths; using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Enums; using BS.SharedLauncher.Exceptions; using BS.SharedLauncher.Extensions; using BS.SharedLauncher.Logic; @@ -13,7 +14,7 @@ using System.Threading.Tasks; namespace BeWo.Service.ServiceUtils.Update { - public static class UpdateFileResponseBuilder + public static class UpdateFileResponseHelper { private static string _Version; private static string _Tenant; @@ -35,39 +36,10 @@ namespace BeWo.Service.ServiceUtils.Update private static void calculate() { - var path = Path.Combine(getSourceFolderPath(), _Request.UpdateFile.RelativePath); - - _Response.FileData = File.ReadAllBytes(path); + _Response.FileData = File.ReadAllBytes(_Request.UpdateFile.AbsolutePath); } - private static string getSourceFolderPath() - { - switch (_Request.UpdateFile.Source) - { - case BS.SharedLauncher.Enums.UpdateFileSource.Invalid: - throw new UpdateException("Invalid UpdateFileSource"); - - case BS.SharedLauncher.Enums.UpdateFileSource.VersionDefault: - return ServerFilePaths.GetVersionDefaultFolderPath(_Version); - - case BS.SharedLauncher.Enums.UpdateFileSource.VersionTenant: - return ServerFilePaths.GetVersionTenantFolderPath(_Version, _Tenant); - - case BS.SharedLauncher.Enums.UpdateFileSource.VersionUser: - break; - - case BS.SharedLauncher.Enums.UpdateFileSource.OverrideTenant: - return ServerFilePaths.GetOverrideTenantFolderPath(_Tenant); - - case BS.SharedLauncher.Enums.UpdateFileSource.OverrideUser: - break; - default: - break; - } - - // User bekommt eigene Daten Feature - throw new NotImplementedException("#479839129"); - } + //public static UpdateResponse GetUpdatePlanResponse(UpdateRequest request, string tenant) //{ diff --git a/Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs b/Service/ServiceUtils/Update/UpdatePlanResponseHelper.cs similarity index 93% rename from Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs rename to Service/ServiceUtils/Update/UpdatePlanResponseHelper.cs index 4abd1edd6..37f34332e 100644 --- a/Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs +++ b/Service/ServiceUtils/Update/UpdatePlanResponseHelper.cs @@ -15,17 +15,18 @@ using System.Threading.Tasks; namespace BeWo.Service.ServiceUtils.Update { - public static class UpdatePlanResponseBuilder + public static class UpdatePlanResponseHelper { private static UpdatePlanRequest _Request; private static UpdatePlanResponse _Response; private static string _Version; private static string _Tenant; - + public static UpdatePlanResponse GetUpdatePlanResponse(UpdatePlanRequest request, string tenant) { - var reader = new UpdateConfigReader(ServerFilePaths.GetVersionConfigFilePath(), tenant); + var (default_version, tenant_version) = UpdateConfigReader.GetDefaultTenantVersion(tenant); + _Version = UpdateConfigReader.GetValidVersion(default_version, tenant_version); _Tenant = tenant; _Request = request; @@ -33,13 +34,11 @@ namespace BeWo.Service.ServiceUtils.Update { CurrentPackage = new UpdatePlanDC { - DefaultVersion = reader.GetDefaultVersion(), - TenantVersion = reader.GetSpecificVersion() + DefaultVersion = default_version, + TenantVersion = tenant_version } }; - _Version = _Response.CurrentPackage.Version; - // Lädt komplettes Paket ohne Hash CalcFullPackage(); diff --git a/Service/ServiceUtils/Update/UpdateRequestValidator.cs b/Service/ServiceUtils/Update/UpdateRequestValidator.cs new file mode 100644 index 000000000..be9286c28 --- /dev/null +++ b/Service/ServiceUtils/Update/UpdateRequestValidator.cs @@ -0,0 +1,124 @@ +using BeWo.Data; +using BeWo.Service.ServiceProxy; +using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Enums; +using BS.SharedLauncher.Information; +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Text.RegularExpressions; +using BeWo.Service.ServiceUtils.Paths; + +namespace BeWo.Service.ServiceUtils.Update +{ + public static class UpdateRequestValidator + { + /// + /// + /// + /// + /// Exception string, otherwise null + public static string IsUpdatePlanRequestValid(UpdatePlanRequest request, string tenant) + { + if (!VerifySession(request.Session, tenant)) + return "Session konnte nicht verifiziert werden."; + + return null; + } + + public static string IsUpdateFileRequestValid(UpdateFileRequest request, string tenant) + { + // Check for Login ? + // Check for File Permissions ? + + if (!VerifyVersion(request, tenant)) + return $"Version konnte nicht bestätigt werden. Angefragte Version:{request.Version}"; + + if (!VerifySource(request)) + return $"Datei Herkunft konnte nicht bestätigt werden. File:{request.UpdateFile.RelativePath}, Source:{request.UpdateFile.Source}"; + + if (!ValidPath(request.UpdateFile, request.Version, tenant)) + return $"Datei Pfad konnte nicht bestätigt werden. Path:{request.UpdateFile.RelativePath}"; + + return null; + } + + private static bool VerifySession(SessionDC session, string tenant) + { + SessionInformation.Login.Username = session.Username; + SessionInformation.Login.Password = session.Password; + SessionInformation.Login.Tenant = tenant; + + ServiceFacade.UpdateServerAddresses(session.CoreServerAddress); + + var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(session.TempUsername, session.Password, session.Pin, session.ClientID, true)); + + if (result == UserValidationResult.UserValid) + return true; + + return false; + } + + private static bool VerifyVersion(UpdateFileRequest request, string tenant) + { + var version_config = UpdateConfigReader.GetValidVersion(tenant); + + return request.Version == version_config; + } + + private static bool VerifySource(UpdateFileRequest request) + { + switch (request.UpdateFile.Source) + { + case UpdateFileSource.Invalid: + return false; + case UpdateFileSource.VersionDefault: + break; + case UpdateFileSource.VersionTenant: + break; + case UpdateFileSource.VersionUser: + return false; + case UpdateFileSource.OverrideTenant: + break; + case UpdateFileSource.OverrideUser: + return false; + default: + return false; + } + + return true; + } + + + + public static bool ValidPath(UpdateFileDC fileDC, string version, string tenant) + { + var source_folder = ServerFilePaths.GetSourceFolderPath(fileDC.Source, version, tenant); + var requested_path = Path.Combine(source_folder, fileDC.RelativePath); + + Regex regex = new Regex(@"([a-zA-Z0-9\s_\\.\-:])+(.dat)$"); + Match match = regex.Match(requested_path); + + if (match.Success) + { + if (File.Exists(requested_path) && Path.GetFullPath(requested_path).StartsWith(source_folder, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + else + { + // "File not found"; + return false; + } + } + else + { + // "File name not valid" + return false; + } + } + } +} diff --git a/SharedLauncher/DataContract/LoginDC.cs b/SharedLauncher/DataContract/LoginDC.cs index 369f5d68f..a1f6e5821 100644 --- a/SharedLauncher/DataContract/LoginDC.cs +++ b/SharedLauncher/DataContract/LoginDC.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace BS.SharedLauncher.DataContract { [DataContract] - public class LoginDC + public class SessionDC { [DataMember] public string Username { get; set; } diff --git a/SharedLauncher/DataContract/UpdatePlanRequest.cs b/SharedLauncher/DataContract/UpdatePlanRequest.cs index 9da9b5d55..fadd6a8fc 100644 --- a/SharedLauncher/DataContract/UpdatePlanRequest.cs +++ b/SharedLauncher/DataContract/UpdatePlanRequest.cs @@ -43,6 +43,6 @@ namespace BS.SharedLauncher.DataContract public UpdatePlanDC ApplyPackage { get; set; } [DataMember] - public LoginDC Login { get; set; } + public SessionDC Session { get; set; } } } diff --git a/SharedLauncher/Exceptions/UpdateException.cs b/SharedLauncher/Exceptions/UpdateException.cs index ef2bcc575..c8545fbb9 100644 --- a/SharedLauncher/Exceptions/UpdateException.cs +++ b/SharedLauncher/Exceptions/UpdateException.cs @@ -19,6 +19,5 @@ namespace BS.SharedLauncher.Exceptions public UpdateException(string message, Exception innerException) : base(message, innerException) { } - -} + } } diff --git a/SharedLauncher/Extensions/PathExtensions.cs b/SharedLauncher/Extensions/PathExtensions.cs index 144ead075..43951636b 100644 --- a/SharedLauncher/Extensions/PathExtensions.cs +++ b/SharedLauncher/Extensions/PathExtensions.cs @@ -72,11 +72,11 @@ namespace BS.SharedLauncher.Extensions using (File.Create(file)); } - public static void Unlock(this string path) + public static void Unlock(this string path, bool skiplock) { var file = Path.Combine(path, BeWoPathFileConfig.LockFileName); - if (!File.Exists(file)) + if (!skiplock && !File.Exists(file)) throw new ArgumentException($"Unlock nicht möglich, Lock existiert nicht", path); File.Delete(file); diff --git a/SharedLauncher/Logic/FileController.cs b/SharedLauncher/Logic/FileController.cs index 3f7a8a5bf..b26e3bdba 100644 --- a/SharedLauncher/Logic/FileController.cs +++ b/SharedLauncher/Logic/FileController.cs @@ -29,10 +29,14 @@ namespace BS.SharedLauncher.Logic if (package == null) package = new UpdatePlanDC(); - package.Files = GetPlanerFiles(applyFolder, true, null); + package.Files = GetAppliedFiles(applyFolder, true); return package; } + public static List GetAppliedFiles(string applyFolder, bool hash) + { + return GetPlanerFiles(applyFolder, hash, null); + } public static UpdatePlanDC LoadPackageInfo(string filepath) { filepath = filepath.WithInfoExtension(); diff --git a/UnitTestProject45/Properties/AssemblyInfo.cs b/UnitTestProject45/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..b2f56afae --- /dev/null +++ b/UnitTestProject45/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject45")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject45")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("d842a26a-c425-4e28-9a5e-a9993f949862")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTests/SharedLauncherTests.cs b/UnitTestProject45/UnitTest1.cs similarity index 89% rename from UnitTests/SharedLauncherTests.cs rename to UnitTestProject45/UnitTest1.cs index d7c39fe2e..f868fdd9b 100644 --- a/UnitTests/SharedLauncherTests.cs +++ b/UnitTestProject45/UnitTest1.cs @@ -1,10 +1,11 @@ +using System; using BS.SharedLauncher.Information; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests +namespace UnitTestProject45 { [TestClass] - public class SharedLauncherTests + public class UnitTest1 { [TestMethod] public void TestLoginLength() diff --git a/UnitTestProject45/UnitTestProject45.csproj b/UnitTestProject45/UnitTestProject45.csproj new file mode 100644 index 000000000..cf7c9a8b4 --- /dev/null +++ b/UnitTestProject45/UnitTestProject45.csproj @@ -0,0 +1,74 @@ + + + + + + Debug + AnyCPU + {D842A26A-C425-4E28-9A5E-A9993F949862} + Library + Properties + UnitTestProject45 + UnitTestProject45 + v4.5 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F} + SharedLauncher + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/UnitTestProject45/packages.config b/UnitTestProject45/packages.config new file mode 100644 index 000000000..d2da0eb1d --- /dev/null +++ b/UnitTestProject45/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/UnitTestProject472/Properties/AssemblyInfo.cs b/UnitTestProject472/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..467de23df --- /dev/null +++ b/UnitTestProject472/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject472")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject472")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("9fdc0675-73d8-4c3b-aa14-425280ad8f58")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTestProject472/UnitTest1.cs b/UnitTestProject472/UnitTest1.cs new file mode 100644 index 000000000..bf988e4d9 --- /dev/null +++ b/UnitTestProject472/UnitTest1.cs @@ -0,0 +1,62 @@ +using System; +using BeWo.Data; +using BeWo.Service.ServiceImplementations; +using BeWo.Service.ServiceUtils.Update; +using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UnitTestProject472 +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void DotDotShlashAttack1() + { + var tenant = "demo"; + + var file = new UpdateFileDC() + { + RelativePath = "../../../secure.txt", + Name = "secure.txt", + Source = BS.SharedLauncher.Enums.UpdateFileSource.VersionDefault, + AbsolutePath = "D:/Rene/ServerBeWoDataExample2/secure.txt" + }; + var request = new UpdateFileRequest() + { + UpdateFile = file, + Version = "1" + }; + file.LoadHash(); + + var res = UpdateFileResponseHelper.GetUpdateFileResponse(request, tenant); + + Assert.IsNotNull(res); + } + + [TestMethod] + public void DotDotShlashDefense1() + { + var tenant = "demo"; + + var file = new UpdateFileDC() + { + RelativePath = "../../../secure.txt", + Name = "secure.txt", + Source = BS.SharedLauncher.Enums.UpdateFileSource.VersionDefault, + AbsolutePath = "D:/Rene/ServerBeWoDataExample2/secure.txt" + }; + var request = new UpdateFileRequest() + { + UpdateFile = file, + Version = "1" + }; + file.LoadHash(); + + var validation = UpdateRequestValidator.ValidPath(request.UpdateFile, request.Version, tenant); + + Assert.IsFalse(validation); + } + } +} diff --git a/UnitTestProject472/UnitTestProject472.csproj b/UnitTestProject472/UnitTestProject472.csproj new file mode 100644 index 000000000..3e5262919 --- /dev/null +++ b/UnitTestProject472/UnitTestProject472.csproj @@ -0,0 +1,82 @@ + + + + + + Debug + AnyCPU + {9FDC0675-73D8-4C3B-AA14-425280AD8F58} + Library + Properties + UnitTestProject472 + UnitTestProject472 + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE} + Data + + + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF} + Service + + + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F} + SharedLauncher + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/UnitTestProject472/packages.config b/UnitTestProject472/packages.config new file mode 100644 index 000000000..2f7c5a189 --- /dev/null +++ b/UnitTestProject472/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj deleted file mode 100644 index aa0327a5d..000000000 --- a/UnitTests/UnitTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.1 - - false - - - - - - - - - - - - -