SEBWIN-301: Defined settings for service component.

This commit is contained in:
dbuechel 2019-06-20 10:55:24 +02:00
parent 4087db9097
commit 1c7c856c33
12 changed files with 183 additions and 14 deletions

View file

@ -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);
}
}
}

View file

@ -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;

View file

@ -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
{
/// <summary>
/// Defines all configuration options for the service application component.
/// </summary>
public class ServiceSettings
{
/// <summary>
/// Determines whether the user may access the ease of access options on the security screen.
/// </summary>
public bool AllowEaseOfAccessOptions { get; set; }
/// <summary>
/// Determines whether the user may access the network options on the security screen.
/// </summary>
public bool AllowNetworkOptions { get; set; }
/// <summary>
/// Determines whether the user may change the password for a user account via the security screen.
/// </summary>
public bool AllowPasswordChange { get; set; }
/// <summary>
/// Determines whether the user may access the power options on the security screen.
/// </summary>
public bool AllowPowerOptions { get; set; }
/// <summary>
/// Determines whether the user may sign out of their account via the security screen.
/// </summary>
public bool AllowSignout { get; set; }
/// <summary>
/// Determines whether the user may start the task manager via the security screen.
/// </summary>
public bool AllowTaskManager { get; set; }
/// <summary>
/// Determines whether the user may lock the computer via the security screen.
/// </summary>
public bool AllowUserLock { get; set; }
/// <summary>
/// Determines whether the user may switch to another user account via the security screen.
/// </summary>
public bool AllowUserSwitch { get; set; }
/// <summary>
/// Determines whether desktop notifications of Google Chrome should be deactivated.
/// </summary>
public bool DisableChromeNotifications { get; set; }
/// <summary>
/// Determines whether remote desktop connections should be deactivated.
/// </summary>
public bool DisableRemoteConnections { get; set; }
/// <summary>
/// Determines whether the user interface overlay for VMware clients should be deactivated.
/// </summary>
public bool DisableVmwareOverlay { get; set; }
/// <summary>
/// Determines whether Windows Update should be deactivated.
/// </summary>
public bool DisableWindowsUpdate { get; set; }
/// <summary>
/// The active policy for the service component.
/// </summary>
public ServicePolicy Policy { get; set; }
}
}

View file

@ -68,9 +68,9 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
public string QuitPasswordHash { get; set; }
/// <summary>
/// The active policy for the service component.
/// All service-related settings.
/// </summary>
public ServicePolicy ServicePolicy { get; set; }
public ServiceSettings Service { get; set; }
/// <summary>
/// All taskbar-related settings.
@ -78,7 +78,7 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
public TaskbarSettings Taskbar { get; set; }
/// <summary>
/// The mode which determines the look & feel of the user interface.
/// The mode which determines the look &amp; feel of the user interface.
/// </summary>
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();
}
}

View file

@ -9,7 +9,7 @@
namespace SafeExamBrowser.Contracts.Configuration.Settings
{
/// <summary>
/// Defines all possible look & feel options for the application.
/// Defines all possible look &amp; feel options for the application.
/// </summary>
public enum UserInterfaceMode
{

View file

@ -85,6 +85,7 @@
<Compile Include="Configuration\ServiceConfiguration.cs" />
<Compile Include="Configuration\Settings\ActionCenterSettings.cs" />
<Compile Include="Configuration\Settings\BrowserWindowSettings.cs" />
<Compile Include="Configuration\Settings\ServiceSettings.cs" />
<Compile Include="Configuration\Settings\UserInterfaceMode.cs" />
<Compile Include="Applications\Events\IconChangedEventHandler.cs" />
<Compile Include="Applications\Events\InstanceTerminatedEventHandler.cs" />

View file

@ -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();

View file

@ -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;

View file

@ -45,10 +45,12 @@ namespace SafeExamBrowser.Service
var bootstrapOperations = new Queue<IOperation>();
var sessionOperations = new Queue<IOperation>();
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);

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -64,6 +64,8 @@
<Compile Include="Installer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Operations\LockdownOperation.cs" />
<Compile Include="Operations\RestoreOperation.cs" />
<Compile Include="Operations\ServiceEventCleanupOperation.cs" />
<Compile Include="Operations\SessionActivationOperation.cs" />
<Compile Include="Operations\SessionInitializationOperation.cs" />