Restore SEBPatch

This commit is contained in:
2025-06-01 11:44:20 +02:00
commit 8c656e3137
1297 changed files with 142172 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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;
namespace SafeExamBrowser.Configuration.Contracts
{
/// <summary>
/// Defines the fundamental, global configuration information for all application components.
/// </summary>
[Serializable]
public class AppConfig
{
/// <summary>
/// The name of the backup data file used by the service component.
/// </summary>
public const string BACKUP_FILE_NAME = "Backup.bin";
/// <summary>
/// The base address for all communication hosts of the application.
/// </summary>
public const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser";
/// <summary>
/// The name of the synchronization primitive for the client component.
/// </summary>
public const string CLIENT_MUTEX_NAME = "safe_exam_browser_client_mutex";
/// <summary>
/// The name of the synchronization primitive for the runtime component.
/// </summary>
public const string RUNTIME_MUTEX_NAME = "safe_exam_browser_runtime_mutex";
/// <summary>
/// The communication address of the service component.
/// </summary>
public const string SERVICE_ADDRESS = BASE_ADDRESS + "/service";
/// <summary>
/// The name of the synchronization primitive for the service component.
/// </summary>
public const string SERVICE_MUTEX_NAME = "safe_exam_browser_reset_mutex";
/// <summary>
/// The file path of the local client configuration for the active user.
/// </summary>
public string AppDataFilePath { get; set; }
/// <summary>
/// The point in time when the application was started.
/// </summary>
public DateTime ApplicationStartTime { get; set; }
/// <summary>
/// The path where the browser cache is to be stored.
/// </summary>
public string BrowserCachePath { get; set; }
/// <summary>
/// The file path under which the log of the browser component is to be stored.
/// </summary>
public string BrowserLogFilePath { get; set; }
/// <summary>
/// The communication address of the client component.
/// </summary>
public string ClientAddress { get; set; }
/// <summary>
/// The executable path of the client compontent.
/// </summary>
public string ClientExecutablePath { get; set; }
/// <summary>
/// The unique identifier for the currently running client instance.
/// </summary>
public Guid ClientId { get; set; }
/// <summary>
/// The file path under which the log of the client component is to be stored.
/// </summary>
public string ClientLogFilePath { get; set; }
/// <summary>
/// The hash value of the certificate used to sign the application binaries, or <c>null</c> if the binaries are unsigned.
/// </summary>
public string CodeSignatureHash { get; set; }
/// <summary>
/// The file extension of configuration files for the application (including the period).
/// </summary>
public string ConfigurationFileExtension { get; set; }
/// <summary>
/// The MIME type of configuration files for the application.
/// </summary>
public string ConfigurationFileMimeType { get; set; }
/// <summary>
/// The build version of the application.
/// </summary>
public string ProgramBuildVersion { get; set; }
/// <summary>
/// The copyright information for the application.
/// </summary>
public string ProgramCopyright { get; set; }
/// <summary>
/// The file path of the local client configuration for all users.
/// </summary>
public string ProgramDataFilePath { get; set; }
/// <summary>
/// The program title of the application.
/// </summary>
public string ProgramTitle { get; set; }
/// <summary>
/// The informational version of the application.
/// </summary>
public string ProgramInformationalVersion { get; set; }
/// <summary>
/// The communication address of the runtime component.
/// </summary>
public string RuntimeAddress { get; set; }
/// <summary>
/// The unique identifier for the currently running runtime instance.
/// </summary>
public Guid RuntimeId { get; set; }
/// <summary>
/// The file path under which the log of the runtime component is to be stored.
/// </summary>
public string RuntimeLogFilePath { get; set; }
/// <summary>
/// The URI scheme for SEB resources.
/// </summary>
public string SebUriScheme { get; set; }
/// <summary>
/// The URI scheme for secure SEB resources.
/// </summary>
public string SebUriSchemeSecure { get; set; }
/// <summary>
/// The server API as JSON string.
/// </summary>
public string ServerApi { get; set; }
/// <summary>
/// The connection token for a server.
/// </summary>
public string ServerConnectionToken { get; set; }
/// <summary>
/// The identifier of the selected server exam.
/// </summary>
public string ServerExamId { get; set; }
/// <summary>
/// The OAuth2 token for a server.
/// </summary>
public string ServerOauth2Token { get; set; }
/// <summary>
/// The communication address of the service component.
/// </summary>
public string ServiceAddress { get; set; }
/// <summary>
/// The name of the global inter-process synchronization event hosted by the service.
/// </summary>
public string ServiceEventName { get; set; }
/// <summary>
/// The file path under which the log for the current session of the service component is to be stored.
/// </summary>
public string ServiceLogFilePath { get; set; }
/// <summary>
/// The file path under which the session cache is to be stored.
/// </summary>
public string SessionCacheFilePath { get; set; }
/// <summary>
/// The directory to be used for temporary application data.
/// </summary>
public string TemporaryDirectory { get; set; }
/// <summary>
/// Creates a shallow clone.
/// </summary>
public AppConfig Clone()
{
return MemberwiseClone() as AppConfig;
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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 SafeExamBrowser.Settings;
namespace SafeExamBrowser.Configuration.Contracts
{
/// <summary>
/// The configuration for a session of the client application component.
/// </summary>
[Serializable]
public class ClientConfiguration
{
/// <summary>
/// The global application configuration.
/// </summary>
public AppConfig AppConfig { get; set; }
/// <summary>
/// The unique identifier for the current session.
/// </summary>
public Guid SessionId { get; set; }
/// <summary>
/// The application settings to be used by the client.
/// </summary>
public AppSettings Settings { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography
{
/// <summary>
/// Holds the cryptographic parameters used to encrypt configuration data.
/// </summary>
public abstract class EncryptionParameters
{
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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 System.Security.Cryptography.X509Certificates;
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
{
/// <summary>
/// Provides functionality related to certificates installed on the computer.
/// </summary>
public interface ICertificateStore
{
/// <summary>
/// Attempts to retrieve the certificate which matches the specified public key hash value.
/// Returns <c>true</c> if the certificate was found, otherwise <c>false</c>.
/// </summary>
bool TryGetCertificateWith(byte[] keyHash, out X509Certificate2 certificate);
/// <summary>
/// Extracts all identity certificates from the given configuration data and installs them on the computer.
/// </summary>
void ExtractAndImportIdentities(IDictionary<string, object> data);
}
}

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography
{
/// <summary>
/// Provides functionality to calculate hash codes of different objects.
/// </summary>
public interface IHashAlgorithm
{
/// <summary>
/// Computes a hash code for the given password.
/// </summary>
string GenerateHashFor(string password);
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography
{
/// <summary>
/// Provides funcionality to calculate keys for integrity checks.
/// </summary>
public interface IKeyGenerator
{
/// <summary>
/// Calculates the encrypted value of the app signature key.
/// </summary>
string CalculateAppSignatureKey(string connectionToken, string salt);
/// <summary>
/// Calculates the hash value of the browser exam key (BEK) for the given URL.
/// </summary>
string CalculateBrowserExamKeyHash(string configurationKey, byte[] salt, string url);
/// <summary>
/// Calculates the hash value of the configuration key (CK) for the given URL.
/// </summary>
string CalculateConfigurationKeyHash(string configurationKey, string url);
/// <summary>
/// Specifies that a custom browser exam key (BEK) should be used.
/// </summary>
void UseCustomBrowserExamKey(string browserExamKey);
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
{
/// <summary>
/// Encrypts and decrypts data with a password.
/// </summary>
public interface IPasswordEncryption
{
/// <summary>
/// Attempts to decrypt the given data. The decrypted data stream can only be considered valid if <see cref="LoadStatus.Success"/>
/// is returned!
/// </summary>
LoadStatus Decrypt(Stream data, string password, out Stream decrypted);
/// <summary>
/// Attempts to encrypt the given data. The encrypted data stream can only be considered valid if <see cref="SaveStatus.Success"/>
/// is returned.
/// </summary>
SaveStatus Encrypt(Stream data, string password, out Stream encrypted);
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
using System.Security.Cryptography.X509Certificates;
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
{
/// <summary>
/// Encrypts and decrypts data with a certificate.
/// </summary>
public interface IPublicKeyEncryption
{
/// <summary>
/// Attempts to decrypt the given data. The decrypted data stream and the certificate can only be considered valid if
/// <see cref="LoadStatus.Success"/> is returned!
/// </summary>
LoadStatus Decrypt(Stream data, out Stream decrypted, out X509Certificate2 certificate);
/// <summary>
/// Attempts to encrypt the given data. The encrypted data stream can only be considered valid if <see cref="SaveStatus.Success"/>
/// is returned.
/// </summary>
SaveStatus Encrypt(Stream data, X509Certificate2 certificate, out Stream encrypted);
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography
{
/// <summary>
/// Holds all parameters for data encryption by password.
/// </summary>
public class PasswordParameters : EncryptionParameters
{
/// <summary>
/// The password in plain text.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Indicates whether the password is a hash code.
/// </summary>
public bool IsHash { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Security.Cryptography.X509Certificates;
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
{
/// <summary>
/// Holds all parameters for data encryption by certificate.
/// </summary>
public class PublicKeyParameters : EncryptionParameters
{
/// <summary>
/// The certificate holding the public key used for encryption.
/// </summary>
public X509Certificate2 Certificate { get; set; }
/// <summary>
/// The encryption parameters of the inner data, if available.
/// </summary>
public PasswordParameters InnerEncryption { get; set; }
/// <summary>
/// Determines the usage of symmetric vs. asymmetric encryption.
/// </summary>
public bool SymmetricEncryption { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
namespace SafeExamBrowser.Configuration.Contracts.DataCompression
{
/// <summary>
/// Defines the functionality for data compression and decompression.
/// </summary>
public interface IDataCompressor
{
/// <summary>
/// Compresses the data from the given stream.
/// </summary>
Stream Compress(Stream data);
/// <summary>
/// Decompresses the data from the given stream.
/// </summary>
Stream Decompress(Stream data);
/// <summary>
/// Indicates whether the given stream holds compressed data.
/// </summary>
bool IsCompressed(Stream data);
/// <summary>
/// Decompresses the specified number of bytes from the beginning of the given stream.
/// </summary>
byte[] Peek(Stream data, int count);
}
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.DataFormats
{
/// <summary>
/// Defines all supported data formats.
/// </summary>
public enum FormatType
{
Binary = 1,
Xml
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
using SafeExamBrowser.Configuration.Contracts.Cryptography;
namespace SafeExamBrowser.Configuration.Contracts.DataFormats
{
/// <summary>
/// Provides functionality to parse configuration data with a particular format.
/// </summary>
public interface IDataParser
{
/// <summary>
/// Indicates whether the given data complies with the required format.
/// </summary>
bool CanParse(Stream data);
/// <summary>
/// Tries to parse the given data.
/// </summary>
ParseResult TryParse(Stream data, PasswordParameters password = null);
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography;
namespace SafeExamBrowser.Configuration.Contracts.DataFormats
{
/// <summary>
/// Provides functionality to serialize configuration data to a particular format.
/// </summary>
public interface IDataSerializer
{
/// <summary>
/// Indicates whether data can be serialized to the given format.
/// </summary>
bool CanSerialize(FormatType format);
/// <summary>
/// Tries to serialize the given data.
/// </summary>
SerializeResult TrySerialize(IDictionary<string, object> data, EncryptionParameters encryption = null);
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Cryptography;
namespace SafeExamBrowser.Configuration.Contracts.DataFormats
{
/// <summary>
/// Defines the result of a data parsing operation by an <see cref="IDataParser"/>.
/// </summary>
public class ParseResult
{
/// <summary>
/// The encryption parameters which were used to decrypt the data, or <c>null</c> if it was not encrypted.
/// </summary>
public EncryptionParameters Encryption { get; set; }
/// <summary>
/// The original format of the data.
/// </summary>
public FormatType Format { get; set; }
/// <summary>
/// The parsed settings data. Might be <c>null</c> or in an undefinable state, depending on <see cref="Status"/>.
/// </summary>
public IDictionary<string, object> RawData { get; set; }
/// <summary>
/// The status result of the parsing operation.
/// </summary>
public LoadStatus Status { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
namespace SafeExamBrowser.Configuration.Contracts.DataFormats
{
/// <summary>
/// Defines the result of a data serialization operation by an <see cref="IDataSerializer"/>.
/// </summary>
public class SerializeResult
{
/// <summary>
/// The serialized data. Might be <c>null</c> or in an undefinable state, depending on <see cref="Status"/>.
/// </summary>
public Stream Data { get; set; }
/// <summary>
/// The status result of the serialization operation.
/// </summary>
public SaveStatus Status { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
namespace SafeExamBrowser.Configuration.Contracts.DataResources
{
/// <summary>
/// Provides functionality to load configuration data from a particular resource type.
/// </summary>
public interface IResourceLoader
{
/// <summary>
/// Indicates whether data can be loaded from the specified resource.
/// </summary>
bool CanLoad(Uri resource);
/// <summary>
/// Tries to load the configuration data from the specified resource.
/// </summary>
LoadStatus TryLoad(Uri resource, out Stream data);
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.IO;
namespace SafeExamBrowser.Configuration.Contracts.DataResources
{
/// <summary>
/// Provides functionality to save configuration data as a particular resource type.
/// </summary>
public interface IResourceSaver
{
/// <summary>
/// Indicates whether data can be saved as the specified resource.
/// </summary>
bool CanSave(Uri destination);
/// <summary>
/// Tries to save the configuration data as the specified resource.
/// </summary>
SaveStatus TrySave(Uri destination, Stream data);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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 SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.Configuration.Contracts.DataFormats;
using SafeExamBrowser.Configuration.Contracts.DataResources;
using SafeExamBrowser.Settings;
namespace SafeExamBrowser.Configuration.Contracts
{
/// <summary>
/// The repository which controls the loading and saving of configuration data.
/// </summary>
public interface IConfigurationRepository
{
/// <summary>
/// Attempts to save the given resource as local client configuration.
/// </summary>
SaveStatus ConfigureClientWith(Uri resource, PasswordParameters password = null);
/// <summary>
/// Initializes the global configuration information for the currently running application instance.
/// </summary>
AppConfig InitializeAppConfig();
/// <summary>
/// Initializes all relevant configuration data for a new session.
/// </summary>
SessionConfiguration InitializeSessionConfiguration();
/// <summary>
/// Loads the default settings.
/// </summary>
AppSettings LoadDefaultSettings();
/// <summary>
/// Registers the specified <see cref="IDataParser"/> to be used to parse configuration data.
/// </summary>
void Register(IDataParser parser);
/// <summary>
/// Registers the specified <see cref="IDataSerializer"/> to be used to serialize configuration data.
/// </summary>
void Register(IDataSerializer serializer);
/// <summary>
/// Registers the specified <see cref="IResourceLoader"/> to be used to load configuration resources.
/// </summary>
void Register(IResourceLoader loader);
/// <summary>
/// Registers the specified <see cref="IResourceSaver"/> to be used to save configuration resources.
/// </summary>
void Register(IResourceSaver saver);
/// <summary>
/// Attempts to load settings from the specified resource.
/// </summary>
LoadStatus TryLoadSettings(Uri resource, out AppSettings settings, PasswordParameters password = null);
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts.Integrity
{
/// <summary>
/// Provides functionality related to application integrity.
/// </summary>
public interface IIntegrityModule
{
/// <summary>
/// Caches the specified session for later integrity verification.
/// </summary>
void CacheSession(string configurationKey, string startUrl);
/// <summary>
/// Removes the specified session from the integrity verification cache.
/// </summary>
void ClearSession(string configurationKey, string startUrl);
/// <summary>
/// Attempts to calculate the app signature key.
/// </summary>
bool TryCalculateAppSignatureKey(string connectionToken, string salt, out string appSignatureKey);
/// <summary>
/// Attempts to calculate the browser exam key.
/// </summary>
bool TryCalculateBrowserExamKey(string configurationKey, string salt, out string browserExamKey);
/// <summary>
/// Attempts to verify the code signature.
/// </summary>
bool TryVerifyCodeSignature(out bool isValid);
/// <summary>
/// Attempts to verify the integrity for the specified session.
/// </summary>
bool TryVerifySessionIntegrity(string configurationKey, string startUrl, out bool isValid);
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts
{
/// <summary>
/// Defines all possible results of an attempt to load a configuration resource.
/// </summary>
public enum LoadStatus
{
/// <summary>
/// Indicates that a resource contains invalid data.
/// </summary>
InvalidData,
/// <summary>
/// Indicates that a resource needs to be loaded with the browser.
/// </summary>
LoadWithBrowser,
/// <summary>
/// Indicates that a resource is not supported.
/// </summary>
NotSupported,
/// <summary>
/// Indicates that a password is needed in order to decrypt the configuration.
/// </summary>
PasswordNeeded,
/// <summary>
/// The configuration was loaded successfully.
/// </summary>
Success,
/// <summary>
/// An unexpected error occurred while trying to load the configuration.
/// </summary>
UnexpectedError
}
}

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.Configuration.Contracts")]
[assembly: AssemblyDescription("Safe Exam Browser")]
[assembly: AssemblyCompany("ETH Zürich")]
[assembly: AssemblyProduct("SafeExamBrowser.Configuration.Contracts")]
[assembly: AssemblyCopyright("Copyright © 2024 ETH Zürich, IT Services")]
// 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("7d74555e-63e1-4c46-bd0a-8580552368c8")]
// 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,91 @@
<?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>{7D74555E-63E1-4C46-BD0A-8580552368C8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SafeExamBrowser.Configuration.Contracts</RootNamespace>
<AssemblyName>SafeExamBrowser.Configuration.Contracts</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppConfig.cs" />
<Compile Include="ClientConfiguration.cs" />
<Compile Include="Cryptography\EncryptionParameters.cs" />
<Compile Include="Cryptography\ICertificateStore.cs" />
<Compile Include="Cryptography\IHashAlgorithm.cs" />
<Compile Include="Integrity\IIntegrityModule.cs" />
<Compile Include="Cryptography\IKeyGenerator.cs" />
<Compile Include="Cryptography\IPasswordEncryption.cs" />
<Compile Include="Cryptography\IPublicKeyEncryption.cs" />
<Compile Include="Cryptography\PasswordParameters.cs" />
<Compile Include="Cryptography\PublicKeyParameters.cs" />
<Compile Include="DataCompression\IDataCompressor.cs" />
<Compile Include="DataFormats\FormatType.cs" />
<Compile Include="DataFormats\IDataParser.cs" />
<Compile Include="DataFormats\IDataSerializer.cs" />
<Compile Include="DataFormats\ParseResult.cs" />
<Compile Include="DataFormats\SerializeResult.cs" />
<Compile Include="DataResources\IResourceLoader.cs" />
<Compile Include="DataResources\IResourceSaver.cs" />
<Compile Include="IConfigurationRepository.cs" />
<Compile Include="LoadStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SaveStatus.cs" />
<Compile Include="ServiceConfiguration.cs" />
<Compile Include="SessionConfiguration.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.Settings\SafeExamBrowser.Settings.csproj">
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
<Name>SafeExamBrowser.Settings</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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.Configuration.Contracts
{
/// <summary>
/// Defines all possible results of an attempt to save a configuration resource.
/// </summary>
public enum SaveStatus
{
/// <summary>
/// The configuration data is invalid or contains invalid elements.
/// </summary>
InvalidData,
/// <summary>
/// The configuration format or resource type is not supported.
/// </summary>
NotSupported,
/// <summary>
/// The configuration was saved successfully.
/// </summary>
Success,
/// <summary>
/// An unexpected error occurred while trying to save the configuration.
/// </summary>
UnexpectedError
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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 SafeExamBrowser.Settings;
namespace SafeExamBrowser.Configuration.Contracts
{
/// <summary>
/// The configuration for a session of the service application component.
/// </summary>
[Serializable]
public class ServiceConfiguration
{
/// <summary>
/// The global application configuration.
/// </summary>
public AppConfig AppConfig { get; set; }
/// <summary>
/// The unique identifier for the current session.
/// </summary>
public Guid SessionId { get; set; }
/// <summary>
/// The application settings to be used by the service.
/// </summary>
public AppSettings 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

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* 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 SafeExamBrowser.Settings;
namespace SafeExamBrowser.Configuration.Contracts
{
/// <summary>
/// Container holding all session-related configuration data.
/// </summary>
public class SessionConfiguration
{
/// <summary>
/// The application configuration for this session.
/// </summary>
public AppConfig AppConfig { get; set; }
/// <summary>
/// The token used for initial communication authentication with the client.
/// </summary>
public Guid ClientAuthenticationToken { get; set; }
/// <summary>
/// Indicates whether a configuration resource needs to be loaded in the browser because it requires authentication or is a webpage.
/// </summary>
public bool IsBrowserResource { get; set; }
/// <summary>
/// The unique session identifier.
/// </summary>
public Guid SessionId { get; set; }
/// <summary>
/// The settings used for this session.
/// </summary>
public AppSettings Settings { get; set; }
}
}