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,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/.
*/
namespace SafeExamBrowser.Server.Contracts.Data
{
/// <summary>
/// Contains all information required to establish a connection with a server.
/// </summary>
public class ConnectionInfo
{
/// <summary>
/// The API of the server as JSON string.
/// </summary>
public string Api { get; set; }
/// <summary>
/// The connection token for authentication with the server.
/// </summary>
public string ConnectionToken { get; set; }
/// <summary>
/// The OAuth2 token for authentication with the server.
/// </summary>
public string Oauth2Token { get; set; }
}
}

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.Server.Contracts.Data
{
/// <summary>
/// Defines a server exam.
/// </summary>
public class Exam
{
/// <summary>
/// The identifier of the exam.
/// </summary>
public string Id { get; set; }
/// <summary>
/// The name of the learning management system (LMS) on which the exam is running.
/// </summary>
public string LmsName { get; set; }
/// <summary>
/// The name of the exam.
/// </summary>
public string Name { get; set; }
/// <summary>
/// The URL of the exam.
/// </summary>
public string Url { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.Server.Contracts.Data
{
/// <summary>
/// Defines the result of a communication with a SEB server.
/// </summary>
public class ServerResponse
{
/// <summary>
/// The message retrieved by the server in case the communication failed.
/// </summary>
public string Message { get; }
/// <summary>
/// Defines whether the communication was successful or not.
/// </summary>
public bool Success { get; }
public ServerResponse(bool success, string message = default)
{
Message = message;
Success = success;
}
}
/// <summary>
/// Defines the result of a communication with a SEB server.
/// </summary>
/// <typeparam name="T">The type of the expected response value.</typeparam>
public class ServerResponse<T> : ServerResponse
{
/// <summary>
/// The response value. Can be <c>null</c> or <c>default(T)</c> in case the communication failed!
/// </summary>
public T Value { get; }
public ServerResponse(bool success, T value, string message = default) : base(success, message)
{
Value = value;
}
}
}

View File

@@ -0,0 +1,16 @@
/*
* 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.Server.Contracts.Events
{
/// <summary>
/// Event handler used to indicate that a lock screen instruction has been received.
/// </summary>
public delegate void LockScreenRequestedEventHandler(string message);
}

View File

@@ -0,0 +1,18 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Defines all parameters for a proctoring instruction received by the <see cref="IServerProxy"/>.
/// </summary>
public abstract class InstructionEventArgs
{
public InstructionMethod Method { get; set; }
}
}

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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Defines all possible methods for a proctoring instruction.
/// </summary>
public enum InstructionMethod
{
/// <summary>
/// Instructs to start proctoring resp. join a proctoring event or session.
/// </summary>
Join,
/// <summary>
/// Instructs to stop proctoring resp. leave a proctoring event or session.
/// </summary>
Leave
}
}

View File

@@ -0,0 +1,20 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Defines the parameters of a proctoring instruction for provider Jitsi Meet.
/// </summary>
public class JitsiMeetInstruction : InstructionEventArgs
{
public string RoomName { get; set; }
public string ServerUrl { get; set; }
public string Token { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Event handler used to indicate that proctoring configuration data has been received.
/// </summary>
public delegate void ProctoringConfigurationReceivedEventHandler(bool allowChat, bool receiveAudio, bool receiveVideo);
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Event handler used to indicate that a proctoring instruction has been received.
/// </summary>
public delegate void ProctoringInstructionReceivedEventHandler(InstructionEventArgs args);
}

View File

@@ -0,0 +1,22 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Defines the parameters of a proctoring instruction for the screen proctoring implementation.
/// </summary>
public class ScreenProctoringInstruction : InstructionEventArgs
{
public string ClientId { get; set; }
public string ClientSecret { get; set; }
public string GroupId { get; set; }
public string ServiceUrl { get; set; }
public string SessionId { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
/*
* 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.Server.Contracts.Events.Proctoring
{
/// <summary>
/// Defines the parameters of a proctoring instruction for provider Zoom.
/// </summary>
public class ZoomInstruction : InstructionEventArgs
{
public string MeetingNumber { get; set; }
public string Password { get; set; }
public string SdkKey { get; set; }
public string Signature { get; set; }
public string Subject { get; set; }
public string UserName { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Server.Contracts.Events
{
/// <summary>
/// The default event handler for server events.
/// </summary>
public delegate void ServerEventHandler();
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Server.Contracts.Events
{
/// <summary>
/// Event handler used to indicate that a termination instruction has been detected.
/// </summary>
public delegate void TerminationRequestedEventHandler();
}

View File

@@ -0,0 +1,128 @@
/*
* 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.Collections.Generic;
using SafeExamBrowser.Server.Contracts.Data;
using SafeExamBrowser.Server.Contracts.Events;
using SafeExamBrowser.Server.Contracts.Events.Proctoring;
using SafeExamBrowser.Settings.Server;
namespace SafeExamBrowser.Server.Contracts
{
/// <summary>
/// Defines the communication options with a server.
/// </summary>
public interface IServerProxy
{
/// <summary>
/// Event fired when the proxy receives a confirmation for a raise hand notification.
/// </summary>
event ServerEventHandler HandConfirmed;
/// <summary>
/// Event fired when the proxy receives a confirmation for a lock screen notification.
/// </summary>
event ServerEventHandler LockScreenConfirmed;
/// <summary>
/// Event fired when the proxy receives a lock screen instruction.
/// </summary>
event LockScreenRequestedEventHandler LockScreenRequested;
/// <summary>
/// Event fired when the proxy receives new proctoring configuration values.
/// </summary>
event ProctoringConfigurationReceivedEventHandler ProctoringConfigurationReceived;
/// <summary>
/// Event fired when the proxy receives a proctoring instruction.
/// </summary>
event ProctoringInstructionReceivedEventHandler ProctoringInstructionReceived;
/// <summary>
/// Event fired when the proxy detects an instruction to terminate SEB.
/// </summary>
event TerminationRequestedEventHandler TerminationRequested;
/// <summary>
/// Sends a lock screen confirm notification to the server.
/// </summary>
ServerResponse ConfirmLockScreen();
/// <summary>
/// Attempts to initialize a connection with the server.
/// </summary>
ServerResponse Connect();
/// <summary>
/// Terminates a connection with the server.
/// </summary>
ServerResponse Disconnect();
/// <summary>
/// Retrieves a list of all currently available exams, or a list containing the specified exam.
/// </summary>
ServerResponse<IEnumerable<Exam>> GetAvailableExams(string examId = default);
/// <summary>
/// Retrieves the URI of the configuration file for the given exam.
/// </summary>
ServerResponse<Uri> GetConfigurationFor(Exam exam);
/// <summary>
/// Retrieves the information required to establish a connection with the server.
/// </summary>
ConnectionInfo GetConnectionInfo();
/// <summary>
/// Initializes the server settings to be used for communication.
/// </summary>
void Initialize(ServerSettings settings);
/// <summary>
/// Initializes the configuration and server settings to be used for communication.
/// </summary>
void Initialize(string api, string connectionToken, string examId, string oauth2Token, ServerSettings settings);
/// <summary>
/// Sends a lock screen notification to the server.
/// </summary>
ServerResponse LockScreen(string message = default);
/// <summary>
/// Sends a lower hand notification to the server.
/// </summary>
ServerResponse LowerHand();
/// <summary>
/// Sends a raise hand notification to the server.
/// </summary>
ServerResponse RaiseHand(string message = default);
/// <summary>
/// Sends the selected exam to the server. Optionally returns a custom browser exam key to be used for the active session.
/// </summary>
ServerResponse<string> SendSelectedExam(Exam exam);
/// <summary>
/// Sends the given user identifier of an LMS and thus establishes a connection with the server.
/// </summary>
ServerResponse SendUserIdentifier(string identifier);
/// <summary>
/// Starts sending ping and log data to the server.
/// </summary>
void StartConnectivity();
/// <summary>
/// Stops sending ping and log data to the server.
/// </summary>
void StopConnectivity();
}
}

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.Server.Contracts")]
[assembly: AssemblyDescription("Safe Exam Browser")]
[assembly: AssemblyCompany("ETH Zürich")]
[assembly: AssemblyProduct("SafeExamBrowser.Server.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("db701e6f-bddc-4cec-b662-335a9dc11809")]
// 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,82 @@
<?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>{DB701E6F-BDDC-4CEC-B662-335A9DC11809}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SafeExamBrowser.Server.Contracts</RootNamespace>
<AssemblyName>SafeExamBrowser.Server.Contracts</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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>
<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="Data\ConnectionInfo.cs" />
<Compile Include="Data\Exam.cs" />
<Compile Include="Events\LockScreenRequestedEventHandler.cs" />
<Compile Include="Events\Proctoring\InstructionMethod.cs" />
<Compile Include="Events\Proctoring\JitsiMeetInstruction.cs" />
<Compile Include="Events\Proctoring\ProctoringConfigurationReceivedEventHandler.cs" />
<Compile Include="Events\Proctoring\InstructionEventArgs.cs" />
<Compile Include="Events\Proctoring\ProctoringInstructionReceivedEventHandler.cs" />
<Compile Include="Events\Proctoring\ScreenProctoringInstruction.cs" />
<Compile Include="Events\Proctoring\ZoomInstruction.cs" />
<Compile Include="Events\ServerEventHandler.cs" />
<Compile Include="Events\TerminationRequestedEventHandler.cs" />
<Compile Include="IServerProxy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Data\ServerResponse.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.Settings\SafeExamBrowser.Settings.csproj">
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
<Name>SafeExamBrowser.Settings</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>