Refactored configuration data mapping.
This commit is contained in:
parent
130dd45ff6
commit
955ae3545e
13 changed files with 374 additions and 340 deletions
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 SafeExamBrowser.Settings;
|
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
|
||||||
{
|
|
||||||
internal partial class DataMapper
|
|
||||||
{
|
|
||||||
private void MapConfigurationMode(AppSettings settings, object value)
|
|
||||||
{
|
|
||||||
const int CONFIGURE_CLIENT = 1;
|
|
||||||
|
|
||||||
if (value is int mode)
|
|
||||||
{
|
|
||||||
settings.ConfigurationMode = mode == CONFIGURE_CLIENT ? ConfigurationMode.ConfigureClient : ConfigurationMode.Exam;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,277 +7,38 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using SafeExamBrowser.Configuration.ConfigurationData.DataMapping;
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal partial class DataMapper
|
||||||
{
|
{
|
||||||
|
private BaseDataMapper[] mappers =
|
||||||
|
{
|
||||||
|
new ApplicationDataMapper(),
|
||||||
|
new AudioDataMapper(),
|
||||||
|
new BrowserDataMapper(),
|
||||||
|
new ConfigurationFileDataMapper(),
|
||||||
|
new GeneralDataMapper(),
|
||||||
|
new InputDataMapper(),
|
||||||
|
new SecurityDataMapper(),
|
||||||
|
new UserInterfaceDataMapper()
|
||||||
|
};
|
||||||
|
|
||||||
internal void MapRawDataToSettings(IDictionary<string, object> rawData, AppSettings settings)
|
internal void MapRawDataToSettings(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
foreach (var item in rawData)
|
foreach (var item in rawData)
|
||||||
{
|
{
|
||||||
MapApplicationSettings(item.Key, item.Value, settings);
|
foreach (var mapper in mappers)
|
||||||
MapAudioSettings(item.Key, item.Value, settings);
|
{
|
||||||
MapBrowserSettings(item.Key, item.Value, settings);
|
mapper.Map(item.Key, item.Value, settings);
|
||||||
MapConfigurationFileSettings(item.Key, item.Value, settings);
|
}
|
||||||
MapGeneralSettings(item.Key, item.Value, settings);
|
|
||||||
MapKeyboardSettings(item.Key, item.Value, settings);
|
|
||||||
MapMouseSettings(item.Key, item.Value, settings);
|
|
||||||
MapSecuritySettings(item.Key, item.Value, settings);
|
|
||||||
MapUserInterfaceSettings(item.Key, item.Value, settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapApplicationLogAccess(rawData, settings);
|
foreach (var mapper in mappers)
|
||||||
MapKioskMode(rawData, settings);
|
|
||||||
MapPopupPolicy(rawData, settings);
|
|
||||||
MapRequestFilter(rawData, settings);
|
|
||||||
MapUserAgentMode(rawData, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapApplicationSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
{
|
||||||
case Keys.Applications.Blacklist:
|
mapper.MapGlobal(rawData, settings);
|
||||||
MapApplicationBlacklist(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Applications.Whitelist:
|
|
||||||
MapApplicationWhitelist(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapAudioSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.Audio.InitialVolumeLevel:
|
|
||||||
MapInitialVolumeLevel(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Audio.MuteAudio:
|
|
||||||
MapMuteAudio(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Audio.SetInitialVolumeLevel:
|
|
||||||
MapSetInitialVolumeLevel(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapBrowserSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.Browser.AllowConfigurationDownloads:
|
|
||||||
MapAllowConfigurationDownloads(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AllowDeveloperConsole:
|
|
||||||
MapAllowDeveloperConsole(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AllowDownloads:
|
|
||||||
MapAllowDownloads(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AllowPageZoom:
|
|
||||||
MapAllowPageZoom(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.AllowAddressBar:
|
|
||||||
MapAllowAddressBarAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.AllowNavigation:
|
|
||||||
MapAllowNavigationAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.AllowReload:
|
|
||||||
MapAllowReloadAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.ShowReloadWarning:
|
|
||||||
MapShowReloadWarningAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.WindowHeight:
|
|
||||||
MapWindowHeightAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.WindowPosition:
|
|
||||||
MapWindowPositionAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.AdditionalWindow.WindowWidth:
|
|
||||||
MapWindowWidthAdditionalWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.Filter.FilterRules:
|
|
||||||
MapFilterRules(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.AllowAddressBar:
|
|
||||||
MapAllowAddressBar(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.AllowNavigation:
|
|
||||||
MapAllowNavigation(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.AllowReload:
|
|
||||||
MapAllowReload(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.ShowReloadWarning:
|
|
||||||
MapShowReloadWarning(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.WindowHeight:
|
|
||||||
MapWindowHeightMainWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.WindowMode:
|
|
||||||
MapMainWindowMode(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.WindowPosition:
|
|
||||||
MapWindowPositionMainWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.MainWindow.WindowWidth:
|
|
||||||
MapWindowWidthMainWindow(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.Proxy.Policy:
|
|
||||||
MapProxyPolicy(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.Proxy.Settings:
|
|
||||||
MapProxySettings(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.QuitUrl:
|
|
||||||
MapQuitUrl(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.QuitUrlConfirmation:
|
|
||||||
MapQuitUrlConfirmation(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Browser.StartUrl:
|
|
||||||
MapStartUrl(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapConfigurationFileSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.ConfigurationFile.AdminPasswordHash:
|
|
||||||
MapAdminPasswordHash(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.ConfigurationFile.ConfigurationPurpose:
|
|
||||||
MapConfigurationMode(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapGeneralSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.General.LogLevel:
|
|
||||||
MapLogLevel(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapKeyboardSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.Keyboard.EnableAltEsc:
|
|
||||||
MapEnableAltEsc(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableAltF4:
|
|
||||||
MapEnableAltF4(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableAltTab:
|
|
||||||
MapEnableAltTab(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableCtrlEsc:
|
|
||||||
MapEnableCtrlEsc(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableEsc:
|
|
||||||
MapEnableEsc(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF1:
|
|
||||||
MapEnableF1(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF2:
|
|
||||||
MapEnableF2(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF3:
|
|
||||||
MapEnableF3(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF4:
|
|
||||||
MapEnableF4(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF5:
|
|
||||||
MapEnableF5(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF6:
|
|
||||||
MapEnableF6(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF7:
|
|
||||||
MapEnableF7(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF8:
|
|
||||||
MapEnableF8(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF9:
|
|
||||||
MapEnableF9(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF10:
|
|
||||||
MapEnableF10(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF11:
|
|
||||||
MapEnableF11(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableF12:
|
|
||||||
MapEnableF12(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnablePrintScreen:
|
|
||||||
MapEnablePrintScreen(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Keyboard.EnableSystemKey:
|
|
||||||
MapEnableSystemKey(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapMouseSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.Mouse.EnableRightMouse:
|
|
||||||
MapEnableRightMouse(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapSecuritySettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.Security.QuitPasswordHash:
|
|
||||||
MapQuitPasswordHash(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.Security.ServicePolicy:
|
|
||||||
MapServicePolicy(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapUserInterfaceSettings(string key, object value, AppSettings settings)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case Keys.UserInterface.ShowAudio:
|
|
||||||
MapAudio(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.UserInterface.ShowKeyboardLayout:
|
|
||||||
MapKeyboardLayout(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.UserInterface.ShowWirelessNetwork:
|
|
||||||
MapWirelessNetwork(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.UserInterface.ShowClock:
|
|
||||||
MapClock(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.UserInterface.UserInterfaceMode:
|
|
||||||
MapUserInterfaceMode(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.UserInterface.Taskbar.ShowApplicationLog:
|
|
||||||
MapApplicationLogButton(settings, value);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,23 @@ using System.Collections.Generic;
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
using SafeExamBrowser.Settings.Applications;
|
using SafeExamBrowser.Settings.Applications;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class ApplicationDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.Applications.Blacklist:
|
||||||
|
MapApplicationBlacklist(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Applications.Whitelist:
|
||||||
|
MapApplicationWhitelist(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapApplicationBlacklist(AppSettings settings, object value)
|
private void MapApplicationBlacklist(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is IList<object> applications)
|
if (value is IList<object> applications)
|
|
@ -8,10 +8,26 @@
|
||||||
|
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class AudioDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.Audio.InitialVolumeLevel:
|
||||||
|
MapInitialVolumeLevel(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Audio.MuteAudio:
|
||||||
|
MapMuteAudio(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Audio.SetInitialVolumeLevel:
|
||||||
|
MapSetInitialVolumeLevel(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapInitialVolumeLevel(AppSettings settings, object value)
|
private void MapInitialVolumeLevel(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is int volume)
|
if (value is int volume)
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* 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.Settings;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
|
{
|
||||||
|
internal abstract class BaseDataMapper
|
||||||
|
{
|
||||||
|
internal abstract void Map(string key, object value, AppSettings settings);
|
||||||
|
internal virtual void MapGlobal(IDictionary<string, object> rawData, AppSettings settings) { }
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,10 +13,99 @@ using SafeExamBrowser.Settings.Browser.Filter;
|
||||||
using SafeExamBrowser.Settings.Browser.Proxy;
|
using SafeExamBrowser.Settings.Browser.Proxy;
|
||||||
using SafeExamBrowser.Settings.UserInterface;
|
using SafeExamBrowser.Settings.UserInterface;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class BrowserDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.Browser.AllowConfigurationDownloads:
|
||||||
|
MapAllowConfigurationDownloads(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AllowDeveloperConsole:
|
||||||
|
MapAllowDeveloperConsole(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AllowDownloads:
|
||||||
|
MapAllowDownloads(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AllowPageZoom:
|
||||||
|
MapAllowPageZoom(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.AllowAddressBar:
|
||||||
|
MapAllowAddressBarAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.AllowNavigation:
|
||||||
|
MapAllowNavigationAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.AllowReload:
|
||||||
|
MapAllowReloadAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.ShowReloadWarning:
|
||||||
|
MapShowReloadWarningAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.WindowHeight:
|
||||||
|
MapWindowHeightAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.WindowPosition:
|
||||||
|
MapWindowPositionAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.AdditionalWindow.WindowWidth:
|
||||||
|
MapWindowWidthAdditionalWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.Filter.FilterRules:
|
||||||
|
MapFilterRules(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.AllowAddressBar:
|
||||||
|
MapAllowAddressBar(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.AllowNavigation:
|
||||||
|
MapAllowNavigation(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.AllowReload:
|
||||||
|
MapAllowReload(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.ShowReloadWarning:
|
||||||
|
MapShowReloadWarning(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.WindowHeight:
|
||||||
|
MapWindowHeightMainWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.WindowMode:
|
||||||
|
MapMainWindowMode(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.WindowPosition:
|
||||||
|
MapWindowPositionMainWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.MainWindow.WindowWidth:
|
||||||
|
MapWindowWidthMainWindow(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.Proxy.Policy:
|
||||||
|
MapProxyPolicy(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.Proxy.Settings:
|
||||||
|
MapProxySettings(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.QuitUrl:
|
||||||
|
MapQuitUrl(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.QuitUrlConfirmation:
|
||||||
|
MapQuitUrlConfirmation(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Browser.StartUrl:
|
||||||
|
MapStartUrl(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void MapGlobal(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
|
{
|
||||||
|
MapPopupPolicy(rawData, settings);
|
||||||
|
MapRequestFilter(rawData, settings);
|
||||||
|
MapUserAgentMode(rawData, settings);
|
||||||
|
}
|
||||||
|
|
||||||
private void MapAllowAddressBar(AppSettings settings, object value)
|
private void MapAllowAddressBar(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool allow)
|
if (value is bool allow)
|
||||||
|
@ -174,6 +263,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapStartUrl(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is string url)
|
||||||
|
{
|
||||||
|
settings.Browser.StartUrl = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapUserAgentMode(IDictionary<string, object> rawData, AppSettings settings)
|
private void MapUserAgentMode(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
const int DEFAULT = 0;
|
const int DEFAULT = 0;
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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 SafeExamBrowser.Settings;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
|
{
|
||||||
|
internal class ConfigurationFileDataMapper : BaseDataMapper
|
||||||
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.ConfigurationFile.AdminPasswordHash:
|
||||||
|
MapAdminPasswordHash(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.ConfigurationFile.ConfigurationPurpose:
|
||||||
|
MapConfigurationMode(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MapAdminPasswordHash(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is string hash)
|
||||||
|
{
|
||||||
|
settings.AdminPasswordHash = hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MapConfigurationMode(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
const int CONFIGURE_CLIENT = 1;
|
||||||
|
|
||||||
|
if (value is int mode)
|
||||||
|
{
|
||||||
|
settings.ConfigurationMode = mode == CONFIGURE_CLIENT ? ConfigurationMode.ConfigureClient : ConfigurationMode.Exam;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,18 +10,25 @@ using System.Collections.Generic;
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
using SafeExamBrowser.Settings.Logging;
|
using SafeExamBrowser.Settings.Logging;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class GeneralDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
private void MapAdminPasswordHash(AppSettings settings, object value)
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
{
|
{
|
||||||
if (value is string hash)
|
switch (key)
|
||||||
{
|
{
|
||||||
settings.AdminPasswordHash = hash;
|
case Keys.General.LogLevel:
|
||||||
|
MapLogLevel(settings, value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override void MapGlobal(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
|
{
|
||||||
|
MapApplicationLogAccess(rawData, settings);
|
||||||
|
}
|
||||||
|
|
||||||
private void MapApplicationLogAccess(IDictionary<string, object> rawData, AppSettings settings)
|
private void MapApplicationLogAccess(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
var hasValue = rawData.TryGetValue(Keys.General.AllowApplicationLog, out var value);
|
var hasValue = rawData.TryGetValue(Keys.General.AllowApplicationLog, out var value);
|
||||||
|
@ -51,21 +58,5 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.LogLevel = level == ERROR ? LogLevel.Error : (level == WARNING ? LogLevel.Warning : (level == INFO ? LogLevel.Info : LogLevel.Debug));
|
settings.LogLevel = level == ERROR ? LogLevel.Error : (level == WARNING ? LogLevel.Warning : (level == INFO ? LogLevel.Info : LogLevel.Debug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapQuitPasswordHash(AppSettings settings, object value)
|
|
||||||
{
|
|
||||||
if (value is string hash)
|
|
||||||
{
|
|
||||||
settings.QuitPasswordHash = hash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapStartUrl(AppSettings settings, object value)
|
|
||||||
{
|
|
||||||
if (value is string url)
|
|
||||||
{
|
|
||||||
settings.Browser.StartUrl = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,10 +8,77 @@
|
||||||
|
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class InputDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.Keyboard.EnableAltEsc:
|
||||||
|
MapEnableAltEsc(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableAltF4:
|
||||||
|
MapEnableAltF4(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableAltTab:
|
||||||
|
MapEnableAltTab(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableCtrlEsc:
|
||||||
|
MapEnableCtrlEsc(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableEsc:
|
||||||
|
MapEnableEsc(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF1:
|
||||||
|
MapEnableF1(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF2:
|
||||||
|
MapEnableF2(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF3:
|
||||||
|
MapEnableF3(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF4:
|
||||||
|
MapEnableF4(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF5:
|
||||||
|
MapEnableF5(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF6:
|
||||||
|
MapEnableF6(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF7:
|
||||||
|
MapEnableF7(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF8:
|
||||||
|
MapEnableF8(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF9:
|
||||||
|
MapEnableF9(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF10:
|
||||||
|
MapEnableF10(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF11:
|
||||||
|
MapEnableF11(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableF12:
|
||||||
|
MapEnableF12(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnablePrintScreen:
|
||||||
|
MapEnablePrintScreen(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Keyboard.EnableSystemKey:
|
||||||
|
MapEnableSystemKey(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Mouse.EnableRightMouse:
|
||||||
|
MapEnableRightMouse(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapEnableAltEsc(AppSettings settings, object value)
|
private void MapEnableAltEsc(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool enabled)
|
if (value is bool enabled)
|
|
@ -10,10 +10,31 @@ using System.Collections.Generic;
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
using SafeExamBrowser.Settings.Service;
|
using SafeExamBrowser.Settings.Service;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class SecurityDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.Security.AllowVirtualMachine:
|
||||||
|
MapVirtualMachinePolicy(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Security.QuitPasswordHash:
|
||||||
|
MapQuitPasswordHash(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.Security.ServicePolicy:
|
||||||
|
MapServicePolicy(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void MapGlobal(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
|
{
|
||||||
|
MapKioskMode(rawData, settings);
|
||||||
|
}
|
||||||
|
|
||||||
private void MapKioskMode(IDictionary<string, object> rawData, AppSettings settings)
|
private void MapKioskMode(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
var hasCreateNewDesktop = rawData.TryGetValue(Keys.Security.KioskModeCreateNewDesktop, out var createNewDesktop);
|
var hasCreateNewDesktop = rawData.TryGetValue(Keys.Security.KioskModeCreateNewDesktop, out var createNewDesktop);
|
||||||
|
@ -35,6 +56,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapQuitPasswordHash(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is string hash)
|
||||||
|
{
|
||||||
|
settings.QuitPasswordHash = hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapServicePolicy(AppSettings settings, object value)
|
private void MapServicePolicy(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
const int WARN = 1;
|
const int WARN = 1;
|
||||||
|
@ -45,5 +74,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Service.Policy = policy == FORCE ? ServicePolicy.Mandatory : (policy == WARN ? ServicePolicy.Warn : ServicePolicy.Optional);
|
settings.Service.Policy = policy == FORCE ? ServicePolicy.Mandatory : (policy == WARN ? ServicePolicy.Warn : ServicePolicy.Optional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapVirtualMachinePolicy(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is bool allow)
|
||||||
|
{
|
||||||
|
// TODO NEXT: settings.Security.VirtualMachinePolicy = ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,10 +9,35 @@
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
using SafeExamBrowser.Settings.UserInterface;
|
using SafeExamBrowser.Settings.UserInterface;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
{
|
{
|
||||||
internal partial class DataMapper
|
internal class UserInterfaceDataMapper : BaseDataMapper
|
||||||
{
|
{
|
||||||
|
internal override void Map(string key, object value, AppSettings settings)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Keys.UserInterface.ShowAudio:
|
||||||
|
MapAudio(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.UserInterface.ShowKeyboardLayout:
|
||||||
|
MapKeyboardLayout(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.UserInterface.ShowWirelessNetwork:
|
||||||
|
MapWirelessNetwork(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.UserInterface.ShowClock:
|
||||||
|
MapClock(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.UserInterface.UserInterfaceMode:
|
||||||
|
MapUserInterfaceMode(settings, value);
|
||||||
|
break;
|
||||||
|
case Keys.UserInterface.Taskbar.ShowApplicationLog:
|
||||||
|
MapApplicationLogButton(settings, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapApplicationLogButton(AppSettings settings, object value)
|
private void MapApplicationLogButton(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool show)
|
if (value is bool show)
|
|
@ -193,6 +193,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
|
|
||||||
internal static class Security
|
internal static class Security
|
||||||
{
|
{
|
||||||
|
internal const string AllowVirtualMachine = "allowVirtualMachine";
|
||||||
internal const string KioskModeCreateNewDesktop = "createNewDesktop";
|
internal const string KioskModeCreateNewDesktop = "createNewDesktop";
|
||||||
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
|
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
|
||||||
internal const string QuitPasswordHash = "hashedQuitPassword";
|
internal const string QuitPasswordHash = "hashedQuitPassword";
|
||||||
|
|
|
@ -56,6 +56,15 @@
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\ApplicationDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\AudioDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\BrowserDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\ConfigurationFileDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\GeneralDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\BaseDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\InputDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\SecurityDataMapper.cs" />
|
||||||
|
<Compile Include="ConfigurationData\DataMapping\UserInterfaceDataMapper.cs" />
|
||||||
<Compile Include="ConfigurationData\Keys.cs" />
|
<Compile Include="ConfigurationData\Keys.cs" />
|
||||||
<Compile Include="ConfigurationData\DataValues.cs" />
|
<Compile Include="ConfigurationData\DataValues.cs" />
|
||||||
<Compile Include="Cryptography\CertificateStore.cs" />
|
<Compile Include="Cryptography\CertificateStore.cs" />
|
||||||
|
@ -67,30 +76,6 @@
|
||||||
<Compile Include="DataFormats\BinarySerializer.cs" />
|
<Compile Include="DataFormats\BinarySerializer.cs" />
|
||||||
<Compile Include="DataFormats\BinaryBlock.cs" />
|
<Compile Include="DataFormats\BinaryBlock.cs" />
|
||||||
<Compile Include="ConfigurationData\DataMapper.cs" />
|
<Compile Include="ConfigurationData\DataMapper.cs" />
|
||||||
<Compile Include="ConfigurationData\DataMapper.Applications.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.Audio.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.Browser.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.ConfigurationFile.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.General.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.Input.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.UserInterface.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="ConfigurationData\DataMapper.Security.cs">
|
|
||||||
<DependentUpon>DataMapper.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Cryptography\HashAlgorithm.cs" />
|
<Compile Include="Cryptography\HashAlgorithm.cs" />
|
||||||
<Compile Include="DataFormats\XmlElement.cs" />
|
<Compile Include="DataFormats\XmlElement.cs" />
|
||||||
<Compile Include="DataFormats\XmlParser.cs" />
|
<Compile Include="DataFormats\XmlParser.cs" />
|
||||||
|
@ -116,5 +101,6 @@
|
||||||
<Name>SafeExamBrowser.Settings</Name>
|
<Name>SafeExamBrowser.Settings</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue