Restore SEBPatch
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.Configuration.ConfigurationData.DataMapping;
|
||||
using SafeExamBrowser.Settings;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal class DataMapper
|
||||
{
|
||||
private readonly BaseDataMapper[] mappers =
|
||||
{
|
||||
new ApplicationDataMapper(),
|
||||
new AudioDataMapper(),
|
||||
new BrowserDataMapper(),
|
||||
new ConfigurationFileDataMapper(),
|
||||
new DisplayDataMapper(),
|
||||
new GeneralDataMapper(),
|
||||
new InputDataMapper(),
|
||||
new ProctoringDataMapper(),
|
||||
new SecurityDataMapper(),
|
||||
new ServerDataMapper(),
|
||||
new ServiceDataMapper(),
|
||||
new SystemDataMapper(),
|
||||
new UserInterfaceDataMapper()
|
||||
};
|
||||
|
||||
internal void Map(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
foreach (var item in rawData)
|
||||
{
|
||||
foreach (var mapper in mappers)
|
||||
{
|
||||
mapper.Map(item.Key, item.Value, settings);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mapper in mappers)
|
||||
{
|
||||
mapper.MapGlobal(rawData, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Applications;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (value is IList<object> applications)
|
||||
{
|
||||
foreach (var item in applications)
|
||||
{
|
||||
if (item is IDictionary<string, object> applicationData)
|
||||
{
|
||||
var isWindowsProcess = applicationData.TryGetValue(Keys.Applications.OperatingSystem, out var v) && v is int os && os == Keys.WINDOWS;
|
||||
|
||||
if (isWindowsProcess)
|
||||
{
|
||||
var application = new BlacklistApplication();
|
||||
var isActive = applicationData.TryGetValue(Keys.Applications.Active, out v) && v is bool active && active;
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.AutoTerminate, out v) && v is bool autoTerminate)
|
||||
{
|
||||
application.AutoTerminate = autoTerminate;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.ExecutableName, out v) && v is string executableName)
|
||||
{
|
||||
application.ExecutableName = executableName;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.OriginalName, out v) && v is string originalName)
|
||||
{
|
||||
application.OriginalName = originalName;
|
||||
}
|
||||
|
||||
var defaultEntry = settings.Applications.Blacklist.FirstOrDefault(a =>
|
||||
{
|
||||
return a.ExecutableName?.Equals(application.ExecutableName, StringComparison.OrdinalIgnoreCase) == true
|
||||
&& a.OriginalName?.Equals(application.OriginalName, StringComparison.OrdinalIgnoreCase) == true;
|
||||
});
|
||||
|
||||
if (defaultEntry != default(BlacklistApplication))
|
||||
{
|
||||
settings.Applications.Blacklist.Remove(defaultEntry);
|
||||
}
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
settings.Applications.Blacklist.Add(application);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MapApplicationWhitelist(AppSettings settings, object value)
|
||||
{
|
||||
if (value is IList<object> applications)
|
||||
{
|
||||
foreach (var item in applications)
|
||||
{
|
||||
if (item is IDictionary<string, object> applicationData)
|
||||
{
|
||||
var isActive = applicationData.TryGetValue(Keys.Applications.Active, out var v) && v is bool active && active;
|
||||
var isWindowsProcess = applicationData.TryGetValue(Keys.Applications.OperatingSystem, out v) && v is int os && os == Keys.WINDOWS;
|
||||
|
||||
if (isActive && isWindowsProcess)
|
||||
{
|
||||
var application = new WhitelistApplication();
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.AllowCustomPath, out v) && v is bool allowCustomPath)
|
||||
{
|
||||
application.AllowCustomPath = allowCustomPath;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.AllowRunning, out v) && v is bool allowRunning)
|
||||
{
|
||||
application.AllowRunning = allowRunning;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.Arguments, out v) && v is IList<object> arguments)
|
||||
{
|
||||
foreach (var argumentItem in arguments)
|
||||
{
|
||||
if (argumentItem is IDictionary<string, object> argumentData)
|
||||
{
|
||||
var argActive = argumentData.TryGetValue(Keys.Applications.Active, out v) && v is bool a && a;
|
||||
|
||||
if (argActive && argumentData.TryGetValue(Keys.Applications.Argument, out v) && v is string argument)
|
||||
{
|
||||
application.Arguments.Add(argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.AutoStart, out v) && v is bool autoStart)
|
||||
{
|
||||
application.AutoStart = autoStart;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.AutoTerminate, out v) && v is bool autoTerminate)
|
||||
{
|
||||
application.AutoTerminate = autoTerminate;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.Description, out v) && v is string description)
|
||||
{
|
||||
application.Description = description;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.DisplayName, out v) && v is string displayName)
|
||||
{
|
||||
application.DisplayName = displayName;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.ExecutableName, out v) && v is string executableName)
|
||||
{
|
||||
application.ExecutableName = executableName;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.ExecutablePath, out v) && v is string executablePath)
|
||||
{
|
||||
application.ExecutablePath = executablePath;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.OriginalName, out v) && v is string originalName)
|
||||
{
|
||||
application.OriginalName = originalName;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.ShowInShell, out v) && v is bool showInShell)
|
||||
{
|
||||
application.ShowInShell = showInShell;
|
||||
}
|
||||
|
||||
if (applicationData.TryGetValue(Keys.Applications.Signature, out v) && v is string signature)
|
||||
{
|
||||
application.Signature = signature;
|
||||
}
|
||||
|
||||
settings.Applications.Whitelist.Add(application);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 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)
|
||||
{
|
||||
//if (value is int volume)
|
||||
//{
|
||||
// settings.Audio.InitialVolume = volume;
|
||||
//}
|
||||
settings.Audio.InitialVolume = 67;
|
||||
}
|
||||
|
||||
private void MapMuteAudio(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is bool mute)
|
||||
//{
|
||||
// settings.Audio.MuteAudio = mute;
|
||||
//}
|
||||
settings.Audio.MuteAudio = false;
|
||||
}
|
||||
|
||||
private void MapSetInitialVolumeLevel(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is bool initialize)
|
||||
//{
|
||||
// settings.Audio.InitializeVolume = initialize;
|
||||
//}
|
||||
settings.Audio.InitializeVolume = true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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) { }
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.ConfigurationPurpose:
|
||||
MapConfigurationMode(settings, value);
|
||||
break;
|
||||
case Keys.ConfigurationFile.SessionMode:
|
||||
MapSessionMode(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapSessionMode(AppSettings settings, object value)
|
||||
{
|
||||
const int SERVER = 1;
|
||||
|
||||
if (value is int mode)
|
||||
{
|
||||
settings.SessionMode = mode == SERVER ? SessionMode.Server : SessionMode.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 DisplayDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Display.AllowedDisplays:
|
||||
MapAllowedDisplays(settings, value);
|
||||
break;
|
||||
case Keys.Display.AlwaysOn:
|
||||
MapAlwaysOn(settings, value);
|
||||
break;
|
||||
case Keys.Display.IgnoreError:
|
||||
MapIgnoreError(settings, value);
|
||||
break;
|
||||
case Keys.Display.InternalDisplayOnly:
|
||||
MapInternalDisplayOnly(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapAllowedDisplays(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is int count)
|
||||
{
|
||||
settings.Display.AllowedDisplays = count;
|
||||
}
|
||||
*/
|
||||
settings.Display.AllowedDisplays = 500;
|
||||
}
|
||||
|
||||
private void MapAlwaysOn(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool alwaysOn)
|
||||
{
|
||||
settings.Display.AlwaysOn = alwaysOn;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapIgnoreError(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool ignore)
|
||||
{
|
||||
settings.Display.IgnoreError = ignore;
|
||||
}
|
||||
*/
|
||||
settings.Display.IgnoreError = true;
|
||||
}
|
||||
|
||||
private void MapInternalDisplayOnly(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool internalOnly)
|
||||
{
|
||||
settings.Display.InternalDisplayOnly = internalOnly;
|
||||
}
|
||||
*/
|
||||
settings.Display.InternalDisplayOnly = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
internal class GeneralDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.General.LogLevel:
|
||||
MapLogLevel(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapLogLevel(AppSettings settings, object value)
|
||||
{
|
||||
const int ERROR = 0, WARNING = 1, INFO = 2;
|
||||
|
||||
if (value is int level)
|
||||
{
|
||||
settings.LogLevel = level == ERROR ? LogLevel.Error : (level == WARNING ? LogLevel.Warning : (level == INFO ? LogLevel.Info : LogLevel.Debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 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.EnableMiddleMouseButton:
|
||||
MapEnableMiddleMouseButton(settings, value);
|
||||
break;
|
||||
case Keys.Mouse.EnableRightMouseButton:
|
||||
MapEnableRightMouseButton(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapEnableAltEsc(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowAltEsc = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowAltEsc = true;
|
||||
}
|
||||
|
||||
private void MapEnableAltF4(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowAltF4 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowAltF4 = true;
|
||||
}
|
||||
|
||||
private void MapEnableAltTab(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowAltTab = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowAltTab = true;
|
||||
}
|
||||
|
||||
private void MapEnableCtrlEsc(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowCtrlEsc = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowCtrlEsc = true;
|
||||
}
|
||||
|
||||
private void MapEnableEsc(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowEsc = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowEsc = true;
|
||||
}
|
||||
|
||||
private void MapEnableF1(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF1 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF1 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF2(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF2 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF2 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF3(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF3 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF3 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF4(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF4 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF4 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF5(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF5 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF5 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF6(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF6 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF6 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF7(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF7 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF7 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF8(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF8 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF8 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF9(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF9 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF9 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF10(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF10 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF10 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF11(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF11 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF11 = true;
|
||||
}
|
||||
|
||||
private void MapEnableF12(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowF12 = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowF12 = true;
|
||||
}
|
||||
|
||||
private void MapEnablePrintScreen(AppSettings settings, object value)
|
||||
{
|
||||
settings.Keyboard.AllowPrintScreen = true;
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowPrintScreen = enabled;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void MapEnableSystemKey(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Keyboard.AllowSystemKey = enabled;
|
||||
}
|
||||
*/
|
||||
settings.Keyboard.AllowSystemKey = true;
|
||||
}
|
||||
|
||||
private void MapEnableMiddleMouseButton(AppSettings settings, object value)
|
||||
{
|
||||
settings.Mouse.AllowMiddleButton = true;
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Mouse.AllowMiddleButton = enabled;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void MapEnableRightMouseButton(AppSettings settings, object value)
|
||||
{
|
||||
settings.Mouse.AllowRightButton = true;
|
||||
/*
|
||||
if (value is bool enabled)
|
||||
{
|
||||
settings.Mouse.AllowRightButton = enabled;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Proctoring;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
internal class ProctoringDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Proctoring.ForceRaiseHandMessage:
|
||||
MapForceRaiseHandMessage(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ClientId:
|
||||
MapClientId(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ClientSecret:
|
||||
MapClientSecret(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.Enabled:
|
||||
MapScreenProctoringEnabled(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.GroupId:
|
||||
MapGroupId(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ImageDownscaling:
|
||||
MapImageDownscaling(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ImageFormat:
|
||||
MapImageFormat(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ImageQuantization:
|
||||
MapImageQuantization(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.MaxInterval:
|
||||
MapMaxInterval(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData:
|
||||
MapCaptureApplicationData(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData:
|
||||
MapCaptureBrowserData(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle:
|
||||
MapCaptureWindowTitle(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.MinInterval:
|
||||
MapMinInterval(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ScreenProctoring.ServiceUrl:
|
||||
MapServiceUrl(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ShowRaiseHand:
|
||||
MapShowRaiseHand(settings, value);
|
||||
break;
|
||||
case Keys.Proctoring.ShowTaskbarNotification:
|
||||
MapShowTaskbarNotification(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapForceRaiseHandMessage(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool force)
|
||||
{
|
||||
settings.Proctoring.ForceRaiseHandMessage = force;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapCaptureApplicationData(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool capture)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData = capture;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapCaptureBrowserData(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool capture)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData = capture;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapCaptureWindowTitle(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool capture)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle = capture;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapClientId(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string clientId)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.ClientId = clientId;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapClientSecret(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string secret)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.ClientSecret = secret;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapGroupId(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string groupId)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.GroupId = groupId;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapImageDownscaling(AppSettings settings, object value)
|
||||
{
|
||||
if (value is double downscaling)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.ImageDownscaling = downscaling;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapImageFormat(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string s && Enum.TryParse<ImageFormat>(s, true, out var format))
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.ImageFormat = format;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapImageQuantization(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int quantization)
|
||||
{
|
||||
switch (quantization)
|
||||
{
|
||||
case 0:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.BlackAndWhite1bpp;
|
||||
break;
|
||||
case 1:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Grayscale2bpp;
|
||||
break;
|
||||
case 2:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Grayscale4bpp;
|
||||
break;
|
||||
case 3:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Grayscale8bpp;
|
||||
break;
|
||||
case 4:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Color8bpp;
|
||||
break;
|
||||
case 5:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Color16bpp;
|
||||
break;
|
||||
case 6:
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Color24bpp;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMaxInterval(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int interval)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.MaxInterval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMinInterval(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int interval)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.MinInterval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapScreenProctoringEnabled(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is bool enabled)
|
||||
//{
|
||||
// settings.Proctoring.ScreenProctoring.Enabled = enabled;
|
||||
//}
|
||||
settings.Proctoring.ScreenProctoring.Enabled = false;
|
||||
}
|
||||
|
||||
private void MapServiceUrl(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string url)
|
||||
{
|
||||
settings.Proctoring.ScreenProctoring.ServiceUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowRaiseHand(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.Proctoring.ShowRaiseHandNotification = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowTaskbarNotification(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.Proctoring.ShowTaskbarNotification = show;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
internal class SecurityDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Security.AdminPasswordHash:
|
||||
MapAdminPasswordHash(settings, value);
|
||||
break;
|
||||
case Keys.Security.AllowReconfiguration:
|
||||
MapAllowReconfiguration(settings, value);
|
||||
break;
|
||||
case Keys.Security.AllowStickyKeys:
|
||||
MapAllowStickyKeys(settings, value);
|
||||
break;
|
||||
case Keys.Security.AllowTermination:
|
||||
MapAllowTermination(settings, value);
|
||||
break;
|
||||
case Keys.Security.AllowVirtualMachine:
|
||||
MapVirtualMachinePolicy(settings, value);
|
||||
break;
|
||||
case Keys.Security.ClipboardPolicy:
|
||||
MapClipboardPolicy(settings, value);
|
||||
break;
|
||||
case Keys.Security.DisableSessionChangeLockScreen:
|
||||
MapDisableSessionChangeLockScreen(settings, value);
|
||||
break;
|
||||
case Keys.Security.QuitPasswordHash:
|
||||
MapQuitPasswordHash(settings, value);
|
||||
break;
|
||||
case Keys.Security.ReconfigurationUrl:
|
||||
MapReconfigurationUrl(settings, value);
|
||||
break;
|
||||
case Keys.Security.VerifyCursorConfiguration:
|
||||
MapVerifyCursorConfiguration(settings, value);
|
||||
break;
|
||||
case Keys.Security.VerifySessionIntegrity:
|
||||
MapVerifySessionIntegrity(settings, value);
|
||||
break;
|
||||
case Keys.Security.VersionRestrictions:
|
||||
MapVersionRestrictions(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void MapGlobal(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
MapApplicationLogAccess(rawData, settings);
|
||||
MapKioskMode(rawData, settings);
|
||||
}
|
||||
|
||||
private void MapAdminPasswordHash(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is string hash)
|
||||
{
|
||||
settings.Security.AdminPasswordHash = hash;
|
||||
}
|
||||
*/
|
||||
settings.Security.AdminPasswordHash = "";
|
||||
}
|
||||
|
||||
private void MapAllowReconfiguration(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is bool allow)
|
||||
//{
|
||||
// settings.Security.AllowReconfiguration = allow;
|
||||
//}
|
||||
settings.Security.AllowReconfiguration = true;
|
||||
}
|
||||
|
||||
private void MapAllowStickyKeys(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool allow)
|
||||
{
|
||||
settings.Security.AllowStickyKeys = allow;
|
||||
}
|
||||
*/
|
||||
settings.Security.AllowStickyKeys = true;
|
||||
}
|
||||
|
||||
private void MapAllowTermination(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool allow)
|
||||
{
|
||||
settings.Security.AllowTermination = allow;
|
||||
}
|
||||
*/
|
||||
settings.Security.AllowTermination = true;
|
||||
}
|
||||
|
||||
private void MapApplicationLogAccess(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
/*
|
||||
var hasValue = rawData.TryGetValue(Keys.Security.AllowApplicationLog, out var value);
|
||||
|
||||
if (hasValue && value is bool allow)
|
||||
{
|
||||
settings.Security.AllowApplicationLogAccess = allow;
|
||||
}
|
||||
|
||||
if (settings.Security.AllowApplicationLogAccess)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowApplicationLog = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowApplicationLog = false;
|
||||
settings.UserInterface.Taskbar.ShowApplicationLog = false;
|
||||
}
|
||||
*/
|
||||
settings.UserInterface.ActionCenter.ShowApplicationLog = false;
|
||||
settings.UserInterface.Taskbar.ShowApplicationLog = false;
|
||||
}
|
||||
|
||||
private void MapKioskMode(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
/*
|
||||
var hasCreateNewDesktop = rawData.TryGetValue(Keys.Security.KioskModeCreateNewDesktop, out var createNewDesktop);
|
||||
var hasDisableExplorerShell = rawData.TryGetValue(Keys.Security.KioskModeDisableExplorerShell, out var disableExplorerShell);
|
||||
|
||||
if (hasDisableExplorerShell && disableExplorerShell as bool? == true)
|
||||
{
|
||||
settings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
}
|
||||
|
||||
if (hasCreateNewDesktop && createNewDesktop as bool? == true)
|
||||
{
|
||||
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
}
|
||||
|
||||
if (hasCreateNewDesktop && hasDisableExplorerShell && createNewDesktop as bool? == false && disableExplorerShell as bool? == false)
|
||||
{
|
||||
settings.Security.KioskMode = KioskMode.None;
|
||||
}
|
||||
*/
|
||||
settings.Security.KioskMode = KioskMode.None;
|
||||
}
|
||||
|
||||
private void MapQuitPasswordHash(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is string hash)
|
||||
{
|
||||
settings.Security.QuitPasswordHash = hash;
|
||||
}
|
||||
*/
|
||||
settings.Security.QuitPasswordHash = "";
|
||||
}
|
||||
|
||||
private void MapClipboardPolicy(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
const int ALLOW = 0;
|
||||
const int BLOCK = 1;
|
||||
|
||||
if (value is int policy)
|
||||
{
|
||||
settings.Security.ClipboardPolicy = policy == ALLOW ? ClipboardPolicy.Allow : (policy == BLOCK ? ClipboardPolicy.Block : ClipboardPolicy.Isolated);
|
||||
}
|
||||
*/
|
||||
settings.Security.ClipboardPolicy = ClipboardPolicy.Allow;
|
||||
}
|
||||
|
||||
private void MapDisableSessionChangeLockScreen(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool disable)
|
||||
{
|
||||
settings.Security.DisableSessionChangeLockScreen = disable;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapVirtualMachinePolicy(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool allow)
|
||||
{
|
||||
settings.Security.VirtualMachinePolicy = allow ? VirtualMachinePolicy.Allow : VirtualMachinePolicy.Deny;
|
||||
}
|
||||
*/
|
||||
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Allow;
|
||||
}
|
||||
|
||||
private void MapReconfigurationUrl(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is string url)
|
||||
//{
|
||||
// settings.Security.ReconfigurationUrl = url;
|
||||
//}
|
||||
settings.Security.ReconfigurationUrl = "*";
|
||||
}
|
||||
|
||||
private void MapVerifyCursorConfiguration(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool verify)
|
||||
{
|
||||
settings.Security.VerifyCursorConfiguration = verify;
|
||||
}
|
||||
*/
|
||||
settings.Security.VerifyCursorConfiguration = false;
|
||||
}
|
||||
|
||||
private void MapVerifySessionIntegrity(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool verify)
|
||||
{
|
||||
settings.Security.VerifySessionIntegrity = verify;
|
||||
}
|
||||
*/
|
||||
settings.Security.VerifySessionIntegrity = false;
|
||||
}
|
||||
|
||||
private void MapVersionRestrictions(AppSettings settings, object value)
|
||||
{
|
||||
if (value is IList<object> restrictions)
|
||||
{
|
||||
foreach (var restriction in restrictions.Cast<string>())
|
||||
{
|
||||
var parts = restriction.Split('.');
|
||||
var os = parts.Length > 0 ? parts[0] : default;
|
||||
|
||||
if (os?.Equals("win", StringComparison.OrdinalIgnoreCase) == true)
|
||||
{
|
||||
var major = parts.Length > 1 ? int.Parse(parts[1]) : default;
|
||||
var minor = parts.Length > 2 ? int.Parse(parts[2]) : default;
|
||||
var patch = parts.Length > 3 && int.TryParse(parts[3], out _) ? int.Parse(parts[3]) : default(int?);
|
||||
var build = parts.Length > 4 && int.TryParse(parts[4], out _) ? int.Parse(parts[4]) : default(int?);
|
||||
|
||||
//settings.Security.VersionRestrictions.Add(new VersionRestriction
|
||||
//{
|
||||
// Major = major,
|
||||
// Minor = minor,
|
||||
// Patch = patch,
|
||||
// Build = build,
|
||||
// IsMinimumRestriction = restriction.Contains("min"),
|
||||
// RequiresAllianceEdition = restriction.Contains("AE")
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 class ServerDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Server.Configuration:
|
||||
MapConfiguration(settings, value);
|
||||
break;
|
||||
case Keys.Server.FallbackPasswordHash:
|
||||
MapFallbackPasswordHash(settings, value);
|
||||
break;
|
||||
case Keys.Server.PerformFallback:
|
||||
MapPerformFallback(settings, value);
|
||||
break;
|
||||
case Keys.Server.RequestAttempts:
|
||||
MapRequestAttempts(settings, value);
|
||||
break;
|
||||
case Keys.Server.RequestAttemptInterval:
|
||||
MapRequestAttemptInterval(settings, value);
|
||||
break;
|
||||
case Keys.Server.RequestTimeout:
|
||||
MapRequestTimeout(settings, value);
|
||||
break;
|
||||
case Keys.Server.ServerUrl:
|
||||
MapServerUrl(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapConfiguration(AppSettings settings, object value)
|
||||
{
|
||||
if (value is IDictionary<string, object> configuration)
|
||||
{
|
||||
if (configuration.TryGetValue(Keys.Server.ApiUrl, out var v) && v is string url)
|
||||
{
|
||||
settings.Server.ApiUrl = url;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(Keys.Server.ClientName, out v) && v is string name)
|
||||
{
|
||||
settings.Server.ClientName = name;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(Keys.Server.ClientSecret, out v) && v is string secret)
|
||||
{
|
||||
settings.Server.ClientSecret = secret;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(Keys.Server.ExamId, out v) && v is string examId)
|
||||
{
|
||||
settings.Server.ExamId = examId;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(Keys.Server.Institution, out v) && v is string institution)
|
||||
{
|
||||
settings.Server.Institution = institution;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(Keys.Server.PingInterval, out v) && v is int interval)
|
||||
{
|
||||
settings.Server.PingInterval = interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MapFallbackPasswordHash(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is string hash)
|
||||
//{
|
||||
// settings.Server.FallbackPasswordHash = hash;
|
||||
//}
|
||||
settings.Server.FallbackPasswordHash = "";
|
||||
}
|
||||
|
||||
private void MapPerformFallback(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool perform)
|
||||
{
|
||||
settings.Server.PerformFallback = perform;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapRequestAttempts(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int attempts)
|
||||
{
|
||||
settings.Server.RequestAttempts = attempts;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapRequestAttemptInterval(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int interval)
|
||||
{
|
||||
settings.Server.RequestAttemptInterval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapRequestTimeout(AppSettings settings, object value)
|
||||
{
|
||||
if (value is int timeout)
|
||||
{
|
||||
settings.Server.RequestTimeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapServerUrl(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string url)
|
||||
{
|
||||
settings.Server.ServerUrl = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using SafeExamBrowser.Settings.Service;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
internal class ServiceDataMapper : BaseDataMapper
|
||||
{
|
||||
public static bool enable = true;
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Service.EnableChromeNotifications:
|
||||
MapEnableChromeNotifications(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableEaseOfAccessOptions:
|
||||
MapEnableEaseOfAccessOptions(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableFindPrinter:
|
||||
MapEnableFindPrinter(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableNetworkOptions:
|
||||
MapEnableNetworkOptions(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnablePasswordChange:
|
||||
MapEnablePasswordChange(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnablePowerOptions:
|
||||
MapEnablePowerOptions(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableRemoteConnections:
|
||||
MapEnableRemoteConnections(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableSignout:
|
||||
MapEnableSignout(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableTaskManager:
|
||||
MapEnableTaskManager(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableUserLock:
|
||||
MapEnableUserLock(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableUserSwitch:
|
||||
MapEnableUserSwitch(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableVmwareOverlay:
|
||||
MapEnableVmwareOverlay(settings, value);
|
||||
break;
|
||||
case Keys.Service.EnableWindowsUpdate:
|
||||
MapEnableWindowsUpdate(settings, value);
|
||||
break;
|
||||
case Keys.Service.IgnoreService:
|
||||
MapIgnoreService(settings, value);
|
||||
break;
|
||||
case Keys.Service.Policy:
|
||||
MapPolicy(settings, value);
|
||||
break;
|
||||
case Keys.Service.SetVmwareConfiguration:
|
||||
MapSetVmwareConfiguration(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapEnableChromeNotifications(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableChromeNotifications = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableChromeNotifications = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableEaseOfAccessOptions(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableEaseOfAccessOptions = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableEaseOfAccessOptions = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableFindPrinter(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableFindPrinter = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableFindPrinter = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableNetworkOptions(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableNetworkOptions = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableNetworkOptions = !enable;
|
||||
}
|
||||
|
||||
private void MapEnablePasswordChange(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisablePasswordChange = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisablePasswordChange = !enable;
|
||||
}
|
||||
|
||||
private void MapEnablePowerOptions(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisablePowerOptions = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisablePowerOptions = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableRemoteConnections(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableRemoteConnections = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableRemoteConnections = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableSignout(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableSignout = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableSignout = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableTaskManager(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableTaskManager = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableTaskManager = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableUserLock(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableUserLock = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableUserLock = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableUserSwitch(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableUserSwitch = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableUserSwitch = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableVmwareOverlay(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableVmwareOverlay = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableVmwareOverlay = !enable;
|
||||
}
|
||||
|
||||
private void MapEnableWindowsUpdate(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.Service.DisableWindowsUpdate = !enable;
|
||||
}
|
||||
*/
|
||||
settings.Service.DisableWindowsUpdate = !enable;
|
||||
}
|
||||
|
||||
private void MapIgnoreService(AppSettings settings, object value)
|
||||
{
|
||||
//if (value is bool ignore)
|
||||
//{
|
||||
// settings.Service.IgnoreService = ignore;
|
||||
//}
|
||||
settings.Service.IgnoreService = enable;
|
||||
}
|
||||
|
||||
private void MapPolicy(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
const int WARN = 1;
|
||||
const int FORCE = 2;
|
||||
|
||||
if (value is int policy)
|
||||
{
|
||||
settings.Service.Policy = policy == FORCE ? ServicePolicy.Mandatory : (policy == WARN ? ServicePolicy.Warn : ServicePolicy.Optional);
|
||||
}
|
||||
*/
|
||||
settings.Service.Policy = ServicePolicy.Optional;
|
||||
}
|
||||
|
||||
private void MapSetVmwareConfiguration(AppSettings settings, object value)
|
||||
{
|
||||
/*
|
||||
if (value is bool set)
|
||||
{
|
||||
settings.Service.SetVmwareConfiguration = set;
|
||||
}
|
||||
*/
|
||||
settings.Service.SetVmwareConfiguration = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 SystemDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.System.AlwaysOn:
|
||||
MapAlwaysOn(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapAlwaysOn(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool alwaysOn)
|
||||
{
|
||||
settings.System.AlwaysOn = alwaysOn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using SafeExamBrowser.Settings.UserInterface;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||
{
|
||||
internal class UserInterfaceDataMapper : BaseDataMapper
|
||||
{
|
||||
internal override void Map(string key, object value, AppSettings settings)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.UserInterface.ActionCenter.EnableActionCenter:
|
||||
MapEnableActionCenter(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.LockScreen.BackgroundColor:
|
||||
MapLockScreenBackgroundColor(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.Audio.Show:
|
||||
MapShowAudio(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.Clock.Show:
|
||||
MapShowClock(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.KeyboardLayout.Show:
|
||||
MapShowKeyboardLayout(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.Network.Show:
|
||||
MapShowNetwork(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.PowerSupply.ChargeThresholdCritical:
|
||||
MapChargeThresholdCritical(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.SystemControls.PowerSupply.ChargeThresholdLow:
|
||||
MapChargeThresholdLow(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.Taskbar.EnableTaskbar:
|
||||
MapEnableTaskbar(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.Taskbar.ShowApplicationLog:
|
||||
MapShowApplicationLog(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.UserInterfaceMode:
|
||||
MapUserInterfaceMode(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapEnableActionCenter(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.EnableActionCenter = enable;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapLockScreenBackgroundColor(AppSettings settings, object value)
|
||||
{
|
||||
if (value is string color)
|
||||
{
|
||||
settings.UserInterface.LockScreen.BackgroundColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowAudio(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowAudio = show;
|
||||
settings.UserInterface.Taskbar.ShowAudio = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowClock(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowClock = show;
|
||||
settings.UserInterface.Taskbar.ShowClock = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowKeyboardLayout(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowKeyboardLayout = show;
|
||||
settings.UserInterface.Taskbar.ShowKeyboardLayout = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowNetwork(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.UserInterface.ActionCenter.ShowNetwork = show;
|
||||
settings.UserInterface.Taskbar.ShowNetwork = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapChargeThresholdCritical(AppSettings settings, object value)
|
||||
{
|
||||
if (value is double threshold)
|
||||
{
|
||||
settings.PowerSupply.ChargeThresholdCritical = threshold;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapChargeThresholdLow(AppSettings settings, object value)
|
||||
{
|
||||
if (value is double threshold)
|
||||
{
|
||||
settings.PowerSupply.ChargeThresholdLow = threshold;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapEnableTaskbar(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool enable)
|
||||
{
|
||||
settings.UserInterface.Taskbar.EnableTaskbar = enable;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapShowApplicationLog(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.UserInterface.Taskbar.ShowApplicationLog = show;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapUserInterfaceMode(AppSettings settings, object value)
|
||||
{
|
||||
if (value is bool mobile)
|
||||
{
|
||||
settings.UserInterface.Mode = mobile ? UserInterfaceMode.Mobile : UserInterfaceMode.Desktop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
101
SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs
Normal file
101
SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Applications;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal class DataProcessor
|
||||
{
|
||||
internal void Process(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
ProcessDefault(settings);
|
||||
CalculateConfigurationKey(rawData, settings);
|
||||
}
|
||||
|
||||
internal void ProcessDefault(AppSettings settings)
|
||||
{
|
||||
AllowBrowserToolbarForReloading(settings);
|
||||
InitializeBrowserHomeFunctionality(settings);
|
||||
InitializeClipboardSettings(settings);
|
||||
InitializeProctoringSettings(settings);
|
||||
RemoveLegacyBrowsers(settings);
|
||||
}
|
||||
|
||||
private void AllowBrowserToolbarForReloading(AppSettings settings)
|
||||
{
|
||||
settings.Browser.AdditionalWindow.ShowToolbar = true;
|
||||
settings.Browser.MainWindow.ShowToolbar = true;
|
||||
}
|
||||
|
||||
private void CalculateConfigurationKey(IDictionary<string, object> rawData, AppSettings settings)
|
||||
{
|
||||
using (var algorithm = new SHA256Managed())
|
||||
using (var stream = new MemoryStream())
|
||||
using (var writer = new StreamWriter(stream))
|
||||
{
|
||||
Json.Serialize(rawData, writer);
|
||||
|
||||
writer.Flush();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
var hash = algorithm.ComputeHash(stream);
|
||||
var key = BitConverter.ToString(hash).ToLower().Replace("-", string.Empty);
|
||||
|
||||
settings.Browser.ConfigurationKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeBrowserHomeFunctionality(AppSettings settings)
|
||||
{
|
||||
settings.Browser.MainWindow.ShowHomeButton = settings.Browser.UseStartUrlAsHomeUrl || !string.IsNullOrWhiteSpace(settings.Browser.HomeUrl);
|
||||
settings.Browser.HomePasswordHash = "";
|
||||
}
|
||||
|
||||
private void InitializeClipboardSettings(AppSettings settings)
|
||||
{
|
||||
settings.Browser.UseIsolatedClipboard = false;
|
||||
settings.Keyboard.AllowCtrlC = true;
|
||||
settings.Keyboard.AllowCtrlV = true;
|
||||
settings.Keyboard.AllowCtrlX = true;
|
||||
}
|
||||
|
||||
private void InitializeProctoringSettings(AppSettings settings)
|
||||
{
|
||||
settings.Proctoring.Enabled = settings.Proctoring.ScreenProctoring.Enabled;
|
||||
}
|
||||
|
||||
private void RemoveLegacyBrowsers(AppSettings settings)
|
||||
{
|
||||
var legacyBrowsers = new List<WhitelistApplication>();
|
||||
|
||||
foreach (var application in settings.Applications.Whitelist)
|
||||
{
|
||||
var isEnginePath = application.ExecutablePath?.Contains("xulrunner") == true;
|
||||
var isFirefox = application.ExecutableName?.Equals("firefox.exe", StringComparison.OrdinalIgnoreCase) == true;
|
||||
var isXulRunner = application.ExecutableName?.Equals("xulrunner.exe", StringComparison.OrdinalIgnoreCase) == true;
|
||||
|
||||
if (isEnginePath && (isFirefox || isXulRunner))
|
||||
{
|
||||
legacyBrowsers.Add(application);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var legacyBrowser in legacyBrowsers)
|
||||
{
|
||||
settings.Applications.Whitelist.Remove(legacyBrowser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
311
SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
Normal file
311
SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
Normal file
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Applications;
|
||||
using SafeExamBrowser.Settings.Browser;
|
||||
using SafeExamBrowser.Settings.Browser.Proxy;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
using SafeExamBrowser.Settings.Proctoring;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.Settings.Service;
|
||||
using SafeExamBrowser.Settings.UserInterface;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal class DataValues
|
||||
{
|
||||
private const string DEFAULT_CONFIGURATION_NAME = "SebClientSettings.seb";
|
||||
private AppConfig appConfig;
|
||||
|
||||
internal string GetAppDataFilePath()
|
||||
{
|
||||
return appConfig.AppDataFilePath;
|
||||
}
|
||||
|
||||
internal AppConfig InitializeAppConfig()
|
||||
{
|
||||
var executable = Assembly.GetEntryAssembly();
|
||||
var certificate = executable.Modules.First().GetSignerCertificate();
|
||||
var programBuild = FileVersionInfo.GetVersionInfo(executable.Location).FileVersion;
|
||||
var programCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
|
||||
var programTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
||||
var programVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||
var appDataLocalFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), nameof(SafeExamBrowser));
|
||||
var appDataRoamingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser));
|
||||
var programDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser));
|
||||
var temporaryFolder = Path.Combine(appDataLocalFolder, "Temp");
|
||||
var startTime = DateTime.Now;
|
||||
var logFolder = Path.Combine(appDataLocalFolder, "Logs");
|
||||
var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
|
||||
|
||||
appConfig = new AppConfig();
|
||||
appConfig.AppDataFilePath = Path.Combine(appDataRoamingFolder, DEFAULT_CONFIGURATION_NAME);
|
||||
appConfig.ApplicationStartTime = startTime;
|
||||
appConfig.BrowserCachePath = Path.Combine(appDataLocalFolder, "Cache");
|
||||
appConfig.BrowserLogFilePath = Path.Combine(logFolder, $"{logFilePrefix}_Browser.log");
|
||||
appConfig.ClientId = Guid.NewGuid();
|
||||
appConfig.ClientAddress = $"{AppConfig.BASE_ADDRESS}/client/{Guid.NewGuid()}";
|
||||
appConfig.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe");
|
||||
appConfig.ClientLogFilePath = Path.Combine(logFolder, $"{logFilePrefix}_Client.log");
|
||||
appConfig.CodeSignatureHash = certificate?.GetCertHashString();
|
||||
appConfig.ConfigurationFileExtension = ".seb";
|
||||
appConfig.ConfigurationFileMimeType = "application/seb";
|
||||
appConfig.ProgramBuildVersion = programBuild;
|
||||
appConfig.ProgramCopyright = programCopyright;
|
||||
appConfig.ProgramDataFilePath = Path.Combine(programDataFolder, DEFAULT_CONFIGURATION_NAME);
|
||||
appConfig.ProgramTitle = programTitle;
|
||||
appConfig.ProgramInformationalVersion = programVersion;
|
||||
appConfig.RuntimeId = Guid.NewGuid();
|
||||
appConfig.RuntimeAddress = $"{AppConfig.BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
|
||||
appConfig.RuntimeLogFilePath = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.log");
|
||||
appConfig.SebUriScheme = "seb";
|
||||
appConfig.SebUriSchemeSecure = "sebs";
|
||||
appConfig.ServiceAddress = $"{AppConfig.BASE_ADDRESS}/service";
|
||||
appConfig.ServiceEventName = $@"Global\{nameof(SafeExamBrowser)}-{Guid.NewGuid()}";
|
||||
appConfig.ServiceLogFilePath = Path.Combine(logFolder, $"{logFilePrefix}_Service.log");
|
||||
appConfig.SessionCacheFilePath = Path.Combine(temporaryFolder, "cache.bin");
|
||||
appConfig.TemporaryDirectory = temporaryFolder;
|
||||
|
||||
return appConfig;
|
||||
}
|
||||
|
||||
internal SessionConfiguration InitializeSessionConfiguration()
|
||||
{
|
||||
var configuration = new SessionConfiguration();
|
||||
|
||||
appConfig.ClientId = Guid.NewGuid();
|
||||
appConfig.ClientAddress = $"{AppConfig.BASE_ADDRESS}/client/{Guid.NewGuid()}";
|
||||
appConfig.ServiceEventName = $@"Global\{nameof(SafeExamBrowser)}-{Guid.NewGuid()}";
|
||||
|
||||
configuration.AppConfig = appConfig.Clone();
|
||||
configuration.ClientAuthenticationToken = Guid.NewGuid();
|
||||
configuration.SessionId = Guid.NewGuid();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
internal AppSettings LoadDefaultSettings()
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "AA_v3.exe", OriginalName = "AA_v3.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "AeroAdmin.exe", OriginalName = "AeroAdmin.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "beamyourscreen-host.exe", OriginalName = "beamyourscreen-host.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CamPlay.exe", OriginalName = "CamPlay.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Camtasia.exe", OriginalName = "Camtasia.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CamtasiaStudio.exe", OriginalName = "CamtasiaStudio.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Camtasia_Studio.exe", OriginalName = "Camtasia_Studio.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CamRecorder.exe", OriginalName = "CamRecorder.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CamtasiaUtl.exe", OriginalName = "CamtasiaUtl.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "chromoting.exe", OriginalName = "chromoting.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CiscoCollabHost.exe", OriginalName = "CiscoCollabHost.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "CiscoWebExStart.exe", OriginalName = "CiscoWebExStart.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Discord.exe", OriginalName = "Discord.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Element.exe", OriginalName = "Element.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "g2mcomm.exe", OriginalName = "g2mcomm.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "g2mlauncher.exe", OriginalName = "g2mlauncher.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "g2mstart.exe", OriginalName = "g2mstart.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "GotoMeetingWinStore.exe", OriginalName = "GotoMeetingWinStore.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "join.me.exe", OriginalName = "join.me.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "join.me.sentinel.exe", OriginalName = "join.me.sentinel.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Microsoft.Media.player.exe", OriginalName = "Microsoft.Media.player.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Mikogo-host.exe", OriginalName = "Mikogo-host.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "MS-teams.exe", OriginalName = "MS-Teams.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "obs32.exe", OriginalName = "obs32.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "obs64.exe", OriginalName = "obs64.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "PCMonitorSrv.exe", OriginalName = "PCMonitorSrv.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "pcmontask.exe", OriginalName = "pcmontask.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "ptoneclk.exe", OriginalName = "ptoneclk.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "RemotePCDesktop.exe", OriginalName = "RemotePCDesktop.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "remoting_host.exe", OriginalName = "remoting_host.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "RPCService.exe", OriginalName = "RPCService.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "RPCSuite.exe", OriginalName = "RPCSuite.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "sethc.exe", OriginalName = "sethc.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Skype.exe", OriginalName = "Skype.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "SkypeApp.exe", OriginalName = "SkypeApp.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "SkypeHost.exe", OriginalName = "SkypeHost.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "slack.exe", OriginalName = "slack.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "spotify.exe", OriginalName = "spotify.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "SRServer.exe", OriginalName = "SRServer.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "strwinclt.exe", OriginalName = "strwinclt.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Teams.exe", OriginalName = "Teams.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "TeamViewer.exe", OriginalName = "TeamViewer.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Telegram.exe", OriginalName = "Telegram.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "VLC.exe", OriginalName = "VLC.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "vncserver.exe", OriginalName = "vncserver.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "vncviewer.exe", OriginalName = "vncviewer.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "vncserverui.exe", OriginalName = "vncserverui.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "webexmta.exe", OriginalName = "webexmta.exe" });
|
||||
settings.Applications.Blacklist.Add(new BlacklistApplication { ExecutableName = "Zoom.exe", OriginalName = "Zoom.exe" });
|
||||
|
||||
settings.Browser.AdditionalWindow.AllowAddressBar = false;
|
||||
settings.Browser.AdditionalWindow.AllowBackwardNavigation = true;
|
||||
settings.Browser.AdditionalWindow.AllowDeveloperConsole = false;
|
||||
settings.Browser.AdditionalWindow.AllowForwardNavigation = true;
|
||||
settings.Browser.AdditionalWindow.AllowReloading = true;
|
||||
settings.Browser.AdditionalWindow.FullScreenMode = false;
|
||||
settings.Browser.AdditionalWindow.Position = WindowPosition.Right;
|
||||
settings.Browser.AdditionalWindow.RelativeHeight = 100;
|
||||
settings.Browser.AdditionalWindow.RelativeWidth = 50;
|
||||
settings.Browser.AdditionalWindow.ShowHomeButton = false;
|
||||
settings.Browser.AdditionalWindow.ShowReloadWarning = false;
|
||||
settings.Browser.AdditionalWindow.ShowToolbar = false;
|
||||
settings.Browser.AdditionalWindow.UrlPolicy = UrlPolicy.Never;
|
||||
settings.Browser.AllowConfigurationDownloads = true;
|
||||
settings.Browser.AllowCustomDownAndUploadLocation = false;
|
||||
settings.Browser.AllowDownloads = true;
|
||||
settings.Browser.AllowFind = true;
|
||||
settings.Browser.AllowPageZoom = true;
|
||||
settings.Browser.AllowPdfReader = true;
|
||||
settings.Browser.AllowPdfReaderToolbar = false;
|
||||
settings.Browser.AllowPrint = false;
|
||||
settings.Browser.AllowUploads = true;
|
||||
settings.Browser.DeleteCacheOnShutdown = true;
|
||||
settings.Browser.DeleteCookiesOnShutdown = true;
|
||||
settings.Browser.DeleteCookiesOnStartup = true;
|
||||
settings.Browser.EnableBrowser = true;
|
||||
settings.Browser.MainWindow.AllowAddressBar = false;
|
||||
settings.Browser.MainWindow.AllowBackwardNavigation = false;
|
||||
settings.Browser.MainWindow.AllowDeveloperConsole = false;
|
||||
settings.Browser.MainWindow.AllowForwardNavigation = false;
|
||||
settings.Browser.MainWindow.AllowReloading = true;
|
||||
settings.Browser.MainWindow.FullScreenMode = false;
|
||||
settings.Browser.MainWindow.RelativeHeight = 100;
|
||||
settings.Browser.MainWindow.RelativeWidth = 100;
|
||||
settings.Browser.MainWindow.ShowHomeButton = false;
|
||||
settings.Browser.MainWindow.ShowReloadWarning = true;
|
||||
settings.Browser.MainWindow.ShowToolbar = false;
|
||||
settings.Browser.MainWindow.UrlPolicy = UrlPolicy.Never;
|
||||
settings.Browser.PopupPolicy = PopupPolicy.Allow;
|
||||
settings.Browser.Proxy.Policy = ProxyPolicy.System;
|
||||
settings.Browser.ResetOnQuitUrl = false;
|
||||
settings.Browser.SendBrowserExamKey = false;
|
||||
settings.Browser.SendConfigurationKey = false;
|
||||
settings.Browser.ShowFileSystemElementPath = true;
|
||||
settings.Browser.StartUrl = "https://www.safeexambrowser.org/start";
|
||||
settings.Browser.UseCustomUserAgent = false;
|
||||
settings.Browser.UseIsolatedClipboard = true;
|
||||
settings.Browser.UseQueryParameter = false;
|
||||
settings.Browser.UseTemporaryDownAndUploadDirectory = false;
|
||||
|
||||
settings.ConfigurationMode = ConfigurationMode.Exam;
|
||||
|
||||
settings.Display.AllowedDisplays = 1;
|
||||
settings.Display.AlwaysOn = true;
|
||||
settings.Display.IgnoreError = false;
|
||||
settings.Display.InternalDisplayOnly = false;
|
||||
|
||||
settings.Keyboard.AllowAltEsc = false;
|
||||
settings.Keyboard.AllowAltF4 = false;
|
||||
settings.Keyboard.AllowAltTab = true;
|
||||
settings.Keyboard.AllowCtrlC = true;
|
||||
settings.Keyboard.AllowCtrlEsc = false;
|
||||
settings.Keyboard.AllowCtrlV = true;
|
||||
settings.Keyboard.AllowCtrlX = true;
|
||||
settings.Keyboard.AllowEsc = true;
|
||||
settings.Keyboard.AllowF1 = true;
|
||||
settings.Keyboard.AllowF2 = true;
|
||||
settings.Keyboard.AllowF3 = true;
|
||||
settings.Keyboard.AllowF4 = true;
|
||||
settings.Keyboard.AllowF5 = true;
|
||||
settings.Keyboard.AllowF6 = true;
|
||||
settings.Keyboard.AllowF7 = true;
|
||||
settings.Keyboard.AllowF8 = true;
|
||||
settings.Keyboard.AllowF9 = true;
|
||||
settings.Keyboard.AllowF10 = true;
|
||||
settings.Keyboard.AllowF11 = true;
|
||||
settings.Keyboard.AllowF12 = true;
|
||||
settings.Keyboard.AllowPrintScreen = false;
|
||||
settings.Keyboard.AllowSystemKey = false;
|
||||
|
||||
settings.LogLevel = LogLevel.Debug;
|
||||
|
||||
settings.Mouse.AllowMiddleButton = false;
|
||||
settings.Mouse.AllowRightButton = true;
|
||||
|
||||
settings.PowerSupply.ChargeThresholdCritical = 0.1;
|
||||
settings.PowerSupply.ChargeThresholdLow = 0.2;
|
||||
|
||||
settings.Proctoring.Enabled = false;
|
||||
settings.Proctoring.ForceRaiseHandMessage = false;
|
||||
settings.Proctoring.ScreenProctoring.Enabled = false;
|
||||
settings.Proctoring.ScreenProctoring.ImageDownscaling = 1.0;
|
||||
settings.Proctoring.ScreenProctoring.ImageFormat = ImageFormat.Png;
|
||||
settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Grayscale4bpp;
|
||||
settings.Proctoring.ScreenProctoring.MaxInterval = 5000;
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData = true;
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData = true;
|
||||
settings.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle = true;
|
||||
settings.Proctoring.ScreenProctoring.MinInterval = 1000;
|
||||
settings.Proctoring.ShowRaiseHandNotification = true;
|
||||
settings.Proctoring.ShowTaskbarNotification = true;
|
||||
|
||||
settings.Security.AllowApplicationLogAccess = false;
|
||||
settings.Security.AllowTermination = true;
|
||||
settings.Security.AllowReconfiguration = false;
|
||||
settings.Security.AllowStickyKeys = false;
|
||||
settings.Security.ClipboardPolicy = ClipboardPolicy.Isolated;
|
||||
settings.Security.DisableSessionChangeLockScreen = false;
|
||||
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
settings.Security.VerifyCursorConfiguration = true;
|
||||
settings.Security.VerifySessionIntegrity = true;
|
||||
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
|
||||
|
||||
settings.Server.PingInterval = 1000;
|
||||
settings.Server.RequestAttemptInterval = 2000;
|
||||
settings.Server.RequestAttempts = 5;
|
||||
settings.Server.RequestTimeout = 30000;
|
||||
settings.Server.PerformFallback = false;
|
||||
|
||||
settings.Service.DisableChromeNotifications = true;
|
||||
settings.Service.DisableEaseOfAccessOptions = true;
|
||||
settings.Service.DisableFindPrinter = true;
|
||||
settings.Service.DisableNetworkOptions = true;
|
||||
settings.Service.DisablePasswordChange = true;
|
||||
settings.Service.DisablePowerOptions = true;
|
||||
settings.Service.DisableRemoteConnections = true;
|
||||
settings.Service.DisableSignout = true;
|
||||
settings.Service.DisableTaskManager = true;
|
||||
settings.Service.DisableUserLock = true;
|
||||
settings.Service.DisableUserSwitch = true;
|
||||
settings.Service.DisableVmwareOverlay = true;
|
||||
settings.Service.DisableWindowsUpdate = true;
|
||||
settings.Service.IgnoreService = true;
|
||||
settings.Service.Policy = ServicePolicy.Mandatory;
|
||||
settings.Service.SetVmwareConfiguration = false;
|
||||
|
||||
settings.SessionMode = SessionMode.Normal;
|
||||
|
||||
settings.System.AlwaysOn = true;
|
||||
|
||||
settings.UserInterface.ActionCenter.EnableActionCenter = true;
|
||||
settings.UserInterface.ActionCenter.ShowApplicationInfo = true;
|
||||
settings.UserInterface.ActionCenter.ShowApplicationLog = false;
|
||||
settings.UserInterface.ActionCenter.ShowClock = true;
|
||||
settings.UserInterface.ActionCenter.ShowKeyboardLayout = true;
|
||||
settings.UserInterface.ActionCenter.ShowNetwork = false;
|
||||
settings.UserInterface.LockScreen.BackgroundColor = "#ff0000";
|
||||
settings.UserInterface.Mode = UserInterfaceMode.Desktop;
|
||||
settings.UserInterface.Taskbar.EnableTaskbar = true;
|
||||
settings.UserInterface.Taskbar.ShowApplicationInfo = false;
|
||||
settings.UserInterface.Taskbar.ShowApplicationLog = false;
|
||||
settings.UserInterface.Taskbar.ShowClock = true;
|
||||
settings.UserInterface.Taskbar.ShowKeyboardLayout = true;
|
||||
settings.UserInterface.Taskbar.ShowNetwork = false;
|
||||
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
107
SafeExamBrowser.Configuration/ConfigurationData/Json.cs
Normal file
107
SafeExamBrowser.Configuration/ConfigurationData/Json.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal static class Json
|
||||
{
|
||||
internal static void Serialize(IDictionary<string, object> dictionary, StreamWriter stream)
|
||||
{
|
||||
var orderedByKey = dictionary.OrderBy(d => d.Key, StringComparer.InvariantCulture).ToList();
|
||||
|
||||
stream.Write('{');
|
||||
|
||||
foreach (var kvp in orderedByKey)
|
||||
{
|
||||
var process = true;
|
||||
|
||||
process &= !kvp.Key.Equals(Keys.General.OriginatorVersion, StringComparison.OrdinalIgnoreCase);
|
||||
process &= !(kvp.Value is IDictionary<string, object> d) || d.Any();
|
||||
|
||||
if (process)
|
||||
{
|
||||
stream.Write('"');
|
||||
stream.Write(kvp.Key);
|
||||
stream.Write('"');
|
||||
stream.Write(':');
|
||||
|
||||
Serialize(kvp.Value, stream);
|
||||
|
||||
if (kvp.Key != orderedByKey.Last().Key)
|
||||
{
|
||||
stream.Write(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.Write('}');
|
||||
}
|
||||
|
||||
private static void Serialize(IList<object> list, StreamWriter stream)
|
||||
{
|
||||
stream.Write('[');
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
Serialize(item, stream);
|
||||
|
||||
if (item != list.Last())
|
||||
{
|
||||
stream.Write(',');
|
||||
}
|
||||
}
|
||||
|
||||
stream.Write(']');
|
||||
}
|
||||
|
||||
private static void Serialize(object value, StreamWriter stream)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case IDictionary<string, object> dictionary:
|
||||
Serialize(dictionary, stream);
|
||||
break;
|
||||
case IList<object> list:
|
||||
Serialize(list, stream);
|
||||
break;
|
||||
case byte[] data:
|
||||
stream.Write('"');
|
||||
stream.Write(Convert.ToBase64String(data));
|
||||
stream.Write('"');
|
||||
break;
|
||||
case DateTime date:
|
||||
stream.Write(date.ToString("o"));
|
||||
break;
|
||||
case bool boolean:
|
||||
stream.Write(boolean.ToString().ToLower());
|
||||
break;
|
||||
case int integer:
|
||||
stream.Write(integer.ToString(NumberFormatInfo.InvariantInfo));
|
||||
break;
|
||||
case double number:
|
||||
stream.Write(number.ToString(NumberFormatInfo.InvariantInfo));
|
||||
break;
|
||||
case string text:
|
||||
stream.Write('"');
|
||||
stream.Write(text);
|
||||
stream.Write('"');
|
||||
break;
|
||||
case null:
|
||||
stream.Write('"');
|
||||
stream.Write('"');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
371
SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
Normal file
371
SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
Normal file
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal static class Keys
|
||||
{
|
||||
internal const int WINDOWS = 1;
|
||||
|
||||
internal static class Applications
|
||||
{
|
||||
internal const string Active = "active";
|
||||
internal const string AllowCustomPath = "allowUserToChooseApp";
|
||||
internal const string AllowRunning = "runInBackground";
|
||||
internal const string Argument = "argument";
|
||||
internal const string Arguments = "arguments";
|
||||
internal const string AutoStart = "autostart";
|
||||
internal const string AutoTerminate = "strongKill";
|
||||
internal const string Blacklist = "prohibitedProcesses";
|
||||
internal const string Description = "description";
|
||||
internal const string DisplayName = "title";
|
||||
internal const string ExecutableName = "executable";
|
||||
internal const string ExecutablePath = "path";
|
||||
internal const string OperatingSystem = "os";
|
||||
internal const string OriginalName = "originalName";
|
||||
internal const string ShowInShell = "iconInTaskbar";
|
||||
internal const string Signature = "signature";
|
||||
internal const string Whitelist = "permittedProcesses";
|
||||
}
|
||||
|
||||
internal static class Audio
|
||||
{
|
||||
internal const string InitialVolumeLevel = "audioVolumeLevel";
|
||||
internal const string MuteAudio = "audioMute";
|
||||
internal const string SetInitialVolumeLevel = "audioSetVolumeLevel";
|
||||
}
|
||||
|
||||
internal static class Browser
|
||||
{
|
||||
internal const string AllowConfigurationDownloads = "downloadAndOpenSebConfig";
|
||||
internal const string AllowCustomDownUploadLocation = "allowCustomDownUploadLocation";
|
||||
internal const string AllowDeveloperConsole = "allowDeveloperConsole";
|
||||
internal const string AllowDownloads = "allowDownloads";
|
||||
internal const string AllowDownloadsAndUploads = "allowDownUploads";
|
||||
internal const string AllowFind = "allowFind";
|
||||
internal const string AllowPageZoom = "enableZoomPage";
|
||||
internal const string AllowPdfReaderToolbar = "allowPDFReaderToolbar";
|
||||
internal const string AllowPrint = "allowPrint";
|
||||
internal const string AllowSpellChecking = "allowSpellCheck";
|
||||
internal const string AllowUploads = "allowUploads";
|
||||
internal const string CustomUserAgentDesktop = "browserUserAgentWinDesktopModeCustom";
|
||||
internal const string CustomUserAgentMobile = "browserUserAgentWinTouchModeCustom";
|
||||
internal const string DeleteCacheOnShutdown = "removeBrowserProfile";
|
||||
internal const string DeleteCookiesOnShutdown = "examSessionClearCookiesOnEnd";
|
||||
internal const string DeleteCookiesOnStartup = "examSessionClearCookiesOnStart";
|
||||
internal const string DownloadDirectory = "downloadDirectoryWin";
|
||||
internal const string DownloadPdfFiles = "downloadPDFFiles";
|
||||
internal const string EnableBrowser = "enableSebBrowser";
|
||||
internal const string ExamKeySalt = "examKeySalt";
|
||||
internal const string HomeButtonMessage = "restartExamText";
|
||||
internal const string HomeButtonRequiresPassword = "restartExamPasswordProtected";
|
||||
internal const string HomeButtonUrl = "restartExamURL";
|
||||
internal const string HomeButtonUseStartUrl = "restartExamUseStartURL";
|
||||
internal const string PopupPolicy = "newBrowserWindowByLinkPolicy";
|
||||
internal const string PopupBlockForeignHost = "newBrowserWindowByLinkBlockForeign";
|
||||
internal const string QuitUrl = "quitURL";
|
||||
internal const string QuitUrlConfirmation = "quitURLConfirm";
|
||||
internal const string ResetOnQuitUrl = "quitURLRestart";
|
||||
internal const string SendCustomHeaders = "sendBrowserExamKey";
|
||||
internal const string ShowFileSystemElementPath = "browserShowFileSystemElementPath";
|
||||
internal const string ShowReloadButton = "showReloadButton";
|
||||
internal const string ShowToolbar = "enableBrowserWindowToolbar";
|
||||
internal const string StartUrl = "startURL";
|
||||
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
|
||||
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
|
||||
internal const string UserAgentSuffix = "browserUserAgent";
|
||||
internal const string UseStartUrlQuery = "startURLAppendQueryParameter";
|
||||
internal const string UseTemporaryDownUploadDirectory = "useTemporaryDownUploadDirectory";
|
||||
|
||||
internal static class AdditionalWindow
|
||||
{
|
||||
internal const string AllowAddressBar = "newBrowserWindowAllowAddressBar";
|
||||
internal const string AllowNavigation = "newBrowserWindowNavigation";
|
||||
internal const string AllowReload = "newBrowserWindowAllowReload";
|
||||
internal const string ShowReloadWarning = "newBrowserWindowShowReloadWarning";
|
||||
internal const string UrlPolicy = "newBrowserWindowShowURL";
|
||||
internal const string WindowHeight = "newBrowserWindowByLinkHeight";
|
||||
internal const string WindowWidth = "newBrowserWindowByLinkWidth";
|
||||
internal const string WindowPosition = "newBrowserWindowByLinkPositioning";
|
||||
}
|
||||
|
||||
internal static class Filter
|
||||
{
|
||||
internal const string EnableContentRequestFilter = "URLFilterEnableContentFilter";
|
||||
internal const string EnableMainRequestFilter = "URLFilterEnable";
|
||||
internal const string FilterRules = "URLFilterRules";
|
||||
internal const string RuleAction = "action";
|
||||
internal const string RuleIsActive = "active";
|
||||
internal const string RuleExpression = "expression";
|
||||
internal const string RuleExpressionIsRegex = "regex";
|
||||
}
|
||||
|
||||
internal static class MainWindow
|
||||
{
|
||||
internal const string AllowAddressBar = "browserWindowAllowAddressBar";
|
||||
internal const string AllowNavigation = "allowBrowsingBackForward";
|
||||
internal const string AllowReload = "browserWindowAllowReload";
|
||||
internal const string ShowReloadWarning = "showReloadWarning";
|
||||
internal const string UrlPolicy = "browserWindowShowURL";
|
||||
internal const string WindowHeight = "mainBrowserWindowHeight";
|
||||
internal const string WindowMode = "browserViewMode";
|
||||
internal const string WindowWidth = "mainBrowserWindowWidth";
|
||||
internal const string WindowPosition = "mainBrowserWindowPositioning";
|
||||
}
|
||||
|
||||
internal static class Proxy
|
||||
{
|
||||
internal const string AutoConfigure = "AutoConfigurationEnabled";
|
||||
internal const string AutoConfigureUrl = "AutoConfigurationURL";
|
||||
internal const string AutoDetect = "AutoDiscoveryEnabled";
|
||||
internal const string BypassList = "ExceptionsList";
|
||||
internal const string Policy = "proxySettingsPolicy";
|
||||
internal const string Settings = "proxies";
|
||||
|
||||
internal static class Ftp
|
||||
{
|
||||
internal const string Enable = "FTPEnable";
|
||||
internal const string Host = "FTPProxy";
|
||||
internal const string Password = "FTPPassword";
|
||||
internal const string Port = "FTPPort";
|
||||
internal const string RequiresAuthentication = "FTPRequiresPassword";
|
||||
internal const string Username = "FTPUsername";
|
||||
}
|
||||
|
||||
internal static class Http
|
||||
{
|
||||
internal const string Enable = "HTTPEnable";
|
||||
internal const string Host = "HTTPProxy";
|
||||
internal const string Password = "HTTPPassword";
|
||||
internal const string Port = "HTTPPort";
|
||||
internal const string RequiresAuthentication = "HTTPRequiresPassword";
|
||||
internal const string Username = "HTTPUsername";
|
||||
}
|
||||
|
||||
internal static class Https
|
||||
{
|
||||
internal const string Enable = "HTTPSEnable";
|
||||
internal const string Host = "HTTPSProxy";
|
||||
internal const string Password = "HTTPSPassword";
|
||||
internal const string Port = "HTTPSPort";
|
||||
internal const string RequiresAuthentication = "HTTPSRequiresPassword";
|
||||
internal const string Username = "HTTPSUsername";
|
||||
}
|
||||
|
||||
internal static class Socks
|
||||
{
|
||||
internal const string Enable = "SOCKSEnable";
|
||||
internal const string Host = "SOCKSProxy";
|
||||
internal const string Password = "SOCKSPassword";
|
||||
internal const string Port = "SOCKSPort";
|
||||
internal const string RequiresAuthentication = "SOCKSRequiresPassword";
|
||||
internal const string Username = "SOCKSUsername";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ConfigurationFile
|
||||
{
|
||||
internal const string ConfigurationPurpose = "sebConfigPurpose";
|
||||
internal const string KeepClientConfigEncryption = "clientConfigKeepEncryption";
|
||||
internal const string SessionMode = "sebMode";
|
||||
}
|
||||
|
||||
internal static class Display
|
||||
{
|
||||
internal const string AllowedDisplays = "allowedDisplaysMaxNumber";
|
||||
internal const string AlwaysOn = "displayAlwaysOn";
|
||||
internal const string IgnoreError = "allowedDisplaysIgnoreFailure";
|
||||
internal const string InternalDisplayOnly = "allowedDisplayBuiltinEnforce";
|
||||
}
|
||||
|
||||
internal static class General
|
||||
{
|
||||
internal const string LogLevel = "logLevel";
|
||||
internal const string OriginatorVersion = "originatorVersion";
|
||||
}
|
||||
|
||||
internal static class Keyboard
|
||||
{
|
||||
internal const string EnableAltEsc = "enableAltEsc";
|
||||
internal const string EnableAltTab = "enableAltTab";
|
||||
internal const string EnableAltF4 = "enableAltF4";
|
||||
internal const string EnableCtrlEsc = "enableCtrlEsc";
|
||||
internal const string EnableEsc = "enableEsc";
|
||||
internal const string EnableF1 = "enableF1";
|
||||
internal const string EnableF2 = "enableF2";
|
||||
internal const string EnableF3 = "enableF3";
|
||||
internal const string EnableF4 = "enableF4";
|
||||
internal const string EnableF5 = "enableF5";
|
||||
internal const string EnableF6 = "enableF6";
|
||||
internal const string EnableF7 = "enableF7";
|
||||
internal const string EnableF8 = "enableF8";
|
||||
internal const string EnableF9 = "enableF9";
|
||||
internal const string EnableF10 = "enableF10";
|
||||
internal const string EnableF11 = "enableF11";
|
||||
internal const string EnableF12 = "enableF12";
|
||||
internal const string EnablePrintScreen = "enablePrintScreen";
|
||||
internal const string EnableSystemKey = "enableStartMenu";
|
||||
}
|
||||
|
||||
internal static class Mouse
|
||||
{
|
||||
internal const string EnableMiddleMouseButton = "enableMiddleMouse";
|
||||
internal const string EnableRightMouseButton = "enableRightMouse";
|
||||
}
|
||||
|
||||
internal static class Network
|
||||
{
|
||||
internal static class Certificates
|
||||
{
|
||||
internal const string CertificateData = "certificateData";
|
||||
internal const string CertificateType = "type";
|
||||
internal const string EmbeddedCertificates = "embeddedCertificates";
|
||||
}
|
||||
}
|
||||
|
||||
internal static class Proctoring
|
||||
{
|
||||
internal const string ForceRaiseHandMessage = "raiseHandButtonAlwaysPromptMessage";
|
||||
internal const string ShowRaiseHand = "raiseHandButtonShow";
|
||||
internal const string ShowTaskbarNotification = "showProctoringViewButton";
|
||||
|
||||
internal static class ScreenProctoring
|
||||
{
|
||||
internal const string ClientId = "screenProctoringClientId";
|
||||
internal const string ClientSecret = "screenProctoringClientSecret";
|
||||
internal const string Enabled = "enableScreenProctoring";
|
||||
internal const string GroupId = "screenProctoringGroupId";
|
||||
internal const string ImageDownscaling = "screenProctoringImageDownscale";
|
||||
internal const string ImageFormat = "screenProctoringImageFormat";
|
||||
internal const string ImageQuantization = "screenProctoringImageQuantization";
|
||||
internal const string MaxInterval = "screenProctoringScreenshotMaxInterval";
|
||||
internal const string MinInterval = "screenProctoringScreenshotMinInterval";
|
||||
internal const string ServiceUrl = "screenProctoringServiceURL";
|
||||
|
||||
internal static class MetaData
|
||||
{
|
||||
internal const string CaptureApplicationData = "screenProctoringMetadataActiveAppEnabled";
|
||||
internal const string CaptureBrowserData = "screenProctoringMetadataURLEnabled";
|
||||
internal const string CaptureWindowTitle = "screenProctoringMetadataWindowTitleEnabled";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class Security
|
||||
{
|
||||
internal const string AdminPasswordHash = "hashedAdminPassword";
|
||||
internal const string AllowApplicationLog = "allowApplicationLog";
|
||||
internal const string AllowReconfiguration = "examSessionReconfigureAllow";
|
||||
internal const string AllowStickyKeys = "allowStickyKeys";
|
||||
internal const string AllowTermination = "allowQuit";
|
||||
internal const string AllowVirtualMachine = "allowVirtualMachine";
|
||||
internal const string ClipboardPolicy = "clipboardPolicy";
|
||||
internal const string DisableSessionChangeLockScreen = "disableSessionChangeLockScreen";
|
||||
internal const string KioskModeCreateNewDesktop = "createNewDesktop";
|
||||
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
|
||||
internal const string QuitPasswordHash = "hashedQuitPassword";
|
||||
internal const string ReconfigurationUrl = "examSessionReconfigureConfigURL";
|
||||
internal const string VerifyCursorConfiguration = "enableCursorVerification";
|
||||
internal const string VerifySessionIntegrity = "enableSessionVerification";
|
||||
internal const string VersionRestrictions = "sebAllowedVersions";
|
||||
}
|
||||
|
||||
internal static class Server
|
||||
{
|
||||
internal const string ApiUrl = "apiDiscovery";
|
||||
internal const string ClientName = "clientName";
|
||||
internal const string ClientSecret = "clientSecret";
|
||||
internal const string Configuration = "sebServerConfiguration";
|
||||
internal const string ExamId = "exam";
|
||||
internal const string FallbackPasswordHash = "sebServerFallbackPasswordHash";
|
||||
internal const string Institution = "institution";
|
||||
internal const string PerformFallback = "sebServerFallback";
|
||||
internal const string PingInterval = "pingInterval";
|
||||
internal const string RequestAttempts = "sebServerFallbackAttempts";
|
||||
internal const string RequestAttemptInterval = "sebServerFallbackAttemptInterval";
|
||||
internal const string RequestTimeout = "sebServerFallbackTimeout";
|
||||
internal const string ServerUrl = "sebServerURL";
|
||||
}
|
||||
|
||||
internal static class Service
|
||||
{
|
||||
internal const string EnableChromeNotifications = "enableChromeNotifications";
|
||||
internal const string EnableEaseOfAccessOptions = "insideSebEnableEaseOfAccess";
|
||||
internal const string EnableFindPrinter = "enableFindPrinter";
|
||||
internal const string EnableNetworkOptions = "insideSebEnableNetworkConnectionSelector";
|
||||
internal const string EnablePasswordChange = "insideSebEnableChangeAPassword";
|
||||
internal const string EnablePowerOptions = "insideSebEnableShutDown";
|
||||
internal const string EnableRemoteConnections = "allowScreenSharing";
|
||||
internal const string EnableSignout = "insideSebEnableLogOff";
|
||||
internal const string EnableTaskManager = "insideSebEnableStartTaskManager";
|
||||
internal const string EnableUserLock = "insideSebEnableLockThisComputer";
|
||||
internal const string EnableUserSwitch = "insideSebEnableSwitchUser";
|
||||
internal const string EnableVmwareOverlay = "insideSebEnableVmWareClientShade";
|
||||
internal const string EnableWindowsUpdate = "enableWindowsUpdate";
|
||||
internal const string IgnoreService = "sebServiceIgnore";
|
||||
internal const string Policy = "sebServicePolicy";
|
||||
internal const string SetVmwareConfiguration = "setVmwareConfiguration";
|
||||
}
|
||||
|
||||
internal static class System
|
||||
{
|
||||
internal const string AlwaysOn = "systemAlwaysOn";
|
||||
}
|
||||
|
||||
internal static class UserInterface
|
||||
{
|
||||
internal const string UserInterfaceMode = "touchOptimized";
|
||||
|
||||
internal static class ActionCenter
|
||||
{
|
||||
internal const string EnableActionCenter = "showSideMenu";
|
||||
}
|
||||
|
||||
internal static class LockScreen
|
||||
{
|
||||
internal const string BackgroundColor = "lockScreenBackgroundColor";
|
||||
}
|
||||
|
||||
internal static class SystemControls
|
||||
{
|
||||
internal static class Audio
|
||||
{
|
||||
internal const string Show = "audioControlEnabled";
|
||||
}
|
||||
|
||||
internal static class Clock
|
||||
{
|
||||
internal const string Show = "showTime";
|
||||
}
|
||||
|
||||
internal static class KeyboardLayout
|
||||
{
|
||||
internal const string Show = "showInputLanguage";
|
||||
}
|
||||
|
||||
internal static class Network
|
||||
{
|
||||
internal const string Show = "allowWlan";
|
||||
}
|
||||
|
||||
internal static class PowerSupply
|
||||
{
|
||||
internal const string ChargeThresholdCritical = "batteryChargeThresholdCritical";
|
||||
internal const string ChargeThresholdLow = "batteryChargeThresholdLow";
|
||||
}
|
||||
}
|
||||
|
||||
internal static class Taskbar
|
||||
{
|
||||
internal const string EnableTaskbar = "showTaskBar";
|
||||
internal const string ShowApplicationLog = "showApplicationLogButton";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user