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,24 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The response to be used to reply to an authentication request (see <see cref="SimpleMessagePurport.Authenticate"/>).
/// </summary>
[Serializable]
public class AuthenticationResponse : Response
{
/// <summary>
/// The process identifier used for authentication.
/// </summary>
public int ProcessId { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
/*
* 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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// The response to be used to reply to a configuration request (see <see cref="SimpleMessagePurport.ConfigurationNeeded"/>).
/// </summary>
[Serializable]
public class ConfigurationResponse : Response
{
/// <summary>
/// The configuration to be used by the client.
/// </summary>
public ClientConfiguration Configuration { 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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// The response to a connection request (see <see cref="ICommunication.Connect(Guid?)"/>).
/// </summary>
[Serializable]
public class ConnectionResponse : Response
{
/// <summary>
/// The communication token needed for authentication. Is <c>null</c> if a connection was refused.
/// </summary>
public Guid? CommunicationToken { get; set; }
/// <summary>
/// Indicates whether the connection request has been accepted.
/// </summary>
public bool ConnectionEstablished { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// This is the last message transmitted from a component to its interlocutor in order to terminate a communication session.
/// </summary>
[Serializable]
public class DisconnectionMessage : Message
{
/// <summary>
/// Identifies the component sending the message.
/// </summary>
public Interlocutor Interlocutor { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The response transmitted to a <see cref="DisconnectionMessage"/>
/// </summary>
[Serializable]
public class DisconnectionResponse : Response
{
/// <summary>
/// Indicates whether the connection has been terminated.
/// </summary>
public bool ConnectionTerminated { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The reply to a <see cref="ExamSelectionRequestMessage"/>.
/// </summary>
[Serializable]
public class ExamSelectionReplyMessage : Message
{
/// <summary>
/// The unique identifier for the exam selection request.
/// </summary>
public Guid RequestId { get; }
/// <summary>
/// The identifier of the exam selected by the user.
/// </summary>
public string SelectedExamId { get; }
/// <summary>
/// Determines whether the user interaction was successful or not.
/// </summary>
public bool Success { get; }
public ExamSelectionReplyMessage(Guid requestId, bool success, string selectedExamId)
{
RequestId = requestId;
Success = success;
SelectedExamId = selectedExamId;
}
}
}

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/.
*/
using System;
using System.Collections.Generic;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the client to request a server exam selection by the user.
/// </summary>
[Serializable]
public class ExamSelectionRequestMessage : Message
{
/// <summary>
/// The exams from which the user needs to make a selection.
/// </summary>
public IEnumerable<(string id, string lms, string name, string url)> Exams { get; }
/// <summary>
/// The unique identifier for the server exam selection request.
/// </summary>
public Guid RequestId { get; }
public ExamSelectionRequestMessage(IEnumerable<(string id, string lms, string name, string url)> exams, Guid requestId)
{
Exams = exams;
RequestId = requestId;
}
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// The base class for messages, from which a message must inherit in order to be sent to an interlocutor via <see cref="ICommunication.Send(Message)"/>.
/// </summary>
[Serializable]
public abstract class Message
{
/// <summary>
/// The communication token needed for authentication.
/// </summary>
public Guid CommunicationToken { get; set; }
public override string ToString()
{
return GetType().Name;
}
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// The reply to a <see cref="MessageBoxRequestMessage"/>.
/// </summary>
[Serializable]
public class MessageBoxReplyMessage : Message
{
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; private set; }
/// <summary>
/// The result of the interaction.
/// </summary>
public int Result { get; private set; }
public MessageBoxReplyMessage(Guid requestId, int result)
{
RequestId = requestId;
Result = result;
}
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the client to request a message box input by the user.
/// </summary>
[Serializable]
public class MessageBoxRequestMessage : Message
{
/// <summary>
/// The action to be displayed.
/// </summary>
public int Action { get; private set; }
/// <summary>
/// The icon to be displayed.
/// </summary>
public int Icon { get; private set; }
/// <summary>
/// The message to be displayed.
/// </summary>
public string Message { get; private set; }
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; private set; }
/// <summary>
/// The title to be displayed.
/// </summary>
public string Title { get; private set; }
public MessageBoxRequestMessage(int action, int icon, string message, Guid requestId, string title)
{
Action = action;
Icon = icon;
Message = message;
RequestId = requestId;
Title = title;
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The reply to a <see cref="PasswordRequestMessage"/>.
/// </summary>
[Serializable]
public class PasswordReplyMessage : Message
{
/// <summary>
/// The password entered by the user, or <c>null</c> if the user interaction was unsuccessful.
/// </summary>
public string Password { get; private set; }
/// <summary>
/// The unique identifier for the password request.
/// </summary>
public Guid RequestId { get; private set; }
/// <summary>
/// Determines whether the user interaction was successful or not.
/// </summary>
public bool Success { get; private set; }
public PasswordReplyMessage(Guid requestId, bool success, string password = null)
{
Password = password;
RequestId = requestId;
Success = success;
}
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the client to request a password input by the user.
/// </summary>
[Serializable]
public class PasswordRequestMessage : Message
{
/// <summary>
/// The purpose of the password request.
/// </summary>
public PasswordRequestPurpose Purpose { get; private set; }
/// <summary>
/// The unique identifier for the password request.
/// </summary>
public Guid RequestId { get; private set; }
public PasswordRequestMessage(PasswordRequestPurpose purpose, Guid requestId)
{
Purpose = purpose;
RequestId = requestId;
}
}
}

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.Communication.Contracts.Data
{
/// <summary>
/// Defines all possible reasons for a <see cref="PasswordRequestMessage"/>.
/// </summary>
public enum PasswordRequestPurpose
{
/// <summary>
/// The password is to be used as administrator password for the local client configuration.
/// </summary>
LocalAdministrator,
/// <summary>
/// The password is to be used as settings password for the local client configuration.
/// </summary>
LocalSettings,
/// <summary>
/// The password is to be used as settings password for an application configuration.
/// </summary>
Settings
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted from the runtime to the client in order to inform the latter that a reconfiguration request was denied.
/// </summary>
[Serializable]
public class ReconfigurationDeniedMessage : Message
{
/// <summary>
/// The full path to the configuration file for which a reconfiguration was denied.
/// </summary>
public string FilePath { get; private set; }
public ReconfigurationDeniedMessage(string filePath)
{
FilePath = filePath;
}
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the runtime to request that the application be reconfigured.
/// </summary>
[Serializable]
public class ReconfigurationMessage : Message
{
/// <summary>
/// The full path of the configuration file to be used.
/// </summary>
public string ConfigurationPath { get; private set; }
/// <summary>
/// The original URL from where the configuration file was downloaded.
/// </summary>
public string ResourceUrl { get; set; }
public ReconfigurationMessage(string path, string url)
{
ConfigurationPath = path;
ResourceUrl = url;
}
}
}

View File

@@ -0,0 +1,24 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The base class for respones, from which a response must inherit in order to be sent to an interlocutor as reply to <see cref="ICommunication.Send(Message)"/>.
/// </summary>
[Serializable]
public abstract class Response
{
public override string ToString()
{
return GetType().Name;
}
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The reply to a <see cref="ServerFailureActionRequestMessage"/>.
/// </summary>
[Serializable]
public class ServerFailureActionReplyMessage : Message
{
/// <summary>
/// The user chose to abort the operation.
/// </summary>
public bool Abort { get; set; }
/// <summary>
/// The user chose to perform a fallback.
/// </summary>
public bool Fallback { get; set; }
/// <summary>
/// The user chose to retry the operation.
/// </summary>
public bool Retry { get; set; }
/// <summary>
/// Identifies the server failure action request.
/// </summary>
public Guid RequestId { get; set; }
public ServerFailureActionReplyMessage(bool abort, bool fallback, bool retry, Guid requestId)
{
Abort = abort;
Fallback = fallback;
Retry = retry;
RequestId = requestId;
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the client to request a server failure action selection by the user.
/// </summary>
[Serializable]
public class ServerFailureActionRequestMessage : Message
{
/// <summary>
/// The server failure message, if available.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Indicates whether the fallback option should be shown to the user.
/// </summary>
public bool ShowFallback { get; set; }
/// <summary>
/// The unique identifier for the server failure action selection request.
/// </summary>
public Guid RequestId { get; }
public ServerFailureActionRequestMessage(string message, bool showFallback, Guid requestId)
{
Message = message;
ShowFallback = showFallback;
RequestId = requestId;
}
}
}

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;
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the service to request the initialization of a new session.
/// </summary>
[Serializable]
public class SessionStartMessage : Message
{
/// <summary>
/// The configuration to be used by the service.
/// </summary>
public ServiceConfiguration Configuration { get; }
public SessionStartMessage(ServiceConfiguration configuration)
{
Configuration = configuration;
}
}
}

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/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Data
{
/// <summary>
/// This message is transmitted to the service to request the termination of a currently running session.
/// </summary>
[Serializable]
public class SessionStopMessage : Message
{
public Guid SessionId { get; }
public SessionStopMessage(Guid sessionId)
{
SessionId = sessionId;
}
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// A generic message to send simple purports without data to an interlocutor.
/// </summary>
[Serializable]
public class SimpleMessage : Message
{
/// <summary>
/// The purport of the message.
/// </summary>
public SimpleMessagePurport Purport { get; set; }
public SimpleMessage(SimpleMessagePurport purport)
{
Purport = purport;
}
public override string ToString()
{
return $"{base.ToString()} -> {Purport}";
}
}
}

View File

@@ -0,0 +1,59 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The possible purports of a <see cref="SimpleMessage"/>.
/// </summary>
[Serializable]
public enum SimpleMessagePurport
{
/// <summary>
/// Requests an interlocutor to submit data for authentication.
/// </summary>
Authenticate = 1,
/// <summary>
/// Sent from the client to the runtime to indicate that the client is ready to operate.
/// </summary>
ClientIsReady,
/// <summary>
/// Sent from the client to the runtime to ask for the client configuration.
/// </summary>
ConfigurationNeeded,
/// <summary>
/// Requests an interlocutor to signal that the connection status is okay.
/// </summary>
Ping,
/// <summary>
/// Sent from the runtime to the client to inform the latter that a reconfiguration was aborted.
/// </summary>
ReconfigurationAborted,
/// <summary>
/// Sent from the client to the runtime to request shutting down the application.
/// </summary>
RequestShutdown,
/// <summary>
/// Sent form the runtime to the client to command the latter to shut itself down.
/// </summary>
Shutdown,
/// <summary>
/// Sent from the runtime to the service to command the latter to update the system configuration.
/// </summary>
UpdateSystemConfiguration
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// A generic response to reply simple purports without data to an interlocutor.
/// </summary>
[Serializable]
public class SimpleResponse : Response
{
/// <summary>
/// The purport of the response.
/// </summary>
public SimpleResponsePurport Purport { get; set; }
public SimpleResponse(SimpleResponsePurport purport)
{
Purport = purport;
}
public override string ToString()
{
return $"{base.ToString()} -> {Purport}";
}
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.Communication.Contracts.Data
{
/// <summary>
/// The possible purports of a <see cref="SimpleResponse"/>.
/// </summary>
[Serializable]
public enum SimpleResponsePurport
{
/// <summary>
/// Signals an interlocutor that a message has been understood.
/// </summary>
Acknowledged = 1,
/// <summary>
/// Signals an interlocutor that it is not authorized to communicate.
/// </summary>
Unauthorized,
/// <summary>
/// Signals an interlocutor that a message has not been understood.
/// </summary>
UnknownMessage
}
}