SEBWIN-821: Implemented configuration value for lock screen on user session change.
This commit is contained in:
parent
79dedf12b5
commit
27155a057d
11 changed files with 44 additions and 22 deletions
|
@ -1228,7 +1228,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
uiFactory.Setup(f => f.CreateLockScreen(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<LockScreenOption>>())).Returns(lockScreen.Object);
|
uiFactory.Setup(f => f.CreateLockScreen(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<LockScreenOption>>())).Returns(lockScreen.Object);
|
||||||
|
|
||||||
sut.TryStart();
|
sut.TryStart();
|
||||||
systemMonitor.Raise(m => m.SessionSwitched += null);
|
systemMonitor.Raise(m => m.SessionChanged += null);
|
||||||
|
|
||||||
lockScreen.Verify(l => l.Show(), Times.Once);
|
lockScreen.Verify(l => l.Show(), Times.Once);
|
||||||
}
|
}
|
||||||
|
@ -1248,7 +1248,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
.Returns(lockScreen.Object);
|
.Returns(lockScreen.Object);
|
||||||
|
|
||||||
sut.TryStart();
|
sut.TryStart();
|
||||||
systemMonitor.Raise(m => m.SessionSwitched += null);
|
systemMonitor.Raise(m => m.SessionChanged += null);
|
||||||
|
|
||||||
lockScreen.Verify(l => l.Show(), Times.Once);
|
lockScreen.Verify(l => l.Show(), Times.Once);
|
||||||
runtimeProxy.Verify(p => p.RequestShutdown(), Times.Once);
|
runtimeProxy.Verify(p => p.RequestShutdown(), Times.Once);
|
||||||
|
@ -1266,7 +1266,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
uiFactory.Setup(f => f.CreateLockScreen(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<LockScreenOption>>())).Returns(lockScreen.Object);
|
uiFactory.Setup(f => f.CreateLockScreen(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<LockScreenOption>>())).Returns(lockScreen.Object);
|
||||||
|
|
||||||
sut.TryStart();
|
sut.TryStart();
|
||||||
systemMonitor.Raise(m => m.SessionSwitched += null);
|
systemMonitor.Raise(m => m.SessionChanged += null);
|
||||||
|
|
||||||
lockScreen.Verify(l => l.Show(), Times.Never);
|
lockScreen.Verify(l => l.Show(), Times.Never);
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace SafeExamBrowser.Client
|
||||||
displayMonitor.DisplayChanged += DisplayMonitor_DisplaySettingsChanged;
|
displayMonitor.DisplayChanged += DisplayMonitor_DisplaySettingsChanged;
|
||||||
registry.ValueChanged += Registry_ValueChanged;
|
registry.ValueChanged += Registry_ValueChanged;
|
||||||
runtime.ConnectionLost += Runtime_ConnectionLost;
|
runtime.ConnectionLost += Runtime_ConnectionLost;
|
||||||
systemMonitor.SessionSwitched += SystemMonitor_SessionSwitched;
|
systemMonitor.SessionChanged += SystemMonitor_SessionChanged;
|
||||||
taskbar.LoseFocusRequested += Taskbar_LoseFocusRequested;
|
taskbar.LoseFocusRequested += Taskbar_LoseFocusRequested;
|
||||||
taskbar.QuitButtonClicked += Shell_QuitButtonClicked;
|
taskbar.QuitButtonClicked += Shell_QuitButtonClicked;
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ namespace SafeExamBrowser.Client
|
||||||
displayMonitor.DisplayChanged -= DisplayMonitor_DisplaySettingsChanged;
|
displayMonitor.DisplayChanged -= DisplayMonitor_DisplaySettingsChanged;
|
||||||
registry.ValueChanged -= Registry_ValueChanged;
|
registry.ValueChanged -= Registry_ValueChanged;
|
||||||
runtime.ConnectionLost -= Runtime_ConnectionLost;
|
runtime.ConnectionLost -= Runtime_ConnectionLost;
|
||||||
systemMonitor.SessionSwitched -= SystemMonitor_SessionSwitched;
|
systemMonitor.SessionChanged -= SystemMonitor_SessionChanged;
|
||||||
taskbar.QuitButtonClicked -= Shell_QuitButtonClicked;
|
taskbar.QuitButtonClicked -= Shell_QuitButtonClicked;
|
||||||
|
|
||||||
if (Browser != null)
|
if (Browser != null)
|
||||||
|
@ -838,21 +838,22 @@ namespace SafeExamBrowser.Client
|
||||||
ResumeActivators();
|
ResumeActivators();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemMonitor_SessionSwitched()
|
private void SystemMonitor_SessionChanged()
|
||||||
{
|
{
|
||||||
var allow = !Settings.Service.IgnoreService && (!Settings.Service.DisableUserLock || !Settings.Service.DisableUserSwitch);
|
var allow = !Settings.Service.IgnoreService && (!Settings.Service.DisableUserLock || !Settings.Service.DisableUserSwitch);
|
||||||
|
var disable = Settings.Security.DisableSessionChangeLockScreen;
|
||||||
var message = text.Get(TextKey.LockScreen_UserSessionMessage);
|
var message = text.Get(TextKey.LockScreen_UserSessionMessage);
|
||||||
var title = text.Get(TextKey.LockScreen_Title);
|
var title = text.Get(TextKey.LockScreen_Title);
|
||||||
var continueOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionContinueOption) };
|
var continueOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionContinueOption) };
|
||||||
var terminateOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionTerminateOption) };
|
var terminateOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionTerminateOption) };
|
||||||
|
|
||||||
if (allow)
|
if (allow || disable)
|
||||||
{
|
{
|
||||||
logger.Info("Detected user session switch, but user lock and/or user switch are allowed.");
|
logger.Info($"Detected user session change, but {(allow ? "session locking and/or switching is allowed" : "lock screen is deactivated")}.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warn("Detected user session switch!");
|
logger.Warn("Detected user session change!");
|
||||||
|
|
||||||
if (!sessionLocked)
|
if (!sessionLocked)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
case Keys.Security.ClipboardPolicy:
|
case Keys.Security.ClipboardPolicy:
|
||||||
MapClipboardPolicy(settings, value);
|
MapClipboardPolicy(settings, value);
|
||||||
break;
|
break;
|
||||||
|
case Keys.Security.DisableSessionChangeLockScreen:
|
||||||
|
MapDisableSessionChangeLockScreen(settings, value);
|
||||||
|
break;
|
||||||
case Keys.Security.QuitPasswordHash:
|
case Keys.Security.QuitPasswordHash:
|
||||||
MapQuitPasswordHash(settings, value);
|
MapQuitPasswordHash(settings, value);
|
||||||
break;
|
break;
|
||||||
|
@ -137,6 +140,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapDisableSessionChangeLockScreen(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is bool disable)
|
||||||
|
{
|
||||||
|
settings.Security.DisableSessionChangeLockScreen = disable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapVirtualMachinePolicy(AppSettings settings, object value)
|
private void MapVirtualMachinePolicy(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool allow)
|
if (value is bool allow)
|
||||||
|
|
|
@ -272,6 +272,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Security.AllowTermination = true;
|
settings.Security.AllowTermination = true;
|
||||||
settings.Security.AllowReconfiguration = false;
|
settings.Security.AllowReconfiguration = false;
|
||||||
settings.Security.ClipboardPolicy = ClipboardPolicy.Isolated;
|
settings.Security.ClipboardPolicy = ClipboardPolicy.Isolated;
|
||||||
|
settings.Security.DisableSessionChangeLockScreen = false;
|
||||||
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||||
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
|
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
internal const string AllowTermination = "allowQuit";
|
internal const string AllowTermination = "allowQuit";
|
||||||
internal const string AllowVirtualMachine = "allowVirtualMachine";
|
internal const string AllowVirtualMachine = "allowVirtualMachine";
|
||||||
internal const string ClipboardPolicy = "clipboardPolicy";
|
internal const string ClipboardPolicy = "clipboardPolicy";
|
||||||
|
internal const string DisableSessionChangeLockScreen = "disableSessionChangeLockScreen";
|
||||||
internal const string KioskModeCreateNewDesktop = "createNewDesktop";
|
internal const string KioskModeCreateNewDesktop = "createNewDesktop";
|
||||||
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
|
internal const string KioskModeDisableExplorerShell = "killExplorerShell";
|
||||||
internal const string QuitPasswordHash = "hashedQuitPassword";
|
internal const string QuitPasswordHash = "hashedQuitPassword";
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
<Compile Include="Applications\InitializationResult.cs" />
|
<Compile Include="Applications\InitializationResult.cs" />
|
||||||
<Compile Include="Applications\IApplicationMonitor.cs" />
|
<Compile Include="Applications\IApplicationMonitor.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="System\Events\SessionSwitchedEventHandler.cs" />
|
<Compile Include="System\Events\SessionChangedEventHandler.cs" />
|
||||||
<Compile Include="System\ISystemMonitor.cs" />
|
<Compile Include="System\ISystemMonitor.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -11,5 +11,5 @@ namespace SafeExamBrowser.Monitoring.Contracts.System.Events
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that the active user session of the operating system has changed.
|
/// Indicates that the active user session of the operating system has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate void SessionSwitchedEventHandler();
|
public delegate void SessionChangedEventHandler();
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ namespace SafeExamBrowser.Monitoring.Contracts.System
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when the active user session has changed.
|
/// Event fired when the active user session has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event SessionSwitchedEventHandler SessionSwitched;
|
event SessionChangedEventHandler SessionChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts the monitoring.
|
/// Starts the monitoring.
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace SafeExamBrowser.Monitoring.System
|
||||||
{
|
{
|
||||||
private readonly ILogger logger;
|
private readonly ILogger logger;
|
||||||
|
|
||||||
public event SessionSwitchedEventHandler SessionSwitched;
|
public event SessionChangedEventHandler SessionChanged;
|
||||||
|
|
||||||
public SystemMonitor(ILogger logger)
|
public SystemMonitor(ILogger logger)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace SafeExamBrowser.Monitoring.System
|
||||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||||
SystemEvents.SessionEnded += SystemEvents_SessionEnded;
|
SystemEvents.SessionEnded += SystemEvents_SessionEnded;
|
||||||
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
|
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
|
||||||
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
|
SystemEvents.SessionSwitch += SystemEvents_SessionChanged;
|
||||||
SystemEvents.TimeChanged += SystemEvents_TimeChanged;
|
SystemEvents.TimeChanged += SystemEvents_TimeChanged;
|
||||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||||
logger.Info("Started monitoring the operating system.");
|
logger.Info("Started monitoring the operating system.");
|
||||||
|
@ -46,7 +46,7 @@ namespace SafeExamBrowser.Monitoring.System
|
||||||
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||||
SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
||||||
SystemEvents.SessionEnding -= SystemEvents_SessionEnding;
|
SystemEvents.SessionEnding -= SystemEvents_SessionEnding;
|
||||||
SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
|
SystemEvents.SessionSwitch -= SystemEvents_SessionChanged;
|
||||||
SystemEvents.TimeChanged -= SystemEvents_TimeChanged;
|
SystemEvents.TimeChanged -= SystemEvents_TimeChanged;
|
||||||
SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
|
SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
|
||||||
logger.Info("Stopped monitoring the operating system.");
|
logger.Info("Stopped monitoring the operating system.");
|
||||||
|
@ -64,23 +64,23 @@ namespace SafeExamBrowser.Monitoring.System
|
||||||
|
|
||||||
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
{
|
{
|
||||||
logger.Info($"Power mode changed: {e.Mode}");
|
logger.Info($"Power mode changed: {e.Mode}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEvents_SessionEnded(object sender, SessionEndedEventArgs e)
|
private void SystemEvents_SessionEnded(object sender, SessionEndedEventArgs e)
|
||||||
{
|
{
|
||||||
logger.Warn($"User session ended! Reason: {e.Reason}");
|
logger.Warn($"User session ended! Reason: {e.Reason}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
|
private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
|
||||||
{
|
{
|
||||||
logger.Warn($"User session is ending! Reason: {e.Reason}");
|
logger.Warn($"User session is ending! Reason: {e.Reason}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
|
private void SystemEvents_SessionChanged(object sender, SessionSwitchEventArgs e)
|
||||||
{
|
{
|
||||||
logger.Info($"User session switch detected! Reason: {e.Reason}");
|
logger.Info($"User session change detected: {e.Reason}.");
|
||||||
Task.Run(() => SessionSwitched?.Invoke());
|
Task.Run(() => SessionChanged?.Invoke());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEvents_TimeChanged(object sender, EventArgs e)
|
private void SystemEvents_TimeChanged(object sender, EventArgs e)
|
||||||
|
@ -90,7 +90,7 @@ namespace SafeExamBrowser.Monitoring.System
|
||||||
|
|
||||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||||
{
|
{
|
||||||
logger.Info($"User preference changed. Category: {e.Category}");
|
logger.Info($"User preference changed. Category: {e.Category}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,12 @@ namespace SafeExamBrowser.Settings.Security
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ClipboardPolicy ClipboardPolicy { get; set; }
|
public ClipboardPolicy ClipboardPolicy { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the lock screen is disabled in case of a user session change. This setting overrides the activation based on
|
||||||
|
/// <see cref="Service.ServiceSettings.IgnoreService"/> and <see cref="Service.ServiceSettings.DisableUserLock"/> or <see cref="Service.ServiceSettings.DisableUserSwitch"/>.
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableSessionChangeLockScreen { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The kiosk mode which determines how the computer is locked down.
|
/// The kiosk mode which determines how the computer is locked down.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -379,6 +379,7 @@ namespace SebWindowsConfig
|
||||||
public const String KeyAllowWindowsUpdate = "enableWindowsUpdate";
|
public const String KeyAllowWindowsUpdate = "enableWindowsUpdate";
|
||||||
public const String KeyVersionRestrictions = "sebAllowedVersions";
|
public const String KeyVersionRestrictions = "sebAllowedVersions";
|
||||||
public const String KeyClipboardPolicy = "clipboardPolicy";
|
public const String KeyClipboardPolicy = "clipboardPolicy";
|
||||||
|
public const String KeyDisableSessionChangeLockScreen = "disableSessionChangeLockScreen";
|
||||||
|
|
||||||
// Group "macOS specific settings"
|
// Group "macOS specific settings"
|
||||||
public const String KeyMinMacOSVersion = "minMacOSVersion";
|
public const String KeyMinMacOSVersion = "minMacOSVersion";
|
||||||
|
@ -1013,6 +1014,7 @@ namespace SebWindowsConfig
|
||||||
SEBSettings.settingsDefault.Add(SEBSettings.KeyAllowChromeNotifications, false);
|
SEBSettings.settingsDefault.Add(SEBSettings.KeyAllowChromeNotifications, false);
|
||||||
SEBSettings.settingsDefault.Add(SEBSettings.KeyAllowWindowsUpdate, false);
|
SEBSettings.settingsDefault.Add(SEBSettings.KeyAllowWindowsUpdate, false);
|
||||||
SEBSettings.settingsDefault.Add(SEBSettings.KeyClipboardPolicy, 2);
|
SEBSettings.settingsDefault.Add(SEBSettings.KeyClipboardPolicy, 2);
|
||||||
|
SEBSettings.settingsDefault.Add(SEBSettings.KeyDisableSessionChangeLockScreen, false);
|
||||||
|
|
||||||
// Default selected index and string in combo box for minMacOSVersion
|
// Default selected index and string in combo box for minMacOSVersion
|
||||||
SEBSettings.intArrayDefault[SEBSettings.ValMinMacOSVersion] = 4;
|
SEBSettings.intArrayDefault[SEBSettings.ValMinMacOSVersion] = 4;
|
||||||
|
|
Loading…
Reference in a new issue