diff --git a/SafeExamBrowser.I18n.Contracts/TextKey.cs b/SafeExamBrowser.I18n.Contracts/TextKey.cs index d532e4ca..397f98bb 100644 --- a/SafeExamBrowser.I18n.Contracts/TextKey.cs +++ b/SafeExamBrowser.I18n.Contracts/TextKey.cs @@ -108,6 +108,8 @@ namespace SafeExamBrowser.I18n.Contracts MessageBox_ReconfigurationErrorTitle, MessageBox_ReloadConfirmation, MessageBox_ReloadConfirmationTitle, + MessageBox_RemoteSessionNotAllowed, + MessageBox_RemoteSessionNotAllowedTitle, MessageBox_ServiceUnavailableError, MessageBox_ServiceUnavailableErrorTitle, MessageBox_ServiceUnavailableWarning, @@ -155,6 +157,7 @@ namespace SafeExamBrowser.I18n.Contracts OperationStatus_StopMouseInterception, OperationStatus_TerminateBrowser, OperationStatus_TerminateShell, + OperationStatus_ValidateRemoteSessionPolicy, OperationStatus_ValidateVirtualMachinePolicy, OperationStatus_WaitExplorerStartup, OperationStatus_WaitExplorerTermination, diff --git a/SafeExamBrowser.I18n/Data/cn.xml b/SafeExamBrowser.I18n/Data/cn.xml index 451de43c..58a58e42 100644 --- a/SafeExamBrowser.I18n/Data/cn.xml +++ b/SafeExamBrowser.I18n/Data/cn.xml @@ -246,6 +246,12 @@ 刷新? + + 系统似乎正在远程会话中运行。所选的配置不允许SEB在远程会话中运行。 + + + 检测到远程会话 + 防作弊考试专用浏览器服务初始化失败。防作弊考试专用浏览器现将终止,因为该服务被配置为强制项。 @@ -375,6 +381,9 @@ 终止用户界面 + + 验证远程会话策略 + 验证虚拟机策略 diff --git a/SafeExamBrowser.I18n/Data/de.xml b/SafeExamBrowser.I18n/Data/de.xml index 1beca4d2..759018c7 100644 --- a/SafeExamBrowser.I18n/Data/de.xml +++ b/SafeExamBrowser.I18n/Data/de.xml @@ -282,6 +282,12 @@ Neu laden? + + Das System scheint in einer Remote-Sitzung zu laufen. Die ausgewählte Konfiguration erlaubt es nicht, SEB in einer Remote-Sitzung auszuführen. + + + Remote-Sitzung erkannt + Fehler beim Initialisieren des SEB-Service! SEB wird sich nun beenden da der Service als obligatorisch konfiguriert ist. @@ -423,6 +429,9 @@ Beende Benutzeroberfläche + + Validiere Richtlinie für Remote-Sitzungen + Validiere Richtlinie für virtuelle Maschinen diff --git a/SafeExamBrowser.I18n/Data/en.xml b/SafeExamBrowser.I18n/Data/en.xml index 42358ee4..b453e229 100644 --- a/SafeExamBrowser.I18n/Data/en.xml +++ b/SafeExamBrowser.I18n/Data/en.xml @@ -282,6 +282,12 @@ Reload? + + The system appears to be running in a remote session. The selected configuration does not allow SEB to be run in a remote session. + + + Remote Session Detected + Failed to initialize the SEB service! SEB will now terminate since the service is configured to be mandatory. @@ -423,6 +429,9 @@ Terminating user interface + + Validating remote session policy + Validating virtual machine policy diff --git a/SafeExamBrowser.I18n/Data/fr.xml b/SafeExamBrowser.I18n/Data/fr.xml index 2c6a9cdb..424fc883 100644 --- a/SafeExamBrowser.I18n/Data/fr.xml +++ b/SafeExamBrowser.I18n/Data/fr.xml @@ -282,6 +282,12 @@ Recharger ? + + Le système semble s'exécuter dans une session à distance. La configuration sélectionnée ne permet pas l'exécution de SEB dans une session à distance. + + + Session distante détectée + Le service SEB n'a pas été initialisé ! Le service SEB va maintenant se terminer puisque le service obligatoire. @@ -423,6 +429,9 @@ Arrêt de l’interface utilisateur + + Validation de la directive sur la session à distance + Validation de la directive sur les machines virtuelles diff --git a/SafeExamBrowser.I18n/Data/it.xml b/SafeExamBrowser.I18n/Data/it.xml index 702c3f43..d809ccc7 100644 --- a/SafeExamBrowser.I18n/Data/it.xml +++ b/SafeExamBrowser.I18n/Data/it.xml @@ -282,6 +282,12 @@ Ricaricare? + + Il sistema sembra essere in esecuzione in una sessione remota. La configurazione selezionata non consente l'esecuzione di SEB in una sessione remota. + + + Sessione remota rilevata + Impossibile inizializzare il servizio SEB! SEB verrà ora terminato poiché il servizio è configurato per essere obbligatorio. @@ -423,6 +429,9 @@ Chiusura dell'interfaccia utente + + Convalida dei criteri della sessione remota + Convalida dei criteri della macchina virtuale diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index ab4c5009..9ff808d4 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -66,6 +66,7 @@ namespace SafeExamBrowser.Runtime var fileSystem = new FileSystem(); var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory))); + var remoteSessionDetector = new RemoteSessionDetector(ModuleLogger(nameof(RemoteSessionDetector))); var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS); var runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig); var server = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy))); @@ -84,6 +85,7 @@ namespace SafeExamBrowser.Runtime sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext)); sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext)); sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server)); + sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext)); 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.Runtime/Operations/RemoteSessionOperation.cs b/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs new file mode 100644 index 00000000..67dc6260 --- /dev/null +++ b/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs @@ -0,0 +1,71 @@ +/* + * 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 SafeExamBrowser.Core.Contracts.OperationModel; +using SafeExamBrowser.Core.Contracts.OperationModel.Events; +using SafeExamBrowser.I18n.Contracts; +using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Runtime.Operations.Events; +using SafeExamBrowser.SystemComponents.Contracts; +using SafeExamBrowser.UserInterface.Contracts.MessageBox; + +namespace SafeExamBrowser.Runtime.Operations +{ + internal class RemoteSessionOperation : SessionOperation + { + private readonly IRemoteSessionDetector detector; + private readonly ILogger logger; + + public override event ActionRequiredEventHandler ActionRequired; + public override event StatusChangedEventHandler StatusChanged; + + public RemoteSessionOperation(IRemoteSessionDetector detector, ILogger logger, SessionContext context) : base(context) + { + this.detector = detector; + this.logger = logger; + } + + public override OperationResult Perform() + { + return ValidatePolicy(); + } + + public override OperationResult Repeat() + { + return ValidatePolicy(); + } + + public override OperationResult Revert() + { + return OperationResult.Success; + } + + private OperationResult ValidatePolicy() + { + logger.Info($"Validating remote session policy..."); + StatusChanged?.Invoke(TextKey.OperationStatus_ValidateRemoteSessionPolicy); + + if (Context.Next.Settings.Service.DisableRemoteConnections && detector.IsRemoteSession()) + { + var args = new MessageEventArgs + { + Icon = MessageBoxIcon.Error, + Message = TextKey.MessageBox_RemoteSessionNotAllowed, + Title = TextKey.MessageBox_RemoteSessionNotAllowedTitle + }; + + logger.Error("Detected remote session while SEB is not allowed to be run in a remote session! Aborting..."); + ActionRequired?.Invoke(args); + + return OperationResult.Aborted; + } + + return OperationResult.Success; + } + } +} diff --git a/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs b/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs index d06c40f0..3e03f282 100644 --- a/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs @@ -22,15 +22,15 @@ namespace SafeExamBrowser.Runtime.Operations private IVirtualMachineDetector detector; private ILogger logger; + public override event ActionRequiredEventHandler ActionRequired; + public override event StatusChangedEventHandler StatusChanged; + public VirtualMachineOperation(IVirtualMachineDetector detector, ILogger logger, SessionContext context) : base(context) { this.detector = detector; this.logger = logger; } - public override event ActionRequiredEventHandler ActionRequired; - public override event StatusChangedEventHandler StatusChanged; - public override OperationResult Perform() { return ValidatePolicy(); diff --git a/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj b/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj index 0e6d4628..ce42538d 100644 --- a/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj +++ b/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj @@ -103,6 +103,7 @@ + diff --git a/SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs b/SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs new file mode 100644 index 00000000..5c387581 --- /dev/null +++ b/SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs @@ -0,0 +1,21 @@ +/* + * 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.SystemComponents.Contracts +{ + /// + /// Provides functionality related to remote session detection. + /// + public interface IRemoteSessionDetector + { + /// + /// Indicates whether the system is currently running in a remote session. + /// + bool IsRemoteSession(); + } +} diff --git a/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj b/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj index 4e4c33de..fe9584ab 100644 --- a/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj +++ b/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj @@ -57,6 +57,7 @@ + diff --git a/SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs b/SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs new file mode 100644 index 00000000..26c4cfce --- /dev/null +++ b/SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs @@ -0,0 +1,33 @@ +/* + * 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.Windows.Forms; +using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.SystemComponents.Contracts; + +namespace SafeExamBrowser.SystemComponents +{ + public class RemoteSessionDetector : IRemoteSessionDetector + { + private readonly ILogger logger; + + public RemoteSessionDetector(ILogger logger) + { + this.logger = logger; + } + + public bool IsRemoteSession() + { + var isRemoteSession = SystemInformation.TerminalServerSession; + + logger.Debug($"System appears {(isRemoteSession ? "" : "not ")}to be running in a remote session."); + + return isRemoteSession; + } + } +} diff --git a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj index b32e383c..5b48d17d 100644 --- a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj +++ b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj @@ -70,6 +70,7 @@ +