diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs index 5e119543..4b35868b 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Security.cs @@ -41,7 +41,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData if (value is int policy) { - settings.ServicePolicy = policy == FORCE ? ServicePolicy.Mandatory : (policy == WARN ? ServicePolicy.Warn : ServicePolicy.Optional); + settings.Service.Policy = policy == FORCE ? ServicePolicy.Mandatory : (policy == WARN ? ServicePolicy.Warn : ServicePolicy.Optional); } } } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index 029ddadd..bcd6df98 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -147,7 +147,19 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Mouse.AllowMiddleButton = false; settings.Mouse.AllowRightButton = true; - settings.ServicePolicy = ServicePolicy.Mandatory; + settings.Service.AllowEaseOfAccessOptions = false; + settings.Service.AllowNetworkOptions = false; + settings.Service.AllowPasswordChange = false; + settings.Service.AllowPowerOptions = false; + settings.Service.AllowSignout = false; + settings.Service.AllowTaskManager = false; + settings.Service.AllowUserLock = false; + settings.Service.AllowUserSwitch = false; + settings.Service.DisableChromeNotifications = true; + settings.Service.DisableRemoteConnections = true; + settings.Service.DisableVmwareOverlay = true; + settings.Service.DisableWindowsUpdate = true; + settings.Service.Policy = ServicePolicy.Mandatory; settings.AllowApplicationLogAccess = false; diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs new file mode 100644 index 00000000..a93ebcfd --- /dev/null +++ b/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 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.Contracts.Configuration.Settings +{ + /// + /// Defines all configuration options for the service application component. + /// + public class ServiceSettings + { + /// + /// Determines whether the user may access the ease of access options on the security screen. + /// + public bool AllowEaseOfAccessOptions { get; set; } + + /// + /// Determines whether the user may access the network options on the security screen. + /// + public bool AllowNetworkOptions { get; set; } + + /// + /// Determines whether the user may change the password for a user account via the security screen. + /// + public bool AllowPasswordChange { get; set; } + + /// + /// Determines whether the user may access the power options on the security screen. + /// + public bool AllowPowerOptions { get; set; } + + /// + /// Determines whether the user may sign out of their account via the security screen. + /// + public bool AllowSignout { get; set; } + + /// + /// Determines whether the user may start the task manager via the security screen. + /// + public bool AllowTaskManager { get; set; } + + /// + /// Determines whether the user may lock the computer via the security screen. + /// + public bool AllowUserLock { get; set; } + + /// + /// Determines whether the user may switch to another user account via the security screen. + /// + public bool AllowUserSwitch { get; set; } + + /// + /// Determines whether desktop notifications of Google Chrome should be deactivated. + /// + public bool DisableChromeNotifications { get; set; } + + /// + /// Determines whether remote desktop connections should be deactivated. + /// + public bool DisableRemoteConnections { get; set; } + + /// + /// Determines whether the user interface overlay for VMware clients should be deactivated. + /// + public bool DisableVmwareOverlay { get; set; } + + /// + /// Determines whether Windows Update should be deactivated. + /// + public bool DisableWindowsUpdate { get; set; } + + /// + /// The active policy for the service component. + /// + public ServicePolicy Policy { get; set; } + } +} diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs index a06b0983..f9e70d90 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs @@ -68,9 +68,9 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings public string QuitPasswordHash { get; set; } /// - /// The active policy for the service component. + /// All service-related settings. /// - public ServicePolicy ServicePolicy { get; set; } + public ServiceSettings Service { get; set; } /// /// All taskbar-related settings. @@ -78,7 +78,7 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings public TaskbarSettings Taskbar { get; set; } /// - /// The mode which determines the look & feel of the user interface. + /// The mode which determines the look & feel of the user interface. /// public UserInterfaceMode UserInterfaceMode { get; set; } @@ -88,6 +88,7 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings Browser = new BrowserSettings(); Keyboard = new KeyboardSettings(); Mouse = new MouseSettings(); + Service = new ServiceSettings(); Taskbar = new TaskbarSettings(); } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/UserInterfaceMode.cs b/SafeExamBrowser.Contracts/Configuration/Settings/UserInterfaceMode.cs index 286934f0..3707f0db 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/UserInterfaceMode.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/UserInterfaceMode.cs @@ -9,7 +9,7 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings { /// - /// Defines all possible look & feel options for the application. + /// Defines all possible look & feel options for the application. /// public enum UserInterfaceMode { diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj index 725a4ad9..758c39b4 100644 --- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj +++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj @@ -85,6 +85,7 @@ + diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs index d5ecdeba..5450f812 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs @@ -55,7 +55,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations sessionContext.Next = session; sessionContext.Next.AppConfig = appConfig; session.Settings = settings; - settings.ServicePolicy = ServicePolicy.Mandatory; + settings.Service.Policy = ServicePolicy.Mandatory; sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, 0); } @@ -64,12 +64,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations public void Perform_MustConnectToService() { service.Setup(s => s.Connect(null, true)).Returns(true); - settings.ServicePolicy = ServicePolicy.Mandatory; + settings.Service.Policy = ServicePolicy.Mandatory; sut.Perform(); service.Setup(s => s.Connect(null, true)).Returns(true); - settings.ServicePolicy = ServicePolicy.Optional; + settings.Service.Policy = ServicePolicy.Optional; sut.Perform(); @@ -160,7 +160,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations service.SetupGet(s => s.IsConnected).Returns(false); service.Setup(s => s.Connect(null, true)).Returns(false); - settings.ServicePolicy = ServicePolicy.Mandatory; + settings.Service.Policy = ServicePolicy.Mandatory; sut.ActionRequired += (args) => errorShown = args is MessageEventArgs m && m.Icon == MessageBoxIcon.Error; var result = sut.Perform(); @@ -174,7 +174,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations { service.SetupGet(s => s.IsConnected).Returns(false); service.Setup(s => s.Connect(null, true)).Returns(false); - settings.ServicePolicy = ServicePolicy.Optional; + settings.Service.Policy = ServicePolicy.Optional; var result = sut.Perform(); @@ -189,7 +189,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations service.SetupGet(s => s.IsConnected).Returns(false); service.Setup(s => s.Connect(null, true)).Returns(false); - settings.ServicePolicy = ServicePolicy.Warn; + settings.Service.Policy = ServicePolicy.Warn; sut.ActionRequired += (args) => warningShown = args is MessageEventArgs m && m.Icon == MessageBoxIcon.Warning; var result = sut.Perform(); diff --git a/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs b/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs index 825b9cb6..2c9339ff 100644 --- a/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs @@ -106,8 +106,8 @@ namespace SafeExamBrowser.Runtime.Operations private bool TryEstablishConnection() { - var mandatory = Context.Next.Settings.ServicePolicy == ServicePolicy.Mandatory; - var warn = Context.Next.Settings.ServicePolicy == ServicePolicy.Warn; + var mandatory = Context.Next.Settings.Service.Policy == ServicePolicy.Mandatory; + var warn = Context.Next.Settings.Service.Policy == ServicePolicy.Warn; var connected = service.Connect(); var success = connected || !mandatory; diff --git a/SafeExamBrowser.Service/CompositionRoot.cs b/SafeExamBrowser.Service/CompositionRoot.cs index 792c8448..af2caa32 100644 --- a/SafeExamBrowser.Service/CompositionRoot.cs +++ b/SafeExamBrowser.Service/CompositionRoot.cs @@ -45,10 +45,12 @@ namespace SafeExamBrowser.Service var bootstrapOperations = new Queue(); var sessionOperations = new Queue(); + bootstrapOperations.Enqueue(new RestoreOperation(logger)); bootstrapOperations.Enqueue(new CommunicationHostOperation(serviceHost, logger)); bootstrapOperations.Enqueue(new ServiceEventCleanupOperation(logger, sessionContext)); sessionOperations.Enqueue(new SessionInitializationOperation(logger, LogWriterFactory, ServiceEventFactory, serviceHost, sessionContext)); + sessionOperations.Enqueue(new LockdownOperation(logger, sessionContext)); sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext)); var bootstrapSequence = new OperationSequence(logger, bootstrapOperations); diff --git a/SafeExamBrowser.Service/Operations/LockdownOperation.cs b/SafeExamBrowser.Service/Operations/LockdownOperation.cs new file mode 100644 index 00000000..92dee180 --- /dev/null +++ b/SafeExamBrowser.Service/Operations/LockdownOperation.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 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.Contracts.Core.OperationModel; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Service.Operations +{ + internal class LockdownOperation : SessionOperation + { + private readonly ILogger logger; + + public LockdownOperation(ILogger logger, SessionContext sessionContext) : base(sessionContext) + { + this.logger = logger; + } + + public override OperationResult Perform() + { + return OperationResult.Success; + } + + public override OperationResult Revert() + { + return OperationResult.Success; + } + } +} diff --git a/SafeExamBrowser.Service/Operations/RestoreOperation.cs b/SafeExamBrowser.Service/Operations/RestoreOperation.cs new file mode 100644 index 00000000..e150d3b1 --- /dev/null +++ b/SafeExamBrowser.Service/Operations/RestoreOperation.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 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.Contracts.Core.OperationModel; +using SafeExamBrowser.Contracts.Core.OperationModel.Events; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Service.Operations +{ + internal class RestoreOperation : IOperation + { + private readonly ILogger logger; + + public event ActionRequiredEventHandler ActionRequired { add { } remove { } } + public event StatusChangedEventHandler StatusChanged { add { } remove { } } + + public RestoreOperation(ILogger logger) + { + this.logger = logger; + } + + public OperationResult Perform() + { + return OperationResult.Success; + } + + public OperationResult Revert() + { + return OperationResult.Success; + } + } +} diff --git a/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj b/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj index 3de337fe..f3f1d3b2 100644 --- a/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj +++ b/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj @@ -64,6 +64,8 @@ Component + +