From b96bbfcd78ba29aaacb4bf5eb7fe771995650d49 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 21 Jun 2019 15:05:31 +0200 Subject: [PATCH] SEBWIN-301: Started implementing backup mechanism for service. --- .../ConfigurationData/DataValues.cs | 16 ++-- .../Configuration/ServiceConfiguration.cs | 10 +++ .../Configuration/Settings/ServiceSettings.cs | 80 +++++++++--------- .../Lockdown/IFeatureConfiguration.cs | 36 ++++++++ .../Lockdown/IFeatureConfigurationBackup.cs | 33 ++++++++ .../Lockdown/IFeatureConfigurationFactory.cs | 76 +++++++++++++++++ .../SafeExamBrowser.Contracts.csproj | 4 + .../SystemComponents/IUserInfo.cs | 26 ++++++ .../FeatureConfigurationBackup.cs | 39 +++++++++ .../FeatureConfigurationFactory.cs | 84 +++++++++++++++++++ .../ChromeNotificationConfiguration.cs | 35 ++++++++ .../EaseOfAccessConfiguration.cs | 35 ++++++++ .../NetworkOptionsConfiguration.cs | 35 ++++++++ .../PasswordChangeConfiguration.cs | 35 ++++++++ .../PowerOptionsConfiguration.cs | 35 ++++++++ .../RemoteConnectionConfiguration.cs | 35 ++++++++ .../SignoutConfiguration.cs | 35 ++++++++ .../TaskManagerConfiguration.cs | 35 ++++++++ .../UserLockConfiguration.cs | 35 ++++++++ .../UserSwitchConfiguration.cs | 35 ++++++++ .../VmwareOverlayConfiguration.cs | 35 ++++++++ .../WindowsUpdateConfiguration.cs | 35 ++++++++ .../Properties/AssemblyInfo.cs | 33 ++++++++ .../SafeExamBrowser.Lockdown.csproj | 80 ++++++++++++++++++ .../Operations/ServiceOperationTests.cs | 13 ++- SafeExamBrowser.Runtime/CompositionRoot.cs | 3 +- .../Operations/ServiceOperation.cs | 10 ++- SafeExamBrowser.Service/CompositionRoot.cs | 5 +- .../Operations/LockdownOperation.cs | 63 +++++++++++++- .../Operations/RestoreOperation.cs | 5 +- .../SafeExamBrowser.Service.csproj | 4 + .../SafeExamBrowser.SystemComponents.csproj | 1 + SafeExamBrowser.SystemComponents/UserInfo.cs | 27 ++++++ SafeExamBrowser.sln | 10 +++ 34 files changed, 1019 insertions(+), 59 deletions(-) create mode 100644 SafeExamBrowser.Contracts/Lockdown/IFeatureConfiguration.cs create mode 100644 SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationBackup.cs create mode 100644 SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs create mode 100644 SafeExamBrowser.Contracts/SystemComponents/IUserInfo.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurationBackup.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/ChromeNotificationConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/EaseOfAccessConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/NetworkOptionsConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/PasswordChangeConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/PowerOptionsConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/RemoteConnectionConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/SignoutConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/TaskManagerConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/UserLockConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/UserSwitchConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/VmwareOverlayConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/FeatureConfigurations/WindowsUpdateConfiguration.cs create mode 100644 SafeExamBrowser.Lockdown/Properties/AssemblyInfo.cs create mode 100644 SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj create mode 100644 SafeExamBrowser.SystemComponents/UserInfo.cs diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index bcd6df98..c5860cf4 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -147,16 +147,16 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Mouse.AllowMiddleButton = false; settings.Mouse.AllowRightButton = true; - 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.DisableEaseOfAccessOptions = true; + settings.Service.DisableNetworkOptions = true; + settings.Service.DisablePasswordChange = true; + settings.Service.DisablePowerOptions = true; settings.Service.DisableRemoteConnections = true; + settings.Service.DisableSignout = true; + settings.Service.DisableTaskManager = true; + settings.Service.DisableUserLock = true; + settings.Service.DisableUserSwitch = true; settings.Service.DisableVmwareOverlay = true; settings.Service.DisableWindowsUpdate = true; settings.Service.Policy = ServicePolicy.Mandatory; diff --git a/SafeExamBrowser.Contracts/Configuration/ServiceConfiguration.cs b/SafeExamBrowser.Contracts/Configuration/ServiceConfiguration.cs index 28773828..b0414e44 100644 --- a/SafeExamBrowser.Contracts/Configuration/ServiceConfiguration.cs +++ b/SafeExamBrowser.Contracts/Configuration/ServiceConfiguration.cs @@ -30,5 +30,15 @@ namespace SafeExamBrowser.Contracts.Configuration /// The application settings to be used by the service. /// public Settings.Settings Settings { get; set; } + + /// + /// The user name of the currently logged in user. + /// + public string UserName { get; set; } + + /// + /// The security identifier of the currently logged in user. + /// + public string UserSid { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs index a93ebcfd..1983b81d 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/ServiceSettings.cs @@ -13,56 +13,56 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings /// 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 the user can access the ease of access options on the security screen. + /// + public bool DisableEaseOfAccessOptions { get; set; } + + /// + /// Determines whether the user can access the network options on the security screen. + /// + public bool DisableNetworkOptions { get; set; } + + /// + /// Determines whether the user can change the password for a user account via the security screen. + /// + public bool DisablePasswordChange { get; set; } + + /// + /// Determines whether the user can access the power options on the security screen. + /// + public bool DisablePowerOptions { get; set; } + /// /// Determines whether remote desktop connections should be deactivated. /// public bool DisableRemoteConnections { get; set; } + /// + /// Determines whether the user can sign out of their account via the security screen. + /// + public bool DisableSignout { get; set; } + + /// + /// Determines whether the user can access the task manager of Windows. + /// + public bool DisableTaskManager { get; set; } + + /// + /// Determines whether the user can lock the computer via the security screen. + /// + public bool DisableUserLock { get; set; } + + /// + /// Determines whether the user can switch to another user account via the security screen. + /// + public bool DisableUserSwitch { get; set; } + /// /// Determines whether the user interface overlay for VMware clients should be deactivated. /// diff --git a/SafeExamBrowser.Contracts/Lockdown/IFeatureConfiguration.cs b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfiguration.cs new file mode 100644 index 00000000..eff72b83 --- /dev/null +++ b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfiguration.cs @@ -0,0 +1,36 @@ +/* + * 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.Lockdown +{ + /// + /// Allows to control a feature of the computer, the operating system or an installed third-party software. + /// + public interface IFeatureConfiguration + { + /// + /// Disables the feature. + /// + void DisableFeature(); + + /// + /// Enables the feature. + /// + void EnableFeature(); + + /// + /// Starts monitoring the feature to ensure that it remains as currently configured. + /// + void Monitor(); + + /// + /// Restores the feature to its initial configuration. + /// + void Restore(); + } +} diff --git a/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationBackup.cs b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationBackup.cs new file mode 100644 index 00000000..b430486c --- /dev/null +++ b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationBackup.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 System.Collections.Generic; + +namespace SafeExamBrowser.Contracts.Lockdown +{ + /// + /// Defines the functionality of a backup repository for . + /// + public interface IFeatureConfigurationBackup + { + /// + /// Gets all currently saved in the backup repository. + /// + IList GetConfigurations(); + + /// + /// Saves the given in the backup repository. + /// + void Save(IFeatureConfiguration configuration); + + /// + /// Deletes the given from the backup repository. + /// + void Delete(IFeatureConfiguration configuration); + } +} diff --git a/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs new file mode 100644 index 00000000..6d355c7f --- /dev/null +++ b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs @@ -0,0 +1,76 @@ +/* + * 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.Lockdown +{ + /// + /// The factory for all currently supported. + /// + public interface IFeatureConfigurationFactory + { + /// + /// Creates an to control notifications of the Google Chrome browser. + /// + IFeatureConfiguration CreateChromeNotificationConfiguration(); + + /// + /// Creates an to control the ease of access options on the security screen. + /// + IFeatureConfiguration CreateEaseOfAccessConfiguration(); + + /// + /// Creates an to control the network options on the security screen. + /// + IFeatureConfiguration CreateNetworkOptionsConfiguration(); + + /// + /// Creates an to control the option to change the password of a user account via the security screen. + /// + IFeatureConfiguration CreatePasswordChangeConfiguration(); + + /// + /// Creates an to control the power options on the security screen. + /// + IFeatureConfiguration CreatePowerOptionsConfiguration(); + + /// + /// Creates an to control remote desktop connections. + /// + IFeatureConfiguration CreateRemoteConnectionConfiguration(); + + /// + /// Creates an to control the option to sign out out via security screen. + /// + IFeatureConfiguration CreateSignoutConfiguration(); + + /// + /// Creates an to control the task manager of Windows. + /// + IFeatureConfiguration CreateTaskManagerConfiguration(); + + /// + /// Creates an to control the option to lock the computer via the security screen. + /// + IFeatureConfiguration CreateUserLockConfiguration(); + + /// + /// Creates an to control the option to switch to another user account via the security screen. + /// + IFeatureConfiguration CreateUserSwitchConfiguration(); + + /// + /// Creates an to control the user interface overlay for VMware clients. + /// + IFeatureConfiguration CreateVmwareOverlayConfiguration(); + + /// + /// Creates an to control Windows Update. + /// + IFeatureConfiguration CreateWindowsUpdateConfiguration(); + } +} diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj index 758c39b4..fd10f1e7 100644 --- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj +++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj @@ -92,6 +92,9 @@ + + + @@ -154,6 +157,7 @@ + diff --git a/SafeExamBrowser.Contracts/SystemComponents/IUserInfo.cs b/SafeExamBrowser.Contracts/SystemComponents/IUserInfo.cs new file mode 100644 index 00000000..a19ffd88 --- /dev/null +++ b/SafeExamBrowser.Contracts/SystemComponents/IUserInfo.cs @@ -0,0 +1,26 @@ +/* + * 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.SystemComponents +{ + /// + /// Provides information about the currently logged in user. + /// + public interface IUserInfo + { + /// + /// Retrieves the name of the currently logged in user. + /// + string GetUserName(); + + /// + /// Retrieves the security identifier of the currently logged in user. + /// + string GetUserSid(); + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurationBackup.cs b/SafeExamBrowser.Lockdown/FeatureConfigurationBackup.cs new file mode 100644 index 00000000..ab4eedf6 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurationBackup.cs @@ -0,0 +1,39 @@ +/* + * 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 System.Collections.Generic; +using SafeExamBrowser.Contracts.Lockdown; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Lockdown +{ + public class FeatureConfigurationBackup : IFeatureConfigurationBackup + { + private ILogger logger; + + public FeatureConfigurationBackup(ILogger logger) + { + this.logger = logger; + } + + public void Delete(IFeatureConfiguration configuration) + { + + } + + public IList GetConfigurations() + { + return new List(); + } + + public void Save(IFeatureConfiguration configuration) + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs b/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs new file mode 100644 index 00000000..304120e5 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs @@ -0,0 +1,84 @@ +/* + * 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.Lockdown; +using SafeExamBrowser.Contracts.Logging; +using SafeExamBrowser.Lockdown.FeatureConfigurations; + +namespace SafeExamBrowser.Lockdown +{ + public class FeatureConfigurationFactory : IFeatureConfigurationFactory + { + private IModuleLogger logger; + + public FeatureConfigurationFactory(IModuleLogger logger) + { + this.logger = logger; + } + + public IFeatureConfiguration CreateChromeNotificationConfiguration() + { + return new ChromeNotificationConfiguration(); + } + + public IFeatureConfiguration CreateEaseOfAccessConfiguration() + { + return new EaseOfAccessConfiguration(); + } + + public IFeatureConfiguration CreateNetworkOptionsConfiguration() + { + return new NetworkOptionsConfiguration(); + } + + public IFeatureConfiguration CreatePasswordChangeConfiguration() + { + return new PasswordChangeConfiguration(); + } + + public IFeatureConfiguration CreatePowerOptionsConfiguration() + { + return new PowerOptionsConfiguration(); + } + + public IFeatureConfiguration CreateRemoteConnectionConfiguration() + { + return new RemoteConnectionConfiguration(); + } + + public IFeatureConfiguration CreateSignoutConfiguration() + { + return new SignoutConfiguration(); + } + + public IFeatureConfiguration CreateTaskManagerConfiguration() + { + return new TaskManagerConfiguration(); + } + + public IFeatureConfiguration CreateUserLockConfiguration() + { + return new UserLockConfiguration(); + } + + public IFeatureConfiguration CreateUserSwitchConfiguration() + { + return new UserSwitchConfiguration(); + } + + public IFeatureConfiguration CreateVmwareOverlayConfiguration() + { + return new VmwareOverlayConfiguration(); + } + + public IFeatureConfiguration CreateWindowsUpdateConfiguration() + { + return new WindowsUpdateConfiguration(); + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/ChromeNotificationConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/ChromeNotificationConfiguration.cs new file mode 100644 index 00000000..cae32eea --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/ChromeNotificationConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class ChromeNotificationConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/EaseOfAccessConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/EaseOfAccessConfiguration.cs new file mode 100644 index 00000000..97ca0d01 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/EaseOfAccessConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class EaseOfAccessConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/NetworkOptionsConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/NetworkOptionsConfiguration.cs new file mode 100644 index 00000000..69732113 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/NetworkOptionsConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class NetworkOptionsConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/PasswordChangeConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/PasswordChangeConfiguration.cs new file mode 100644 index 00000000..32f8081c --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/PasswordChangeConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class PasswordChangeConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/PowerOptionsConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/PowerOptionsConfiguration.cs new file mode 100644 index 00000000..da9391f8 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/PowerOptionsConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class PowerOptionsConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/RemoteConnectionConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/RemoteConnectionConfiguration.cs new file mode 100644 index 00000000..f5ba59cc --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/RemoteConnectionConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class RemoteConnectionConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/SignoutConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/SignoutConfiguration.cs new file mode 100644 index 00000000..d225acca --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/SignoutConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class SignoutConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/TaskManagerConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/TaskManagerConfiguration.cs new file mode 100644 index 00000000..1bda3ab0 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/TaskManagerConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class TaskManagerConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/UserLockConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/UserLockConfiguration.cs new file mode 100644 index 00000000..bb65bc96 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/UserLockConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class UserLockConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/UserSwitchConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/UserSwitchConfiguration.cs new file mode 100644 index 00000000..041028d4 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/UserSwitchConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class UserSwitchConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/VmwareOverlayConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/VmwareOverlayConfiguration.cs new file mode 100644 index 00000000..a1ff38d7 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/VmwareOverlayConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class VmwareOverlayConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/WindowsUpdateConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/WindowsUpdateConfiguration.cs new file mode 100644 index 00000000..82b5afc4 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/WindowsUpdateConfiguration.cs @@ -0,0 +1,35 @@ +/* + * 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.Lockdown; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations +{ + internal class WindowsUpdateConfiguration : IFeatureConfiguration + { + public void DisableFeature() + { + + } + + public void EnableFeature() + { + + } + + public void Monitor() + { + + } + + public void Restore() + { + + } + } +} diff --git a/SafeExamBrowser.Lockdown/Properties/AssemblyInfo.cs b/SafeExamBrowser.Lockdown/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..ef15fc65 --- /dev/null +++ b/SafeExamBrowser.Lockdown/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SafeExamBrowser.Lockdown")] +[assembly: AssemblyDescription("Safe Exam Browser")] +[assembly: AssemblyCompany("ETH Zürich")] +[assembly: AssemblyProduct("SafeExamBrowser.Lockdown")] +[assembly: AssemblyCopyright("Copyright © 2019 ETH Zürich, Educational Development and Technology (LET)")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("386b6042-3e12-4753-9fc6-c88ea4f97030")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj b/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj new file mode 100644 index 00000000..63e5862c --- /dev/null +++ b/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {386B6042-3E12-4753-9FC6-C88EA4F97030} + Library + Properties + SafeExamBrowser.Lockdown + SafeExamBrowser.Lockdown + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + {47da5933-bef8-4729-94e6-abde2db12262} + SafeExamBrowser.Contracts + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs index 5450f812..698cbd80 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ServiceOperationTests.cs @@ -16,6 +16,7 @@ using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.Core.OperationModel; using SafeExamBrowser.Contracts.Logging; +using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.MessageBox; using SafeExamBrowser.Runtime.Operations; using SafeExamBrowser.Runtime.Operations.Events; @@ -33,6 +34,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations private SessionConfiguration session; private SessionContext sessionContext; private Settings settings; + private Mock userInfo; private ServiceOperation sut; [TestInitialize] @@ -48,6 +50,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations session = new SessionConfiguration(); sessionContext = new SessionContext(); settings = new Settings(); + userInfo = new Mock(); appConfig.ServiceEventName = serviceEventName; sessionContext.Current = session; @@ -57,7 +60,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations session.Settings = settings; settings.Service.Policy = ServicePolicy.Mandatory; - sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, 0); + sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, 0, userInfo.Object); } [TestMethod] @@ -86,6 +89,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations var result = sut.Perform(); service.Verify(s => s.StartSession(It.IsAny()), Times.Once); + userInfo.Verify(u => u.GetUserName(), Times.Once); + userInfo.Verify(u => u.GetUserSid(), Times.Once); Assert.AreEqual(OperationResult.Success, result); } @@ -116,7 +121,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations service.Setup(s => s.Connect(null, true)).Returns(true); service.Setup(s => s.StartSession(It.IsAny())).Returns(new CommunicationResult(true)); - sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT); + sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT, userInfo.Object); before = DateTime.Now; var result = sut.Perform(); @@ -257,7 +262,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations var before = default(DateTime); service.Setup(s => s.StopSession(It.IsAny())).Returns(new CommunicationResult(true)); - sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT); + sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT, userInfo.Object); PerformNormally(); @@ -339,7 +344,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations var before = default(DateTime); service.Setup(s => s.StopSession(It.IsAny())).Returns(new CommunicationResult(true)); - sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT); + sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, sessionContext, TIMEOUT, userInfo.Object); PerformNormally(); diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index 92524e4c..c690932d 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -71,6 +71,7 @@ namespace SafeExamBrowser.Runtime var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime); var sessionContext = new SessionContext(); var uiFactory = new UserInterfaceFactory(text); + var userInfo = new UserInfo(); var bootstrapOperations = new Queue(); var sessionOperations = new Queue(); @@ -80,7 +81,7 @@ namespace SafeExamBrowser.Runtime sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext)); sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext)); - sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS)); + 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 KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext)); sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS)); diff --git a/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs b/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs index 2c9339ff..38fc5140 100644 --- a/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ServiceOperation.cs @@ -17,6 +17,7 @@ using SafeExamBrowser.Contracts.Core.OperationModel; using SafeExamBrowser.Contracts.Core.OperationModel.Events; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.Logging; +using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.MessageBox; using SafeExamBrowser.Runtime.Operations.Events; @@ -28,6 +29,7 @@ namespace SafeExamBrowser.Runtime.Operations private IRuntimeHost runtimeHost; private IServiceProxy service; private int timeout_ms; + private IUserInfo userInfo; public override event ActionRequiredEventHandler ActionRequired; public override event StatusChangedEventHandler StatusChanged; @@ -37,12 +39,14 @@ namespace SafeExamBrowser.Runtime.Operations IRuntimeHost runtimeHost, IServiceProxy service, SessionContext sessionContext, - int timeout_ms) : base(sessionContext) + int timeout_ms, + IUserInfo userInfo) : base(sessionContext) { this.logger = logger; this.runtimeHost = runtimeHost; this.service = service; this.timeout_ms = timeout_ms; + this.userInfo = userInfo; } public override OperationResult Perform() @@ -162,7 +166,9 @@ namespace SafeExamBrowser.Runtime.Operations { AppConfig = Context.Next.AppConfig, SessionId = Context.Next.SessionId, - Settings = Context.Next.Settings + Settings = Context.Next.Settings, + UserName = userInfo.GetUserName(), + UserSid = userInfo.GetUserSid() }; var started = false; diff --git a/SafeExamBrowser.Service/CompositionRoot.cs b/SafeExamBrowser.Service/CompositionRoot.cs index af2caa32..189361ab 100644 --- a/SafeExamBrowser.Service/CompositionRoot.cs +++ b/SafeExamBrowser.Service/CompositionRoot.cs @@ -19,6 +19,7 @@ using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.Service; using SafeExamBrowser.Core.OperationModel; using SafeExamBrowser.Core.Operations; +using SafeExamBrowser.Lockdown; using SafeExamBrowser.Logging; using SafeExamBrowser.Service.Communication; using SafeExamBrowser.Service.Operations; @@ -38,6 +39,8 @@ namespace SafeExamBrowser.Service InitializeLogging(); + var featureBackup = new FeatureConfigurationBackup(new ModuleLogger(logger, nameof(FeatureConfigurationBackup))); + var featureFactory = new FeatureConfigurationFactory(new ModuleLogger(logger, nameof(FeatureConfigurationFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), new ModuleLogger(logger, nameof(ProxyFactory))); var serviceHost = new ServiceHost(SERVICE_ADDRESS, new HostObjectFactory(), new ModuleLogger(logger, nameof(ServiceHost)), FIVE_SECONDS); var sessionContext = new SessionContext(); @@ -50,7 +53,7 @@ namespace SafeExamBrowser.Service bootstrapOperations.Enqueue(new ServiceEventCleanupOperation(logger, sessionContext)); sessionOperations.Enqueue(new SessionInitializationOperation(logger, LogWriterFactory, ServiceEventFactory, serviceHost, sessionContext)); - sessionOperations.Enqueue(new LockdownOperation(logger, sessionContext)); + sessionOperations.Enqueue(new LockdownOperation(featureBackup, featureFactory, 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 index 92dee180..a84e001a 100644 --- a/SafeExamBrowser.Service/Operations/LockdownOperation.cs +++ b/SafeExamBrowser.Service/Operations/LockdownOperation.cs @@ -7,27 +7,86 @@ */ using SafeExamBrowser.Contracts.Core.OperationModel; +using SafeExamBrowser.Contracts.Lockdown; using SafeExamBrowser.Contracts.Logging; namespace SafeExamBrowser.Service.Operations { internal class LockdownOperation : SessionOperation { - private readonly ILogger logger; + private IFeatureConfigurationBackup backup; + private IFeatureConfigurationFactory factory; + private ILogger logger; - public LockdownOperation(ILogger logger, SessionContext sessionContext) : base(sessionContext) + public LockdownOperation( + IFeatureConfigurationBackup backup, + IFeatureConfigurationFactory factory, + ILogger logger, + SessionContext sessionContext) : base(sessionContext) { + this.backup = backup; + this.factory = factory; this.logger = logger; } public override OperationResult Perform() { + var chromeNotification = factory.CreateChromeNotificationConfiguration(); + var easeOfAccess = factory.CreateEaseOfAccessConfiguration(); + var networkOptions = factory.CreateNetworkOptionsConfiguration(); + var passwordChange = factory.CreatePasswordChangeConfiguration(); + var powerOptions = factory.CreatePowerOptionsConfiguration(); + var remoteConnection = factory.CreateRemoteConnectionConfiguration(); + var signout = factory.CreateSignoutConfiguration(); + var taskManager = factory.CreateTaskManagerConfiguration(); + var userLock = factory.CreateUserLockConfiguration(); + var userSwitch = factory.CreateUserSwitchConfiguration(); + var vmwareOverlay = factory.CreateVmwareOverlayConfiguration(); + var windowsUpdate = factory.CreateWindowsUpdateConfiguration(); + + SetConfiguration(chromeNotification, Context.Configuration.Settings.Service.DisableChromeNotifications); + SetConfiguration(easeOfAccess, Context.Configuration.Settings.Service.DisableEaseOfAccessOptions); + SetConfiguration(networkOptions, Context.Configuration.Settings.Service.DisableNetworkOptions); + SetConfiguration(passwordChange, Context.Configuration.Settings.Service.DisablePasswordChange); + SetConfiguration(powerOptions, Context.Configuration.Settings.Service.DisablePowerOptions); + SetConfiguration(remoteConnection, Context.Configuration.Settings.Service.DisableRemoteConnections); + SetConfiguration(signout, Context.Configuration.Settings.Service.DisableSignout); + SetConfiguration(taskManager, Context.Configuration.Settings.Service.DisableTaskManager); + SetConfiguration(userLock, Context.Configuration.Settings.Service.DisableUserLock); + SetConfiguration(userSwitch, Context.Configuration.Settings.Service.DisableUserSwitch); + SetConfiguration(vmwareOverlay, Context.Configuration.Settings.Service.DisableVmwareOverlay); + SetConfiguration(windowsUpdate, Context.Configuration.Settings.Service.DisableWindowsUpdate); + return OperationResult.Success; } public override OperationResult Revert() { + var configurations = backup.GetConfigurations(); + + foreach (var configuration in configurations) + { + configuration.Restore(); + backup.Delete(configuration); + } + return OperationResult.Success; } + + private void SetConfiguration(IFeatureConfiguration configuration, bool disable) + { + backup.Save(configuration); + + if (disable) + { + configuration.DisableFeature(); + } + else + { + configuration.EnableFeature(); + } + + configuration.Monitor(); + } } } diff --git a/SafeExamBrowser.Service/Operations/RestoreOperation.cs b/SafeExamBrowser.Service/Operations/RestoreOperation.cs index e150d3b1..1ec3f861 100644 --- a/SafeExamBrowser.Service/Operations/RestoreOperation.cs +++ b/SafeExamBrowser.Service/Operations/RestoreOperation.cs @@ -14,7 +14,7 @@ namespace SafeExamBrowser.Service.Operations { internal class RestoreOperation : IOperation { - private readonly ILogger logger; + private ILogger logger; public event ActionRequiredEventHandler ActionRequired { add { } remove { } } public event StatusChangedEventHandler StatusChanged { add { } remove { } } @@ -26,6 +26,9 @@ namespace SafeExamBrowser.Service.Operations public OperationResult Perform() { + // TODO: Must not delay startup! If restore does not succeed on first attempt, try again in separate thread! + // -> Ensure session cannot be started until values are restored or alike! + return OperationResult.Success; } diff --git a/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj b/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj index f3f1d3b2..3b0293a3 100644 --- a/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj +++ b/SafeExamBrowser.Service/SafeExamBrowser.Service.csproj @@ -93,6 +93,10 @@ {3d6fdbb6-a4af-4626-bb2b-bf329d44f9cc} SafeExamBrowser.Core + + {386b6042-3e12-4753-9fc6-c88ea4f97030} + SafeExamBrowser.Lockdown + {e107026c-2011-4552-a7d8-3a0d37881df6} SafeExamBrowser.Logging diff --git a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj index 434b961b..358078b7 100644 --- a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj +++ b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj @@ -64,6 +64,7 @@ + diff --git a/SafeExamBrowser.SystemComponents/UserInfo.cs b/SafeExamBrowser.SystemComponents/UserInfo.cs new file mode 100644 index 00000000..b16e80a3 --- /dev/null +++ b/SafeExamBrowser.SystemComponents/UserInfo.cs @@ -0,0 +1,27 @@ +/* + * 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 System; +using System.Security.Principal; +using SafeExamBrowser.Contracts.SystemComponents; + +namespace SafeExamBrowser.SystemComponents +{ + public class UserInfo : IUserInfo + { + public string GetUserName() + { + return Environment.UserName; + } + + public string GetUserSid() + { + return WindowsIdentity.GetCurrent().User.Value; + } + } +} diff --git a/SafeExamBrowser.sln b/SafeExamBrowser.sln index 55f233c1..44a1df3c 100644 --- a/SafeExamBrowser.sln +++ b/SafeExamBrowser.sln @@ -62,6 +62,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Service", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Service.UnitTests", "SafeExamBrowser.Service.UnitTests\SafeExamBrowser.Service.UnitTests.csproj", "{26C4AAEE-3902-400C-A154-63A357DEA2F8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Lockdown", "SafeExamBrowser.Lockdown\SafeExamBrowser.Lockdown.csproj", "{386B6042-3E12-4753-9FC6-C88EA4F97030}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -262,6 +264,14 @@ Global {26C4AAEE-3902-400C-A154-63A357DEA2F8}.Release|Any CPU.Build.0 = Release|Any CPU {26C4AAEE-3902-400C-A154-63A357DEA2F8}.Release|x86.ActiveCfg = Release|x86 {26C4AAEE-3902-400C-A154-63A357DEA2F8}.Release|x86.Build.0 = Release|x86 + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Debug|Any CPU.Build.0 = Debug|Any CPU + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Debug|x86.ActiveCfg = Debug|x86 + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Debug|x86.Build.0 = Debug|x86 + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Release|Any CPU.ActiveCfg = Release|Any CPU + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Release|Any CPU.Build.0 = Release|Any CPU + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Release|x86.ActiveCfg = Release|x86 + {386B6042-3E12-4753-9FC6-C88EA4F97030}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE