Skip to content

Commit 3dd023b

Browse files
committed
SEBWIN-643: Implemented version restriction functionality.
1 parent 543ad70 commit 3dd023b

File tree

20 files changed

+713
-296
lines changed

20 files changed

+713
-296
lines changed

SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SecurityDataMapper.cs

+35
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
88

9+
using System;
910
using System.Collections.Generic;
11+
using System.Linq;
1012
using SafeExamBrowser.Settings;
1113
using SafeExamBrowser.Settings.Security;
1214

@@ -36,6 +38,9 @@ internal override void Map(string key, object value, AppSettings settings)
3638
case Keys.Security.ReconfigurationUrl:
3739
MapReconfigurationUrl(settings, value);
3840
break;
41+
case Keys.Security.VersionRestrictions:
42+
MapVersionRestrictions(settings, value);
43+
break;
3944
}
4045
}
4146

@@ -133,5 +138,35 @@ private void MapReconfigurationUrl(AppSettings settings, object value)
133138
settings.Security.ReconfigurationUrl = url;
134139
}
135140
}
141+
142+
private void MapVersionRestrictions(AppSettings settings, object value)
143+
{
144+
if (value is IList<object> restrictions)
145+
{
146+
foreach (var restriction in restrictions.Cast<string>())
147+
{
148+
var parts = restriction.Split('.');
149+
var os = parts.Length > 0 ? parts[0] : default;
150+
151+
if (os?.Equals("win", StringComparison.OrdinalIgnoreCase) == true)
152+
{
153+
var major = parts.Length > 1 ? int.Parse(parts[1]) : default;
154+
var minor = parts.Length > 2 ? int.Parse(parts[2]) : default;
155+
var patch = parts.Length > 3 && int.TryParse(parts[3], out _) ? int.Parse(parts[3]) : default(int?);
156+
var build = parts.Length > 4 && int.TryParse(parts[4], out _) ? int.Parse(parts[4]) : default(int?);
157+
158+
settings.Security.VersionRestrictions.Add(new VersionRestriction
159+
{
160+
Major = major,
161+
Minor = minor,
162+
Patch = patch,
163+
Build = build,
164+
IsMinimumRestriction = restriction.Contains("min"),
165+
RequiresAllianceEdition = restriction.Contains("AE")
166+
});
167+
}
168+
}
169+
}
170+
}
136171
}
137172
}

SafeExamBrowser.Configuration/ConfigurationData/Keys.cs

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ internal static class Security
285285
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
286286
internal const string QuitPasswordHash = "hashedQuitPassword";
287287
internal const string ReconfigurationUrl = "examSessionReconfigureConfigURL";
288+
internal const string VersionRestrictions = "sebAllowedVersions";
288289
}
289290

290291
internal static class Server

SafeExamBrowser.I18n.Contracts/TextKey.cs

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public enum TextKey
157157
MessageBox_UnexpectedConfigurationErrorTitle,
158158
MessageBox_UploadNotAllowed,
159159
MessageBox_UploadNotAllowedTitle,
160+
MessageBox_VersionRestrictionError,
161+
MessageBox_VersionRestrictionErrorTitle,
162+
MessageBox_VersionRestrictionMinimum,
160163
MessageBox_VirtualMachineNotAllowed,
161164
MessageBox_VirtualMachineNotAllowedTitle,
162165
MessageBox_YesButton,
@@ -202,6 +205,7 @@ public enum TextKey
202205
OperationStatus_TerminateShell,
203206
OperationStatus_ValidateDisplayConfiguration,
204207
OperationStatus_ValidateRemoteSessionPolicy,
208+
OperationStatus_ValidateVersionRestrictions,
205209
OperationStatus_ValidateVirtualMachinePolicy,
206210
OperationStatus_VerifyApplicationIntegrity,
207211
OperationStatus_VerifySessionIntegrity,

SafeExamBrowser.I18n/Data/de.xml

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@
429429
<Entry key="MessageBox_UploadNotAllowedTitle">
430430
Hochladen nicht erlaubt!
431431
</Entry>
432+
<Entry key="MessageBox_VersionRestrictionError">
433+
Die installierte SEB-Version %%_VERSION_%% kann nicht verwendet werden, da die ausgewählte Konfiguration die Verwendung einer bestimmten Version erfordert:%%_REQUIRED_VERSIONS_%%Bitte laden Sie die erforderliche Version von der offiziellen Website (safeexambrowser.org/download) oder aus dem Repository von SEB für Windows auf GitHub (github.com/safeexambrowser) herunter und installieren Sie diese.
434+
</Entry>
435+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
436+
Ungültige SEB-Version
437+
</Entry>
438+
<Entry key="MessageBox_VersionRestrictionMinimum">
439+
SEB %%_VERSION_%% oder neuer
440+
</Entry>
432441
<Entry key="MessageBox_VirtualMachineNotAllowed">
433442
Dieser Computer scheint eine virtuelle Maschine zu sein. Die ausgewählte Konfiguration erlaubt es nicht, SEB in einer virtuellen Maschine auszuführen.
434443
</Entry>
@@ -564,6 +573,9 @@
564573
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
565574
Validiere Richtlinie für Remote-Sitzungen
566575
</Entry>
576+
<Entry key="OperationStatus_ValidateVersionRestrictions">
577+
Validiere Versionsbeschränkungen
578+
</Entry>
567579
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
568580
Validiere Richtlinie für virtuelle Maschinen
569581
</Entry>

SafeExamBrowser.I18n/Data/en.xml

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@
429429
<Entry key="MessageBox_UploadNotAllowedTitle">
430430
Uploading Not Allowed!
431431
</Entry>
432+
<Entry key="MessageBox_VersionRestrictionError">
433+
The installed SEB version %%_VERSION_%% cannot be used as the selected configuration requires to use a specific version:%%_REQUIRED_VERSIONS_%%Please download and install the required version from the official website (safeexambrowser.org/download) or from the repository of SEB for Windows on GitHub (github.com/safeexambrowser).
434+
</Entry>
435+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
436+
Invalid SEB Version
437+
</Entry>
438+
<Entry key="MessageBox_VersionRestrictionMinimum">
439+
SEB %%_VERSION_%% or newer
440+
</Entry>
432441
<Entry key="MessageBox_VirtualMachineNotAllowed">
433442
This computer appears to be a virtual machine. The selected configuration does not allow SEB to be run in a virtual machine.
434443
</Entry>
@@ -564,6 +573,9 @@
564573
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
565574
Validating remote session policy
566575
</Entry>
576+
<Entry key="OperationStatus_ValidateVersionRestrictions">
577+
Validating version restrictions
578+
</Entry>
567579
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
568580
Validating virtual machine policy
569581
</Entry>

SafeExamBrowser.I18n/Data/es.xml

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@
429429
<Entry key="MessageBox_UploadNotAllowedTitle">
430430
Uploading Not Allowed!
431431
</Entry>
432+
<Entry key="MessageBox_VersionRestrictionError">
433+
La versión instalada de SEB %%_VERSION_%% no puede ser utilizada ya que la configuración seleccionada requiere utilizar una versión específica:%%_REQUIRED_VERSIONS_%%Por favor descargue e instale la versión requerida desde el sitio web oficial (safeexambrowser.org/download) o desde el repositorio de SEB para Windows en GitHub (github.com/safeexambrowser).
434+
</Entry>
435+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
436+
Versión SEB no válida
437+
</Entry>
438+
<Entry key="MessageBox_VersionRestrictionMinimum">
439+
SEB %%_VERSION_%% o más reciente
440+
</Entry>
432441
<Entry key="MessageBox_VirtualMachineNotAllowed">
433442
Este ordenador parece ser una máquina virtual. La configuración seleccionada no permite ejecutar SEB en una máquina virtual.
434443
</Entry>
@@ -564,6 +573,9 @@
564573
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
565574
Validación de la política de sesión remota
566575
</Entry>
576+
<Entry key="OperationStatus_ValidateVersionRestrictions">
577+
Validación de las restricciones de versión
578+
</Entry>
567579
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
568580
Validación de la política de máquinas virtuales
569581
</Entry>

SafeExamBrowser.I18n/Data/fr.xml

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@
429429
<Entry key="MessageBox_UploadNotAllowedTitle">
430430
Téléchargement non autorisé!
431431
</Entry>
432+
<Entry key="MessageBox_VersionRestrictionError">
433+
La version SEB installée %%_VERSION_%% ne peut pas être utilisée car la configuration sélectionnée nécessite l'utilisation d'une version spécifique:%%_REQUIRED_VERSIONS_%%Veuillez télécharger et installer la version requise depuis le site officiel (safeexambrowser.org/download) ou depuis le dépôt de SEB pour Windows sur GitHub (github.com/safeexambrowser).
434+
</Entry>
435+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
436+
Version SEB non valide
437+
</Entry>
438+
<Entry key="MessageBox_VersionRestrictionMinimum">
439+
SEB %%_VERSION_%% ou plus récent
440+
</Entry>
432441
<Entry key="MessageBox_VirtualMachineNotAllowed">
433442
Cet ordinateur semble être une machine virtuelle. La configuration sélectionnée ne permet pas à SEB de fonctionner dans une machine virtuelle.
434443
</Entry>
@@ -564,6 +573,9 @@
564573
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
565574
Validation de la directive sur la session à distance
566575
</Entry>
576+
<Entry key="OperationStatus_ValidateVersionRestrictions">
577+
Validation des restrictions de version
578+
</Entry>
567579
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
568580
Validation de la directive sur les machines virtuelles
569581
</Entry>

SafeExamBrowser.I18n/Data/it.xml

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@
429429
<Entry key="MessageBox_UploadNotAllowedTitle">
430430
Upload non consentito!
431431
</Entry>
432+
<Entry key="MessageBox_VersionRestrictionError">
433+
La versione di SEB installata %%_VERSION_%% non può essere usata perché la configurazione selezionata richiede l'uso di una versione specifica:%%_REQUIRED_VERSIONS_%%Si prega di scaricare e installare la versione richiesta dal sito ufficiale (safeexambrowser.org/download) o dal repository di SEB per Windows su GitHub (github.com/safeexambrowser).
434+
</Entry>
435+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
436+
Versione SEB non valida
437+
</Entry>
438+
<Entry key="MessageBox_VersionRestrictionMinimum">
439+
SEB %%_VERSION_%% o più recente
440+
</Entry>
432441
<Entry key="MessageBox_VirtualMachineNotAllowed">
433442
Questo computer sembra essere una macchina virtuale. La configurazione selezionata non consente l'esecuzione di SEB in una macchina virtuale.
434443
</Entry>
@@ -564,6 +573,9 @@
564573
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
565574
Convalida dei criteri della sessione remota
566575
</Entry>
576+
<Entry key="OperationStatus_ValidateVersionRestrictions">
577+
Convalida delle restrizioni di versione
578+
</Entry>
567579
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
568580
Convalida dei criteri della macchina virtuale
569581
</Entry>

SafeExamBrowser.I18n/Data/zh.xml

+12
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,15 @@
393393
<Entry key="MessageBox_UploadNotAllowedTitle">
394394
不允许上传!
395395
</Entry>
396+
<Entry key="MessageBox_VersionRestrictionError">
397+
已安装的 SEB 版本 %%_VERSION_%% 不能使用,因为所选配置需要使用特定的版本:%%_REQUIRED_VERSIONS_%%请从官方网站(safeexambrowser.org/download)或 GitHub 上的 SEB for Windows 仓库(github.com/safeexambrowser)下载并安装所需的版本。
398+
</Entry>
399+
<Entry key="MessageBox_VersionRestrictionErrorTitle">
400+
无效的 SEB 版本
401+
</Entry>
402+
<Entry key="MessageBox_VersionRestrictionMinimum">
403+
SEB %%_VERSION_%% 或更新的版本
404+
</Entry>
396405
<Entry key="MessageBox_VirtualMachineNotAllowed">
397406
这台电脑是一个虚拟机。所选配置不允许防作弊考试专用浏览器在虚拟机中运行。
398407
</Entry>
@@ -519,6 +528,9 @@
519528
<Entry key="OperationStatus_ValidateRemoteSessionPolicy">
520529
验证远程会话策略
521530
</Entry>
531+
<Entry key="OperationStatus_ValidateVersionRestrictions">
532+
验证版本限制
533+
</Entry>
522534
<Entry key="OperationStatus_ValidateVirtualMachinePolicy">
523535
验证虚拟机策略
524536
</Entry>

SafeExamBrowser.Runtime/CompositionRoot.cs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ internal void BuildObjectGraph(Action shutdown)
9595
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext));
9696
sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext));
9797
sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server));
98+
sessionOperations.Enqueue(new VersionRestrictionOperation(logger, sessionContext, text));
9899
sessionOperations.Enqueue(new DisclaimerOperation(logger, sessionContext));
99100
sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext));
100101
sessionOperations.Enqueue(new SessionIntegrityOperation(logger, registry, sessionContext));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2023 ETH Zürich, Educational Development and Technology (LET)
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
using SafeExamBrowser.I18n.Contracts;
10+
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
11+
12+
namespace SafeExamBrowser.Runtime.Operations.Events
13+
{
14+
internal class VersionRestrictionMessageArgs : MessageEventArgs
15+
{
16+
internal VersionRestrictionMessageArgs(string version, string requiredVersions)
17+
{
18+
Icon = MessageBoxIcon.Error;
19+
Message = TextKey.MessageBox_VersionRestrictionError;
20+
MessagePlaceholders["%%_VERSION_%%"] = version;
21+
MessagePlaceholders["%%_REQUIRED_VERSIONS_%%"] = requiredVersions;
22+
Title = TextKey.MessageBox_VersionRestrictionErrorTitle;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)