diff --git a/SafeExamBrowser.Configuration.UnitTests/ConfigurationRepositoryTests.cs b/SafeExamBrowser.Configuration.UnitTests/ConfigurationRepositoryTests.cs
index 777a1515..133e25e8 100644
--- a/SafeExamBrowser.Configuration.UnitTests/ConfigurationRepositoryTests.cs
+++ b/SafeExamBrowser.Configuration.UnitTests/ConfigurationRepositoryTests.cs
@@ -331,7 +331,7 @@ namespace SafeExamBrowser.Configuration.UnitTests
}
///
- /// Hack required for unit tests to be able to retrieve the while executing.
+ /// Required for unit tests to be able to retrieve the while executing.
///
public void SetEntryAssembly()
{
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ConfigurationFileDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ConfigurationFileDataMapper.cs
index f0b69393..f765d829 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ConfigurationFileDataMapper.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ConfigurationFileDataMapper.cs
@@ -19,6 +19,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
case Keys.ConfigurationFile.ConfigurationPurpose:
MapConfigurationMode(settings, value);
break;
+ case Keys.ConfigurationFile.SessionMode:
+ MapSessionMode(settings, value);
+ break;
}
}
@@ -31,5 +34,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
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;
+ }
+ }
}
}
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SecurityDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SecurityDataMapper.cs
index 93a654a6..0fe20938 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SecurityDataMapper.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SecurityDataMapper.cs
@@ -18,7 +18,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
{
switch (key)
{
- case Keys.ConfigurationFile.AdminPasswordHash:
+ case Keys.Security.AdminPasswordHash:
MapAdminPasswordHash(settings, value);
break;
case Keys.Security.AllowTermination:
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ServerDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ServerDataMapper.cs
new file mode 100644
index 00000000..3c0523a2
--- /dev/null
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ServerDataMapper.cs
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+using System.Collections.Generic;
+using SafeExamBrowser.Settings;
+
+namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
+{
+ internal 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 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.Institution, out v) && v is string institution)
+ {
+ settings.Server.Institution = institution;
+ }
+ }
+ }
+
+ private void MapFallbackPasswordHash(AppSettings settings, object value)
+ {
+ if (value is string hash)
+ {
+ settings.Server.FallbackPasswordHash = hash;
+ }
+ }
+
+ 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;
+ }
+ }
+ }
+}
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
index 796f7e78..b97614cc 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs
@@ -172,6 +172,11 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
+ settings.Server.RequestAttemptInterval = 2000;
+ settings.Server.RequestAttempts = 5;
+ settings.Server.RequestTimeout = 5000;
+ settings.Server.PerformFallback = false;
+
settings.Service.DisableChromeNotifications = true;
settings.Service.DisableEaseOfAccessOptions = true;
settings.Service.DisableNetworkOptions = true;
@@ -188,6 +193,8 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
settings.Service.Policy = ServicePolicy.Mandatory;
settings.Service.SetVmwareConfiguration = false;
+ settings.SessionMode = SessionMode.Normal;
+
settings.Taskbar.EnableTaskbar = true;
settings.Taskbar.ShowApplicationInfo = false;
settings.Taskbar.ShowApplicationLog = false;
diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
index ee62f01a..9054a9f8 100644
--- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
@@ -156,9 +156,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal static class ConfigurationFile
{
- internal const string AdminPasswordHash = "hashedAdminPassword";
internal const string ConfigurationPurpose = "sebConfigPurpose";
internal const string KeepClientConfigEncryption = "clientConfigKeepEncryption";
+ internal const string SessionMode = "sebMode";
}
internal static class General
@@ -207,6 +207,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal static class Security
{
+ internal const string AdminPasswordHash = "hashedAdminPassword";
internal const string AllowApplicationLog = "allowApplicationLog";
internal const string AllowTermination = "allowQuit";
internal const string AllowVirtualMachine = "allowVirtualMachine";
@@ -215,6 +216,21 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal const string QuitPasswordHash = "hashedQuitPassword";
}
+ 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 FallbackPasswordHash = "sebServerFallbackPasswordHash";
+ internal const string Institution = "institution";
+ internal const string PerformFallback = "sebServerFallback";
+ 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";
diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj
index be9324c2..2f52f6ef 100644
--- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj
+++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj
@@ -64,6 +64,7 @@
+
diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs
index 15f3c3e1..87df6690 100644
--- a/SafeExamBrowser.Runtime/CompositionRoot.cs
+++ b/SafeExamBrowser.Runtime/CompositionRoot.cs
@@ -80,6 +80,7 @@ namespace SafeExamBrowser.Runtime
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext));
+ // TODO: sessionOperations.Enqueue(new ServerOperation());
sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
diff --git a/SafeExamBrowser.Settings/AppSettings.cs b/SafeExamBrowser.Settings/AppSettings.cs
index 51cbcb87..25e7cd4a 100644
--- a/SafeExamBrowser.Settings/AppSettings.cs
+++ b/SafeExamBrowser.Settings/AppSettings.cs
@@ -12,6 +12,7 @@ using SafeExamBrowser.Settings.Browser;
using SafeExamBrowser.Settings.Logging;
using SafeExamBrowser.Settings.Monitoring;
using SafeExamBrowser.Settings.Security;
+using SafeExamBrowser.Settings.Server;
using SafeExamBrowser.Settings.Service;
using SafeExamBrowser.Settings.SystemComponents;
using SafeExamBrowser.Settings.UserInterface;
@@ -69,11 +70,21 @@ namespace SafeExamBrowser.Settings
///
public SecuritySettings Security { get; set; }
+ ///
+ /// All server-related settings.
+ ///
+ public ServerSettings Server { get; set; }
+
///
/// All service-related settings.
///
public ServiceSettings Service { get; set; }
+ ///
+ /// The mode which determines the session behaviour.
+ ///
+ public SessionMode SessionMode { get; set; }
+
///
/// All taskbar-related settings.
///
@@ -93,6 +104,7 @@ namespace SafeExamBrowser.Settings
Keyboard = new KeyboardSettings();
Mouse = new MouseSettings();
Security = new SecuritySettings();
+ Server = new ServerSettings();
Service = new ServiceSettings();
Taskbar = new TaskbarSettings();
}
diff --git a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj
index 1e019db2..138fc18c 100644
--- a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj
+++ b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj
@@ -70,6 +70,7 @@
+
@@ -77,6 +78,7 @@
+
diff --git a/SafeExamBrowser.Settings/Server/ServerSettings.cs b/SafeExamBrowser.Settings/Server/ServerSettings.cs
new file mode 100644
index 00000000..90212f72
--- /dev/null
+++ b/SafeExamBrowser.Settings/Server/ServerSettings.cs
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+using System;
+
+namespace SafeExamBrowser.Settings.Server
+{
+ ///
+ /// Defines all settings for a SEB server.
+ ///
+ [Serializable]
+ public class ServerSettings
+ {
+ ///
+ /// The discovery URL for the API of the server.
+ ///
+ public string ApiUrl { get; set; }
+
+ ///
+ /// The client name for initial authentication with the server.
+ ///
+ public string ClientName { get; set; }
+
+ ///
+ /// The client secret for initial authentication with the server.
+ ///
+ public string ClientSecret { get; set; }
+
+ ///
+ /// The hash code of the password required to perform a fallback.
+ ///
+ public string FallbackPasswordHash { get; set; }
+
+ ///
+ /// The institution to be used for identification with the server.
+ ///
+ public string Institution { get; set; }
+
+ ///
+ /// Indicates whether SEB will fallback to the start URL in case no connection could be established with the server.
+ ///
+ public bool PerformFallback { get; set; }
+
+ ///
+ /// The number of attempts (e.g. when receiving an invalid server response) before performing a fallback or failing.
+ ///
+ public int RequestAttempts { get; set; }
+
+ ///
+ /// The time interval in milliseconds to be waited in between attempts.
+ ///
+ public int RequestAttemptInterval { get; set; }
+
+ ///
+ /// The timeout in milliseconds (e.g. to wait for a server response) before performing a fallback or failing.
+ ///
+ public int RequestTimeout { get; set; }
+
+ ///
+ /// The URL of the server.
+ ///
+ public string ServerUrl { get; set; }
+ }
+}
diff --git a/SafeExamBrowser.Settings/SessionMode.cs b/SafeExamBrowser.Settings/SessionMode.cs
new file mode 100644
index 00000000..a52ec067
--- /dev/null
+++ b/SafeExamBrowser.Settings/SessionMode.cs
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+namespace SafeExamBrowser.Settings
+{
+ ///
+ /// Defines all possible session modes.
+ ///
+ public enum SessionMode
+ {
+ ///
+ /// SEB will start a normal session without SEB server.
+ ///
+ Normal,
+
+ ///
+ /// SEB will start a session with SEB server.
+ ///
+ Server
+ }
+}