diff --git a/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs index 92a2d009..5111f7cb 100644 --- a/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs +++ b/SafeExamBrowser.Contracts/Lockdown/IFeatureConfigurationFactory.cs @@ -41,16 +41,16 @@ namespace SafeExamBrowser.Contracts.Lockdown /// IFeatureConfiguration CreateLockWorkstationConfiguration(Guid groupId, string sid, string userName); + /// + /// Creates an to control the power options on the security screen. + /// + IFeatureConfiguration CreateMachinePowerOptionsConfiguration(Guid groupId); + /// /// Creates an to control the network options on the security screen. /// IFeatureConfiguration CreateNetworkOptionsConfiguration(Guid groupId); - /// - /// Creates an to control the power options on the security screen. - /// - IFeatureConfiguration CreatePowerOptionsConfiguration(Guid groupId); - /// /// Creates an to control remote desktop connections. /// @@ -71,6 +71,11 @@ namespace SafeExamBrowser.Contracts.Lockdown /// IFeatureConfiguration CreateTaskManagerConfiguration(Guid groupId, string sid, string userName); + /// + /// Creates an to control the power options in the start menu. + /// + IFeatureConfiguration CreateUserPowerOptionsConfiguration(Guid groupId, string sid, string userName); + /// /// Creates an to control the user interface overlay for VMware clients. /// diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs b/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs index 906e2f0f..eda1d343 100644 --- a/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs +++ b/SafeExamBrowser.Lockdown/FeatureConfigurationFactory.cs @@ -33,12 +33,13 @@ namespace SafeExamBrowser.Lockdown CreateChromeNotificationConfiguration(groupId, sid, userName), CreateEaseOfAccessConfiguration(groupId), CreateLockWorkstationConfiguration(groupId, sid, userName), + CreateMachinePowerOptionsConfiguration(groupId), CreateNetworkOptionsConfiguration(groupId), - CreatePowerOptionsConfiguration(groupId), CreateRemoteConnectionConfiguration(groupId), CreateSignoutConfiguration(groupId, sid, userName), CreateSwitchUserConfiguration(groupId), CreateTaskManagerConfiguration(groupId, sid, userName), + CreateUserPowerOptionsConfiguration(groupId, sid, userName), CreateVmwareOverlayConfiguration(groupId, sid, userName), CreateWindowsUpdateConfiguration(groupId) }; @@ -64,16 +65,16 @@ namespace SafeExamBrowser.Lockdown return new LockWorkstationConfiguration(groupId, logger.CloneFor(nameof(LockWorkstationConfiguration)), sid, userName); } + public IFeatureConfiguration CreateMachinePowerOptionsConfiguration(Guid groupId) + { + return new MachinePowerOptionsConfiguration(groupId, logger.CloneFor(nameof(MachinePowerOptionsConfiguration))); + } + public IFeatureConfiguration CreateNetworkOptionsConfiguration(Guid groupId) { return new NetworkOptionsConfiguration(groupId, logger.CloneFor(nameof(NetworkOptionsConfiguration))); } - public IFeatureConfiguration CreatePowerOptionsConfiguration(Guid groupId) - { - return new PowerOptionsConfiguration(groupId, logger.CloneFor(nameof(PowerOptionsConfiguration))); - } - public IFeatureConfiguration CreateRemoteConnectionConfiguration(Guid groupId) { return new RemoteConnectionConfiguration(groupId, logger.CloneFor(nameof(RemoteConnectionConfiguration))); @@ -94,6 +95,11 @@ namespace SafeExamBrowser.Lockdown return new TaskManagerConfiguration(groupId, logger.CloneFor(nameof(TaskManagerConfiguration)), sid, userName); } + public IFeatureConfiguration CreateUserPowerOptionsConfiguration(Guid groupId, string sid, string userName) + { + return new UserPowerOptionsConfiguration(groupId, logger.CloneFor(nameof(UserPowerOptionsConfiguration)), sid, userName); + } + public IFeatureConfiguration CreateVmwareOverlayConfiguration(Guid groupId, string sid, string userName) { return new VmwareOverlayConfiguration(groupId, logger.CloneFor(nameof(VmwareOverlayConfiguration)), sid, userName); diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/PowerOptionsConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/MachinePowerOptionsConfiguration.cs similarity index 82% rename from SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/PowerOptionsConfiguration.cs rename to SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/MachinePowerOptionsConfiguration.cs index eb7d7652..750c03d2 100644 --- a/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/PowerOptionsConfiguration.cs +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/MachineHive/MachinePowerOptionsConfiguration.cs @@ -13,14 +13,14 @@ using SafeExamBrowser.Contracts.Logging; namespace SafeExamBrowser.Lockdown.FeatureConfigurations.RegistryConfigurations.MachineHive { [Serializable] - internal class PowerOptionsConfiguration : MachineHiveConfiguration + internal class MachinePowerOptionsConfiguration : MachineHiveConfiguration { protected override IEnumerable Items => new [] { new RegistryConfigurationItem(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoClose", 1, 0) }; - public PowerOptionsConfiguration(Guid groupId, ILogger logger) : base(groupId, logger) + public MachinePowerOptionsConfiguration(Guid groupId, ILogger logger) : base(groupId, logger) { } diff --git a/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/UserHive/UserPowerOptionsConfiguration.cs b/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/UserHive/UserPowerOptionsConfiguration.cs new file mode 100644 index 00000000..3c8f6639 --- /dev/null +++ b/SafeExamBrowser.Lockdown/FeatureConfigurations/RegistryConfigurations/UserHive/UserPowerOptionsConfiguration.cs @@ -0,0 +1,32 @@ +/* + * 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.Collections.Generic; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Lockdown.FeatureConfigurations.RegistryConfigurations.UserHive +{ + [Serializable] + internal class UserPowerOptionsConfiguration : UserHiveConfiguration + { + protected override IEnumerable Items => new[] + { + new RegistryConfigurationItem($@"HKEY_USERS\{SID}\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoClose", 1, 0) + }; + + public UserPowerOptionsConfiguration(Guid groupId, ILogger logger, string sid, string userName) : base(groupId, logger, sid, userName) + { + } + + public override bool Reset() + { + return DeleteConfiguration(); + } + } +} diff --git a/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj b/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj index c9209690..41b3a2ae 100644 --- a/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj +++ b/SafeExamBrowser.Lockdown/SafeExamBrowser.Lockdown.csproj @@ -64,12 +64,13 @@ + - + diff --git a/SafeExamBrowser.Service.UnitTests/Operations/LockdownOperationTests.cs b/SafeExamBrowser.Service.UnitTests/Operations/LockdownOperationTests.cs index 6064b299..5d508652 100644 --- a/SafeExamBrowser.Service.UnitTests/Operations/LockdownOperationTests.cs +++ b/SafeExamBrowser.Service.UnitTests/Operations/LockdownOperationTests.cs @@ -56,7 +56,7 @@ namespace SafeExamBrowser.Service.UnitTests.Operations configuration.SetReturnsDefault(true); factory.SetReturnsDefault(configuration.Object); settings.Service.DisableChromeNotifications = true; - settings.Service.DisablePowerOptions = true; + settings.Service.DisableEaseOfAccessOptions = true; settings.Service.DisableSignout = true; var result = sut.Perform(); @@ -91,12 +91,13 @@ namespace SafeExamBrowser.Service.UnitTests.Operations factory.Verify(f => f.CreateChromeNotificationConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); factory.Verify(f => f.CreateEaseOfAccessConfiguration(It.Is(id => id == groupId)), Times.Once); factory.Verify(f => f.CreateLockWorkstationConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); + factory.Verify(f => f.CreateMachinePowerOptionsConfiguration(It.Is(id => id == groupId)), Times.Once); factory.Verify(f => f.CreateNetworkOptionsConfiguration(It.Is(id => id == groupId)), Times.Once); - factory.Verify(f => f.CreatePowerOptionsConfiguration(It.Is(id => id == groupId)), Times.Once); factory.Verify(f => f.CreateRemoteConnectionConfiguration(It.Is(id => id == groupId)), Times.Once); factory.Verify(f => f.CreateSignoutConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); factory.Verify(f => f.CreateSwitchUserConfiguration(It.Is(id => id == groupId)), Times.Once); factory.Verify(f => f.CreateTaskManagerConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); + factory.Verify(f => f.CreateUserPowerOptionsConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); factory.Verify(f => f.CreateVmwareOverlayConfiguration(It.Is(id => id == groupId), It.IsAny(), It.IsAny()), Times.Once); factory.Verify(f => f.CreateWindowsUpdateConfiguration(It.Is(id => id == groupId)), Times.Once); } diff --git a/SafeExamBrowser.Service/Operations/LockdownOperation.cs b/SafeExamBrowser.Service/Operations/LockdownOperation.cs index 15fce865..823e6ea9 100644 --- a/SafeExamBrowser.Service/Operations/LockdownOperation.cs +++ b/SafeExamBrowser.Service/Operations/LockdownOperation.cs @@ -47,12 +47,13 @@ namespace SafeExamBrowser.Service.Operations (factory.CreateChromeNotificationConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableChromeNotifications), (factory.CreateEaseOfAccessConfiguration(groupId), Context.Configuration.Settings.Service.DisableEaseOfAccessOptions), (factory.CreateLockWorkstationConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableUserLock), + (factory.CreateMachinePowerOptionsConfiguration(groupId), Context.Configuration.Settings.Service.DisablePowerOptions), (factory.CreateNetworkOptionsConfiguration(groupId), Context.Configuration.Settings.Service.DisableNetworkOptions), - (factory.CreatePowerOptionsConfiguration(groupId), Context.Configuration.Settings.Service.DisablePowerOptions), (factory.CreateRemoteConnectionConfiguration(groupId), Context.Configuration.Settings.Service.DisableRemoteConnections), (factory.CreateSignoutConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableSignout), (factory.CreateSwitchUserConfiguration(groupId), Context.Configuration.Settings.Service.DisableUserSwitch), (factory.CreateTaskManagerConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableTaskManager), + (factory.CreateUserPowerOptionsConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisablePowerOptions), (factory.CreateVmwareOverlayConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableVmwareOverlay), (factory.CreateWindowsUpdateConfiguration(groupId), Context.Configuration.Settings.Service.DisableWindowsUpdate) };