SEBWIN-447: Implemented missing remote session check during session initialization.
This commit is contained in:
		
							parent
							
								
									d2407afebf
								
							
						
					
					
						commit
						ba523d4381
					
				
					 14 changed files with 181 additions and 3 deletions
				
			
		| 
						 | 
					@ -108,6 +108,8 @@ namespace SafeExamBrowser.I18n.Contracts
 | 
				
			||||||
		MessageBox_ReconfigurationErrorTitle,
 | 
							MessageBox_ReconfigurationErrorTitle,
 | 
				
			||||||
		MessageBox_ReloadConfirmation,
 | 
							MessageBox_ReloadConfirmation,
 | 
				
			||||||
		MessageBox_ReloadConfirmationTitle,
 | 
							MessageBox_ReloadConfirmationTitle,
 | 
				
			||||||
 | 
							MessageBox_RemoteSessionNotAllowed,
 | 
				
			||||||
 | 
							MessageBox_RemoteSessionNotAllowedTitle,
 | 
				
			||||||
		MessageBox_ServiceUnavailableError,
 | 
							MessageBox_ServiceUnavailableError,
 | 
				
			||||||
		MessageBox_ServiceUnavailableErrorTitle,
 | 
							MessageBox_ServiceUnavailableErrorTitle,
 | 
				
			||||||
		MessageBox_ServiceUnavailableWarning,
 | 
							MessageBox_ServiceUnavailableWarning,
 | 
				
			||||||
| 
						 | 
					@ -155,6 +157,7 @@ namespace SafeExamBrowser.I18n.Contracts
 | 
				
			||||||
		OperationStatus_StopMouseInterception,
 | 
							OperationStatus_StopMouseInterception,
 | 
				
			||||||
		OperationStatus_TerminateBrowser,
 | 
							OperationStatus_TerminateBrowser,
 | 
				
			||||||
		OperationStatus_TerminateShell,
 | 
							OperationStatus_TerminateShell,
 | 
				
			||||||
 | 
							OperationStatus_ValidateRemoteSessionPolicy,
 | 
				
			||||||
		OperationStatus_ValidateVirtualMachinePolicy,
 | 
							OperationStatus_ValidateVirtualMachinePolicy,
 | 
				
			||||||
		OperationStatus_WaitExplorerStartup,
 | 
							OperationStatus_WaitExplorerStartup,
 | 
				
			||||||
		OperationStatus_WaitExplorerTermination,
 | 
							OperationStatus_WaitExplorerTermination,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -246,6 +246,12 @@
 | 
				
			||||||
    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
					    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
				
			||||||
        刷新?
 | 
					        刷新?
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowed">
 | 
				
			||||||
 | 
					        系统似乎正在远程会话中运行。所选的配置不允许SEB在远程会话中运行。
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowedTitle">
 | 
				
			||||||
 | 
					        检测到远程会话
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="MessageBox_ServiceUnavailableError">
 | 
					    <Entry key="MessageBox_ServiceUnavailableError">
 | 
				
			||||||
        防作弊考试专用浏览器服务初始化失败。防作弊考试专用浏览器现将终止,因为该服务被配置为强制项。
 | 
					        防作弊考试专用浏览器服务初始化失败。防作弊考试专用浏览器现将终止,因为该服务被配置为强制项。
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					@ -375,6 +381,9 @@
 | 
				
			||||||
    <Entry key="OperationStatus_TerminateShell">
 | 
					    <Entry key="OperationStatus_TerminateShell">
 | 
				
			||||||
        终止用户界面
 | 
					        终止用户界面
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="OperationStatus_ValidateRemoteSessionPolicy">
 | 
				
			||||||
 | 
					        验证远程会话策略
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
					    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
				
			||||||
        验证虚拟机策略
 | 
					        验证虚拟机策略
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,12 @@
 | 
				
			||||||
    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
					    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
				
			||||||
        Neu laden?
 | 
					        Neu laden?
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowed">
 | 
				
			||||||
 | 
					        Das System scheint in einer Remote-Sitzung zu laufen. Die ausgewählte Konfiguration erlaubt es nicht, SEB in einer Remote-Sitzung auszuführen.
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowedTitle">
 | 
				
			||||||
 | 
					        Remote-Sitzung erkannt
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="MessageBox_ServiceUnavailableError">
 | 
					    <Entry key="MessageBox_ServiceUnavailableError">
 | 
				
			||||||
        Fehler beim Initialisieren des SEB-Service! SEB wird sich nun beenden da der Service als obligatorisch konfiguriert ist.
 | 
					        Fehler beim Initialisieren des SEB-Service! SEB wird sich nun beenden da der Service als obligatorisch konfiguriert ist.
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					@ -423,6 +429,9 @@
 | 
				
			||||||
    <Entry key="OperationStatus_TerminateShell">
 | 
					    <Entry key="OperationStatus_TerminateShell">
 | 
				
			||||||
        Beende Benutzeroberfläche
 | 
					        Beende Benutzeroberfläche
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="OperationStatus_ValidateRemoteSessionPolicy">
 | 
				
			||||||
 | 
					        Validiere Richtlinie für Remote-Sitzungen
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
					    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
				
			||||||
        Validiere Richtlinie für virtuelle Maschinen
 | 
					        Validiere Richtlinie für virtuelle Maschinen
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,12 @@
 | 
				
			||||||
    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
					    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
				
			||||||
        Reload?
 | 
					        Reload?
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowed">
 | 
				
			||||||
 | 
					        The system appears to be running in a remote session. The selected configuration does not allow SEB to be run in a remote session.
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowedTitle">
 | 
				
			||||||
 | 
					        Remote Session Detected
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="MessageBox_ServiceUnavailableError">
 | 
					    <Entry key="MessageBox_ServiceUnavailableError">
 | 
				
			||||||
        Failed to initialize the SEB service! SEB will now terminate since the service is configured to be mandatory.
 | 
					        Failed to initialize the SEB service! SEB will now terminate since the service is configured to be mandatory.
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					@ -423,6 +429,9 @@
 | 
				
			||||||
    <Entry key="OperationStatus_TerminateShell">
 | 
					    <Entry key="OperationStatus_TerminateShell">
 | 
				
			||||||
        Terminating user interface
 | 
					        Terminating user interface
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="OperationStatus_ValidateRemoteSessionPolicy">
 | 
				
			||||||
 | 
					        Validating remote session policy
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
					    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
				
			||||||
        Validating virtual machine policy
 | 
					        Validating virtual machine policy
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,12 @@
 | 
				
			||||||
    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
					    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
				
			||||||
        Recharger ?
 | 
					        Recharger ?
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowed">
 | 
				
			||||||
 | 
					        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.
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowedTitle">
 | 
				
			||||||
 | 
					        Session distante détectée
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="MessageBox_ServiceUnavailableError">
 | 
					    <Entry key="MessageBox_ServiceUnavailableError">
 | 
				
			||||||
        Le service SEB n'a pas été initialisé ! Le service SEB va maintenant se terminer puisque le service obligatoire.
 | 
					        Le service SEB n'a pas été initialisé ! Le service SEB va maintenant se terminer puisque le service obligatoire.
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					@ -423,6 +429,9 @@
 | 
				
			||||||
    <Entry key="OperationStatus_TerminateShell">
 | 
					    <Entry key="OperationStatus_TerminateShell">
 | 
				
			||||||
        Arrêt de l’interface utilisateur
 | 
					        Arrêt de l’interface utilisateur
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="OperationStatus_ValidateRemoteSessionPolicy">
 | 
				
			||||||
 | 
					        Validation de la directive sur la session à distance
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
					    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
				
			||||||
        Validation de la directive sur les machines virtuelles
 | 
					        Validation de la directive sur les machines virtuelles
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,12 @@
 | 
				
			||||||
    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
					    <Entry key="MessageBox_ReloadConfirmationTitle">
 | 
				
			||||||
        Ricaricare?
 | 
					        Ricaricare?
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowed">
 | 
				
			||||||
 | 
					        Il sistema sembra essere in esecuzione in una sessione remota. La configurazione selezionata non consente l'esecuzione di SEB in una sessione remota.
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="MessageBox_RemoteSessionNotAllowedTitle">
 | 
				
			||||||
 | 
					        Sessione remota rilevata
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="MessageBox_ServiceUnavailableError">
 | 
					    <Entry key="MessageBox_ServiceUnavailableError">
 | 
				
			||||||
        Impossibile inizializzare il servizio SEB! SEB verrà ora terminato poiché il servizio è configurato per essere obbligatorio.
 | 
					        Impossibile inizializzare il servizio SEB! SEB verrà ora terminato poiché il servizio è configurato per essere obbligatorio.
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					@ -423,6 +429,9 @@
 | 
				
			||||||
    <Entry key="OperationStatus_TerminateShell">
 | 
					    <Entry key="OperationStatus_TerminateShell">
 | 
				
			||||||
        Chiusura dell'interfaccia utente
 | 
					        Chiusura dell'interfaccia utente
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
 | 
					    <Entry key="OperationStatus_ValidateRemoteSessionPolicy">
 | 
				
			||||||
 | 
					        Convalida dei criteri della sessione remota
 | 
				
			||||||
 | 
					    </Entry>
 | 
				
			||||||
    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
					    <Entry key="OperationStatus_ValidateVirtualMachinePolicy">
 | 
				
			||||||
        Convalida dei criteri della macchina virtuale
 | 
					        Convalida dei criteri della macchina virtuale
 | 
				
			||||||
    </Entry>
 | 
					    </Entry>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,6 +66,7 @@ namespace SafeExamBrowser.Runtime
 | 
				
			||||||
			var fileSystem = new FileSystem();
 | 
								var fileSystem = new FileSystem();
 | 
				
			||||||
			var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
 | 
								var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
 | 
				
			||||||
			var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory)));
 | 
								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 runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
 | 
				
			||||||
			var runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
 | 
								var runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
 | 
				
			||||||
			var server = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy)));
 | 
								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 SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext));
 | 
				
			||||||
			sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, 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 ServerOperation(args, configuration, fileSystem, logger, sessionContext, server));
 | 
				
			||||||
 | 
								sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext));
 | 
				
			||||||
			sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
 | 
								sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
 | 
				
			||||||
			sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
 | 
								sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
 | 
				
			||||||
			sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
 | 
								sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										71
									
								
								SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -22,15 +22,15 @@ namespace SafeExamBrowser.Runtime.Operations
 | 
				
			||||||
		private IVirtualMachineDetector detector;
 | 
							private IVirtualMachineDetector detector;
 | 
				
			||||||
		private ILogger logger;
 | 
							private ILogger logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public override event ActionRequiredEventHandler ActionRequired;
 | 
				
			||||||
 | 
							public override event StatusChangedEventHandler StatusChanged;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public VirtualMachineOperation(IVirtualMachineDetector detector, ILogger logger, SessionContext context) : base(context)
 | 
							public VirtualMachineOperation(IVirtualMachineDetector detector, ILogger logger, SessionContext context) : base(context)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			this.detector = detector;
 | 
								this.detector = detector;
 | 
				
			||||||
			this.logger = logger;
 | 
								this.logger = logger;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override event ActionRequiredEventHandler ActionRequired;
 | 
					 | 
				
			||||||
		public override event StatusChangedEventHandler StatusChanged;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public override OperationResult Perform()
 | 
							public override OperationResult Perform()
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return ValidatePolicy();
 | 
								return ValidatePolicy();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,6 +103,7 @@
 | 
				
			||||||
    <Compile Include="Operations\Events\ServerFailureEventArgs.cs" />
 | 
					    <Compile Include="Operations\Events\ServerFailureEventArgs.cs" />
 | 
				
			||||||
    <Compile Include="Operations\Events\UnexpectedErrorMessageArgs.cs" />
 | 
					    <Compile Include="Operations\Events\UnexpectedErrorMessageArgs.cs" />
 | 
				
			||||||
    <Compile Include="Operations\KioskModeOperation.cs" />
 | 
					    <Compile Include="Operations\KioskModeOperation.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Operations\RemoteSessionOperation.cs" />
 | 
				
			||||||
    <Compile Include="Operations\ServerOperation.cs" />
 | 
					    <Compile Include="Operations\ServerOperation.cs" />
 | 
				
			||||||
    <Compile Include="Operations\ServiceOperation.cs" />
 | 
					    <Compile Include="Operations\ServiceOperation.cs" />
 | 
				
			||||||
    <Compile Include="Operations\SessionActivationOperation.cs" />
 | 
					    <Compile Include="Operations\SessionActivationOperation.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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Provides functionality related to remote session detection.
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						public interface IRemoteSessionDetector
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// Indicates whether the system is currently running in a remote session.
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							bool IsRemoteSession();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -57,6 +57,7 @@
 | 
				
			||||||
    <Compile Include="Audio\Events\VolumeChangedEventHandler.cs" />
 | 
					    <Compile Include="Audio\Events\VolumeChangedEventHandler.cs" />
 | 
				
			||||||
    <Compile Include="Audio\IAudio.cs" />
 | 
					    <Compile Include="Audio\IAudio.cs" />
 | 
				
			||||||
    <Compile Include="IFileSystem.cs" />
 | 
					    <Compile Include="IFileSystem.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="IRemoteSessionDetector.cs" />
 | 
				
			||||||
    <Compile Include="IVirtualMachineDetector.cs" />
 | 
					    <Compile Include="IVirtualMachineDetector.cs" />
 | 
				
			||||||
    <Compile Include="PowerSupply\Events\StatusChangedEventHandler.cs" />
 | 
					    <Compile Include="PowerSupply\Events\StatusChangedEventHandler.cs" />
 | 
				
			||||||
    <Compile Include="PowerSupply\IPowerSupply.cs" />
 | 
					    <Compile Include="PowerSupply\IPowerSupply.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										33
									
								
								SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -70,6 +70,7 @@
 | 
				
			||||||
    <Compile Include="PowerSupply\PowerSupply.cs" />
 | 
					    <Compile Include="PowerSupply\PowerSupply.cs" />
 | 
				
			||||||
    <Compile Include="PowerSupply\PowerSupplyStatus.cs" />
 | 
					    <Compile Include="PowerSupply\PowerSupplyStatus.cs" />
 | 
				
			||||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
					    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="RemoteSessionDetector.cs" />
 | 
				
			||||||
    <Compile Include="SystemInfo.cs" />
 | 
					    <Compile Include="SystemInfo.cs" />
 | 
				
			||||||
    <Compile Include="UserInfo.cs" />
 | 
					    <Compile Include="UserInfo.cs" />
 | 
				
			||||||
    <Compile Include="VirtualMachineDetector.cs" />
 | 
					    <Compile Include="VirtualMachineDetector.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue