SEBWIN-301: Started implementing backup mechanism for service.

This commit is contained in:
dbuechel 2019-06-21 15:05:31 +02:00
parent 1c7c856c33
commit b96bbfcd78
34 changed files with 1019 additions and 59 deletions

View file

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

View file

@ -30,5 +30,15 @@ namespace SafeExamBrowser.Contracts.Configuration
/// The application settings to be used by the service.
/// </summary>
public Settings.Settings Settings { get; set; }
/// <summary>
/// The user name of the currently logged in user.
/// </summary>
public string UserName { get; set; }
/// <summary>
/// The security identifier of the currently logged in user.
/// </summary>
public string UserSid { get; set; }
}
}

View file

@ -13,56 +13,56 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
/// </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 the user can access the ease of access options on the security screen.
/// </summary>
public bool DisableEaseOfAccessOptions { get; set; }
/// <summary>
/// Determines whether the user can access the network options on the security screen.
/// </summary>
public bool DisableNetworkOptions { get; set; }
/// <summary>
/// Determines whether the user can change the password for a user account via the security screen.
/// </summary>
public bool DisablePasswordChange { get; set; }
/// <summary>
/// Determines whether the user can access the power options on the security screen.
/// </summary>
public bool DisablePowerOptions { get; set; }
/// <summary>
/// Determines whether remote desktop connections should be deactivated.
/// </summary>
public bool DisableRemoteConnections { get; set; }
/// <summary>
/// Determines whether the user can sign out of their account via the security screen.
/// </summary>
public bool DisableSignout { get; set; }
/// <summary>
/// Determines whether the user can access the task manager of Windows.
/// </summary>
public bool DisableTaskManager { get; set; }
/// <summary>
/// Determines whether the user can lock the computer via the security screen.
/// </summary>
public bool DisableUserLock { get; set; }
/// <summary>
/// Determines whether the user can switch to another user account via the security screen.
/// </summary>
public bool DisableUserSwitch { get; set; }
/// <summary>
/// Determines whether the user interface overlay for VMware clients should be deactivated.
/// </summary>

View file

@ -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
{
/// <summary>
/// Allows to control a feature of the computer, the operating system or an installed third-party software.
/// </summary>
public interface IFeatureConfiguration
{
/// <summary>
/// Disables the feature.
/// </summary>
void DisableFeature();
/// <summary>
/// Enables the feature.
/// </summary>
void EnableFeature();
/// <summary>
/// Starts monitoring the feature to ensure that it remains as currently configured.
/// </summary>
void Monitor();
/// <summary>
/// Restores the feature to its initial configuration.
/// </summary>
void Restore();
}
}

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 System.Collections.Generic;
namespace SafeExamBrowser.Contracts.Lockdown
{
/// <summary>
/// Defines the functionality of a backup repository for <see cref="IFeatureConfiguration"/>.
/// </summary>
public interface IFeatureConfigurationBackup
{
/// <summary>
/// Gets all <see cref="IFeatureConfiguration"/> currently saved in the backup repository.
/// </summary>
IList<IFeatureConfiguration> GetConfigurations();
/// <summary>
/// Saves the given <see cref="IFeatureConfiguration"/> in the backup repository.
/// </summary>
void Save(IFeatureConfiguration configuration);
/// <summary>
/// Deletes the given <see cref="IFeatureConfiguration"/> from the backup repository.
/// </summary>
void Delete(IFeatureConfiguration configuration);
}
}

View file

@ -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
{
/// <summary>
/// The factory for all <see cref="IFeatureConfiguration"/> currently supported.
/// </summary>
public interface IFeatureConfigurationFactory
{
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control notifications of the Google Chrome browser.
/// </summary>
IFeatureConfiguration CreateChromeNotificationConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the ease of access options on the security screen.
/// </summary>
IFeatureConfiguration CreateEaseOfAccessConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the network options on the security screen.
/// </summary>
IFeatureConfiguration CreateNetworkOptionsConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the option to change the password of a user account via the security screen.
/// </summary>
IFeatureConfiguration CreatePasswordChangeConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the power options on the security screen.
/// </summary>
IFeatureConfiguration CreatePowerOptionsConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control remote desktop connections.
/// </summary>
IFeatureConfiguration CreateRemoteConnectionConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the option to sign out out via security screen.
/// </summary>
IFeatureConfiguration CreateSignoutConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the task manager of Windows.
/// </summary>
IFeatureConfiguration CreateTaskManagerConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the option to lock the computer via the security screen.
/// </summary>
IFeatureConfiguration CreateUserLockConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the option to switch to another user account via the security screen.
/// </summary>
IFeatureConfiguration CreateUserSwitchConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control the user interface overlay for VMware clients.
/// </summary>
IFeatureConfiguration CreateVmwareOverlayConfiguration();
/// <summary>
/// Creates an <see cref="IFeatureConfiguration"/> to control Windows Update.
/// </summary>
IFeatureConfiguration CreateWindowsUpdateConfiguration();
}
}

View file

@ -92,6 +92,9 @@
<Compile Include="Applications\Events\NameChangedEventHandler.cs" />
<Compile Include="Applications\IApplicationController.cs" />
<Compile Include="Applications\InstanceIdentifier.cs" />
<Compile Include="Lockdown\IFeatureConfiguration.cs" />
<Compile Include="Lockdown\IFeatureConfigurationBackup.cs" />
<Compile Include="Lockdown\IFeatureConfigurationFactory.cs" />
<Compile Include="Runtime\IRuntimeController.cs" />
<Compile Include="Core\OperationModel\Events\ActionRequiredEventArgs.cs" />
<Compile Include="Core\OperationModel\Events\ActionRequiredEventHandler.cs" />
@ -154,6 +157,7 @@
<Compile Include="Client\INotificationInfo.cs" />
<Compile Include="Service\IServiceController.cs" />
<Compile Include="SystemComponents\ISystemInfo.cs" />
<Compile Include="SystemComponents\IUserInfo.cs" />
<Compile Include="SystemComponents\OperatingSystem.cs" />
<Compile Include="Configuration\Settings\BrowserSettings.cs" />
<Compile Include="Configuration\Settings\KeyboardSettings.cs" />

View file

@ -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
{
/// <summary>
/// Provides information about the currently logged in user.
/// </summary>
public interface IUserInfo
{
/// <summary>
/// Retrieves the name of the currently logged in user.
/// </summary>
string GetUserName();
/// <summary>
/// Retrieves the security identifier of the currently logged in user.
/// </summary>
string GetUserSid();
}
}

View file

@ -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<IFeatureConfiguration> GetConfigurations()
{
return new List<IFeatureConfiguration>();
}
public void Save(IFeatureConfiguration configuration)
{
}
}
}

View file

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

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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()
{
}
}
}

View file

@ -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")]

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{386B6042-3E12-4753-9FC6-C88EA4F97030}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SafeExamBrowser.Lockdown</RootNamespace>
<AssemblyName>SafeExamBrowser.Lockdown</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="FeatureConfigurationFactory.cs" />
<Compile Include="FeatureConfigurationBackup.cs" />
<Compile Include="FeatureConfigurations\ChromeNotificationConfiguration.cs" />
<Compile Include="FeatureConfigurations\TaskManagerConfiguration.cs" />
<Compile Include="FeatureConfigurations\EaseOfAccessConfiguration.cs" />
<Compile Include="FeatureConfigurations\NetworkOptionsConfiguration.cs" />
<Compile Include="FeatureConfigurations\PasswordChangeConfiguration.cs" />
<Compile Include="FeatureConfigurations\PowerOptionsConfiguration.cs" />
<Compile Include="FeatureConfigurations\RemoteConnectionConfiguration.cs" />
<Compile Include="FeatureConfigurations\SignoutConfiguration.cs" />
<Compile Include="FeatureConfigurations\UserLockConfiguration.cs" />
<Compile Include="FeatureConfigurations\UserSwitchConfiguration.cs" />
<Compile Include="FeatureConfigurations\VmwareOverlayConfiguration.cs" />
<Compile Include="FeatureConfigurations\WindowsUpdateConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
<Project>{47da5933-bef8-4729-94e6-abde2db12262}</Project>
<Name>SafeExamBrowser.Contracts</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -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<IUserInfo> 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<IUserInfo>();
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<ServiceConfiguration>()), 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<ServiceConfiguration>())).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<Guid>())).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<Guid>())).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();

View file

@ -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<IOperation>();
var sessionOperations = new Queue<IRepeatableOperation>();
@ -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));

View file

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

View file

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

View file

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

View file

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

View file

@ -93,6 +93,10 @@
<Project>{3d6fdbb6-a4af-4626-bb2b-bf329d44f9cc}</Project>
<Name>SafeExamBrowser.Core</Name>
</ProjectReference>
<ProjectReference Include="..\SafeExamBrowser.Lockdown\SafeExamBrowser.Lockdown.csproj">
<Project>{386b6042-3e12-4753-9fc6-c88ea4f97030}</Project>
<Name>SafeExamBrowser.Lockdown</Name>
</ProjectReference>
<ProjectReference Include="..\SafeExamBrowser.Logging\SafeExamBrowser.Logging.csproj">
<Project>{e107026c-2011-4552-a7d8-3a0d37881df6}</Project>
<Name>SafeExamBrowser.Logging</Name>

View file

@ -64,6 +64,7 @@
<Compile Include="PowerSupply.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemInfo.cs" />
<Compile Include="UserInfo.cs" />
<Compile Include="WirelessNetwork.cs" />
<Compile Include="WirelessNetworkDefinition.cs" />
</ItemGroup>

View file

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

View file

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