From 1625e7fa2b3fedf0a7dc8c8d6e5ddd5e761d905e Mon Sep 17 00:00:00 2001 From: dbuechel Date: Thu, 7 Mar 2019 08:34:47 +0100 Subject: [PATCH] SEBWIN-226: Added mapping for kiosk mode configuration. --- .../ConfigurationData/DataMapper.Security.cs | 37 +++++++++++++++++++ .../ConfigurationData/DataMapper.cs | 1 + .../ConfigurationData/Keys.cs | 2 + .../SafeExamBrowser.Configuration.csproj | 3 ++ 4 files changed, 43 insertions(+) create mode 100644 SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs new file mode 100644 index 00000000..141de63c --- /dev/null +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +using System.Collections.Generic; +using SafeExamBrowser.Contracts.Configuration.Settings; + +namespace SafeExamBrowser.Configuration.ConfigurationData +{ + internal partial class DataMapper + { + private void MapKioskMode(IDictionary rawData, Settings settings) + { + var hasCreateNewDesktop = rawData.TryGetValue(Keys.Security.KioskModeCreateNewDesktop, out var createNewDesktop); + var hasDisableExplorerShell = rawData.TryGetValue(Keys.Security.KioskModeCreateNewDesktop, out var disableExplorerShell); + + if (hasDisableExplorerShell && disableExplorerShell as bool? == true) + { + settings.KioskMode = KioskMode.DisableExplorerShell; + } + + if (hasCreateNewDesktop && createNewDesktop as bool? == true) + { + settings.KioskMode = KioskMode.CreateNewDesktop; + } + + if (hasCreateNewDesktop && hasDisableExplorerShell && createNewDesktop as bool? == false && disableExplorerShell as bool? == false) + { + settings.KioskMode = KioskMode.None; + } + } + } +} diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs index de77d027..4a2f63ae 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs @@ -20,6 +20,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData Map(item.Key, item.Value, settings); } + MapKioskMode(rawData, settings); MapUserAgentMode(rawData, settings); } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index bad4d2ea..692c4e86 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -102,6 +102,8 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal static class Security { + internal const string KioskModeCreateNewDesktop = "createNewDesktop"; + internal const string KioskModeDisableExplorerShell = "killExplorerShell"; } internal static class UserInterface diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj index 638e8666..0e58f7ae 100644 --- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj +++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj @@ -84,6 +84,9 @@ DataMapper.cs + + DataMapper.cs +