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

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/.
*/
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the client configuration event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ClientConfigurationEventArgs : CommunicationEventArgs
{
/// <summary>
/// The configuration to be sent to the client.
/// </summary>
public ClientConfiguration ClientConfiguration { 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.Communication.Contracts.Events
{
/// <summary>
/// Base class which must be used for all event parameters <c>T</c> of <see cref="CommunicationEventHandler{T}"/>.
/// </summary>
public abstract class CommunicationEventArgs
{
}
}

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.Threading.Tasks;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The default handler for communication events of an interlocutor.
/// </summary>
public delegate void CommunicationEventHandler();
/// <summary>
/// The handler with parameter for communication events of an interlocutor.
/// </summary>
public delegate void CommunicationEventHandler<T>(T args) where T : CommunicationEventArgs;
public static class CommunicationEventHandlerExtensions
{
/// <summary>
/// Executes the event handler asynchronously, i.e. on a separate thread.
/// </summary>
public static async Task InvokeAsync(this CommunicationEventHandler handler)
{
await Task.Run(() => handler?.Invoke());
}
/// <summary>
/// Executes the event handler asynchronously, i.e. on a separate thread.
/// </summary>
public static async Task InvokeAsync<T>(this CommunicationEventHandler<T> handler, T args) where T : CommunicationEventArgs
{
await Task.Run(() => handler?.Invoke(args));
}
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the exam selection event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ExamSelectionReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// Identifies the exam selection request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The identifier of the exam selected by the user.
/// </summary>
public string SelectedExamId { get; set; }
/// <summary>
/// Indicates whether an exam has been successfully selected by the user.
/// </summary>
public bool Success { 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.Collections.Generic;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server exam selection request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class ExamSelectionRequestEventArgs : CommunicationEventArgs
{
/// <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; set; }
/// <summary>
/// Identifies the server exam selection request.
/// </summary>
public Guid RequestId { 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;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the message box reply event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class MessageBoxReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The result of the interaction.
/// </summary>
public int Result { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.Events
{
/// <summary>
/// The event arguments used for the message box request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class MessageBoxRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The action to be displayed.
/// </summary>
public int Action { get; set; }
/// <summary>
/// The icon to be displayed.
/// </summary>
public int Icon { get; set; }
/// <summary>
/// The message to be displayed.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The title to be displayed.
/// </summary>
public string Title { 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;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the password input event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class PasswordReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// The password entered by the user, or <c>null</c> if not available.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Identifies the password request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// Indicates whether the password has been successfully entered by the user.
/// </summary>
public bool Success { 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 SafeExamBrowser.Communication.Contracts.Data;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the password request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class PasswordRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The purpose for which a password is requested.
/// </summary>
public PasswordRequestPurpose Purpose { get; set; }
/// <summary>
/// Identifies the password request.
/// </summary>
public Guid RequestId { 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.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the reconfiguration event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ReconfigurationEventArgs : CommunicationEventArgs
{
/// <summary>
/// The full path to the configuration file to be used for reconfiguration.
/// </summary>
public string ConfigurationPath { get; set; }
/// <summary>
/// The original URL from where the configuration file was downloaded.
/// </summary>
public string ResourceUrl { 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;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server failure action event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ServerFailureActionReplyEventArgs : CommunicationEventArgs
{
/// <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; }
}
}

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;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server failure action request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class ServerFailureActionRequestEventArgs : CommunicationEventArgs
{
/// <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>
/// Identifies the server failure action selection request.
/// </summary>
public Guid RequestId { 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/.
*/
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the session start event fired by the <see cref="Hosts.IServiceHost"/>.
/// </summary>
public class SessionStartEventArgs : CommunicationEventArgs
{
/// <summary>
/// The configuration to be used for the new session.
/// </summary>
public ServiceConfiguration Configuration { 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/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the session stop event fired by the <see cref="Hosts.IServiceHost"/>.
/// </summary>
public class SessionStopEventArgs : CommunicationEventArgs
{
/// <summary>
/// The identifier of the session to be stopped.
/// </summary>
public Guid SessionId { get; set; }
}
}

View File

@@ -0,0 +1,69 @@
/*
* 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.Communication.Contracts.Events;
namespace SafeExamBrowser.Communication.Contracts.Hosts
{
/// <summary>
/// Defines the functionality of the communication host for the client application component.
/// </summary>
public interface IClientHost : ICommunicationHost
{
/// <summary>
/// The token used for initial authentication with the runtime.
/// </summary>
Guid AuthenticationToken { set; }
/// <summary>
/// Indicates whether the runtime has established a connection to this host.
/// </summary>
bool IsConnected { get; }
/// <summary>
/// Event fired when the runtime requests a server exam selection from the user.
/// </summary>
event CommunicationEventHandler<ExamSelectionRequestEventArgs> ExamSelectionRequested;
/// <summary>
/// Event fired when the runtime requests a message box input from the user.
/// </summary>
event CommunicationEventHandler<MessageBoxRequestEventArgs> MessageBoxRequested;
/// <summary>
/// Event fired when the runtime requests a password input from the user.
/// </summary>
event CommunicationEventHandler<PasswordRequestEventArgs> PasswordRequested;
/// <summary>
/// Event fired when the runtime aborted a reconfiguration.
/// </summary>
event CommunicationEventHandler ReconfigurationAborted;
/// <summary>
/// Event fired when the runtime denied a reconfiguration request.
/// </summary>
event CommunicationEventHandler<ReconfigurationEventArgs> ReconfigurationDenied;
/// <summary>
/// Event fired when the runtime disconnected from the client.
/// </summary>
event CommunicationEventHandler RuntimeDisconnected;
/// <summary>
/// Event fired when the runtime requests a server failure action selection from the user.
/// </summary>
event CommunicationEventHandler<ServerFailureActionRequestEventArgs> ServerFailureActionRequested;
/// <summary>
/// Event fired when the runtime commands the client to shutdown.
/// </summary>
event CommunicationEventHandler Shutdown;
}
}

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/.
*/
using System.ServiceModel;
namespace SafeExamBrowser.Communication.Contracts.Hosts
{
/// <summary>
/// The host object to be used in communication hosts.
/// </summary>
public interface IHostObject : ICommunicationObject
{
}
}

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.Communication.Contracts.Hosts
{
/// <summary>
/// A factory to create host objects for communication hosts.
/// </summary>
public interface IHostObjectFactory
{
/// <summary>
/// Utilizes the given communication object to create a host object (see <see cref="IHostObject"/>) for the specified endpoint address.
/// </summary>
IHostObject CreateObject(string address, ICommunication communicationObject);
}
}

View File

@@ -0,0 +1,74 @@
/*
* 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.Communication.Contracts.Events;
namespace SafeExamBrowser.Communication.Contracts.Hosts
{
/// <summary>
/// Defines the functionality of the communication host for the runtime application component.
/// </summary>
public interface IRuntimeHost : ICommunicationHost
{
/// <summary>
/// Determines whether another application component may establish a connection with the host.
/// </summary>
bool AllowConnection { get; set; }
/// <summary>
/// The token used for initial authentication.
/// </summary>
Guid? AuthenticationToken { set; }
/// <summary>
/// Event fired when the client disconnected from the runtime.
/// </summary>
event CommunicationEventHandler ClientDisconnected;
/// <summary>
/// Event fired when the client has signaled that it is ready to operate.
/// </summary>
event CommunicationEventHandler ClientReady;
/// <summary>
/// Event fired when the client requested its configuration data.
/// </summary>
event CommunicationEventHandler<ClientConfigurationEventArgs> ClientConfigurationNeeded;
/// <summary>
/// Event fired when the client submitted a server exam selection made by the user.
/// </summary>
event CommunicationEventHandler<ExamSelectionReplyEventArgs> ExamSelectionReceived;
/// <summary>
/// Event fired when the client submitted a message box result chosen by the user.
/// </summary>
event CommunicationEventHandler<MessageBoxReplyEventArgs> MessageBoxReplyReceived;
/// <summary>
/// Event fired when the client submitted a password entered by the user.
/// </summary>
event CommunicationEventHandler<PasswordReplyEventArgs> PasswordReceived;
/// <summary>
/// Event fired when the client requested a reconfiguration of the application.
/// </summary>
event CommunicationEventHandler<ReconfigurationEventArgs> ReconfigurationRequested;
/// <summary>
/// Event fired when the client submitted a server failure action chosen by the user.
/// </summary>
event CommunicationEventHandler<ServerFailureActionReplyEventArgs> ServerFailureActionReceived;
/// <summary>
/// Event fired when the client requests to shut down the application.
/// </summary>
event CommunicationEventHandler ShutdownRequested;
}
}

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 SafeExamBrowser.Communication.Contracts.Events;
namespace SafeExamBrowser.Communication.Contracts.Hosts
{
/// <summary>
/// Defines the functionality of the communication host for the service application component.
/// </summary>
public interface IServiceHost : ICommunicationHost
{
/// <summary>
/// Event fired when the runtime requested to start a new session.
/// </summary>
event CommunicationEventHandler<SessionStartEventArgs> SessionStartRequested;
/// <summary>
/// Event fired when the runtime requested to stop a running session.
/// </summary>
event CommunicationEventHandler<SessionStopEventArgs> SessionStopRequested;
/// <summary>
/// Event fired when the runtime requested to update the system configuration.
/// </summary>
event CommunicationEventHandler SystemConfigurationUpdateRequested;
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.ServiceModel;
using SafeExamBrowser.Communication.Contracts.Data;
using SafeExamBrowser.Configuration.Contracts;
using ServiceConfiguration = SafeExamBrowser.Configuration.Contracts.ServiceConfiguration;
namespace SafeExamBrowser.Communication.Contracts
{
/// <summary>
/// Defines the API for all communication between the three application components (runtime, service and client).
/// </summary>
[ServiceContract(SessionMode = SessionMode.Required)]
[ServiceKnownType(typeof(AuthenticationResponse))]
[ServiceKnownType(typeof(ClientConfiguration))]
[ServiceKnownType(typeof(ConfigurationResponse))]
[ServiceKnownType(typeof(ExamSelectionReplyMessage))]
[ServiceKnownType(typeof(ExamSelectionRequestMessage))]
[ServiceKnownType(typeof(MessageBoxReplyMessage))]
[ServiceKnownType(typeof(MessageBoxRequestMessage))]
[ServiceKnownType(typeof(PasswordReplyMessage))]
[ServiceKnownType(typeof(PasswordRequestMessage))]
[ServiceKnownType(typeof(ReconfigurationMessage))]
[ServiceKnownType(typeof(ReconfigurationDeniedMessage))]
[ServiceKnownType(typeof(ServerFailureActionReplyMessage))]
[ServiceKnownType(typeof(ServerFailureActionRequestMessage))]
[ServiceKnownType(typeof(ServiceConfiguration))]
[ServiceKnownType(typeof(SessionStartMessage))]
[ServiceKnownType(typeof(SessionStopMessage))]
[ServiceKnownType(typeof(SimpleMessage))]
[ServiceKnownType(typeof(SimpleResponse))]
public interface ICommunication
{
/// <summary>
/// Initiates a connection and must thus be called before any other opertion. Where applicable, an authentication token should be
/// specified. Returns a response indicating whether the connection request was successful or not.
/// </summary>
[OperationContract(IsInitiating = true)]
ConnectionResponse Connect(Guid? token = null);
/// <summary>
/// Closes a connection. Returns a response indicating whether the disconnection request was successful or not.
/// </summary>
[OperationContract(IsInitiating = false, IsTerminating = true)]
DisconnectionResponse Disconnect(DisconnectionMessage message);
/// <summary>
/// Sends a message, optionally returning a response. If no response is expected, <c>null</c> will be returned.
/// </summary>
[OperationContract(IsInitiating = false)]
Response Send(Message message);
}
}

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/.
*/
namespace SafeExamBrowser.Communication.Contracts
{
/// <summary>
/// Defines the common functionality for all communication hosts. A communication host can be hosted by an application component to
/// allow for inter-process communication with other components (e.g. runtime -> client communication).
/// </summary>
public interface ICommunicationHost
{
/// <summary>
/// Indicates whether the host is running and ready for communication.
/// </summary>
bool IsRunning { get; }
/// <summary>
/// Starts the host and opens it for communication.
/// </summary>
/// <exception cref="System.ServiceModel.CommunicationException">If the host fails to start.</exception>
void Start();
/// <summary>
/// Closes and terminates the host.
/// </summary>
/// <exception cref="System.ServiceModel.CommunicationException">If the host fails to terminate.</exception>
void Stop();
}
}

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;
using SafeExamBrowser.Communication.Contracts.Events;
namespace SafeExamBrowser.Communication.Contracts
{
/// <summary>
/// Defines the common functionality for all communication proxies. A proxy is needed to be able to perform inter-process communication
/// with the <see cref="ICommunicationHost"/> of another application component.
/// </summary>
public interface ICommunicationProxy
{
/// <summary>
/// Indicates whether a connection to the host has been established.
/// </summary>
bool IsConnected { get; }
/// <summary>
/// Fired when the connection to the host was lost, e.g. if a ping request failed or a communication fault occurred.
/// </summary>
event CommunicationEventHandler ConnectionLost;
/// <summary>
/// Tries to establish a connection. Returns <c>true</c> if the connection has been successful, otherwise <c>false</c>. If a
/// connection was successfully established and the auto-ping flag is set, the connection status will be periodically checked.
/// </summary>
bool Connect(Guid? token = null, bool autoPing = true);
/// <summary>
/// Terminates an open connection. Returns <c>true</c> if the disconnection has been successful, otherwise <c>false</c>.
/// </summary>
bool Disconnect();
}
}

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;
namespace SafeExamBrowser.Communication.Contracts
{
/// <summary>
/// Defines all possible interlocutors for inter-process communication within the application.
/// </summary>
[Serializable]
public enum Interlocutor
{
/// <summary>
/// The interlocutor is not an application component.
/// </summary>
Unknown = 0,
/// <summary>
/// The client application component.
/// </summary>
Client,
/// <summary>
/// The runtime application component.
/// </summary>
Runtime,
/// <summary>
/// The service application component.
/// </summary>
Service
}
}

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.Communication.Contracts")]
[assembly: AssemblyDescription("Safe Exam Browser")]
[assembly: AssemblyCompany("ETH Zürich")]
[assembly: AssemblyProduct("SafeExamBrowser.Communication.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("0cd2c5fe-711a-4c32-afe0-bb804fe8b220")]
// 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,43 @@
/*
* 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.Proxies
{
/// <summary>
/// Defines the result of a communication between an <see cref="ICommunicationProxy"/> and its <see cref="ICommunicationHost"/>.
/// </summary>
public class CommunicationResult
{
/// <summary>
/// Defines whether the communication was successful or not.
/// </summary>
public bool Success { get; protected set; }
public CommunicationResult(bool success)
{
Success = success;
}
}
/// <summary>
/// Defines the result of a communication between an <see cref="ICommunicationProxy"/> and its <see cref="ICommunicationHost"/>.
/// </summary>
/// <typeparam name="T">The type of the expected response value.</typeparam>
public class CommunicationResult<T> : CommunicationResult
{
/// <summary>
/// The response value. Can be <c>null</c> or <c>default(T)</c> in case the communication has failed!
/// </summary>
public T Value { get; protected set; }
public CommunicationResult(bool success, T value) : base(success)
{
Value = value;
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.Communication.Contracts.Data;
namespace SafeExamBrowser.Communication.Contracts.Proxies
{
/// <summary>
/// Defines the functionality for a proxy to the communication host of the client application component.
/// </summary>
public interface IClientProxy : ICommunicationProxy
{
/// <summary>
/// Informs the client that a reconfiguration was aborted.
/// </summary>
CommunicationResult InformReconfigurationAborted();
/// <summary>
/// Informs the client that the reconfiguration request for the specified file was denied.
/// </summary>
CommunicationResult InformReconfigurationDenied(string filePath);
/// <summary>
/// Instructs the client to initiate its shutdown procedure.
/// </summary>
CommunicationResult InitiateShutdown();
/// <summary>
/// Instructs the client to submit its authentication data.
/// </summary>
CommunicationResult<AuthenticationResponse> RequestAuthentication();
/// <summary>
/// Requests the client to render a server exam selection dialog and subsequently return the interaction result as separate message.
/// </summary>
CommunicationResult RequestExamSelection(IEnumerable<(string id, string lms, string name, string url)> exams, Guid requestId);
/// <summary>
/// Requests the client to render a password dialog and subsequently return the interaction result as separate message.
/// </summary>
CommunicationResult RequestPassword(PasswordRequestPurpose purpose, Guid requestId);
/// <summary>
/// Requests the client to render a server failure action dialog and subsequently return the interaction result as separate message.
/// </summary>
CommunicationResult RequestServerFailureAction(string message, bool showFallback, Guid requestId);
/// <summary>
/// Requests the client to render a message box and subsequently return the interaction result as separate message.
/// </summary>
CommunicationResult ShowMessage(string message, string title, int action, int icon, Guid requestId);
}
}

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.Communication.Contracts.Proxies
{
/// <summary>
/// A factory to create communication proxies during application runtime.
/// </summary>
public interface IProxyFactory
{
/// <summary>
/// Creates a new <see cref="IClientProxy"/> for the given endpoint address and owner.
/// </summary>
IClientProxy CreateClientProxy(string address, Interlocutor owner);
}
}

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/.
*/
using System.ServiceModel;
namespace SafeExamBrowser.Communication.Contracts.Proxies
{
/// <summary>
/// The communication object to be used in an <see cref="ICommunicationProxy"/>.
/// </summary>
public interface IProxyObject : ICommunication, ICommunicationObject
{
}
}

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.Communication.Contracts.Proxies
{
/// <summary>
/// A factory to create proxy objects for communication proxies.
/// </summary>
public interface IProxyObjectFactory
{
/// <summary>
/// Creates a proxy object (see <see cref="IProxyObject"/>) for the specified endpoint address.
/// </summary>
IProxyObject CreateObject(string address);
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.Communication.Contracts.Data;
namespace SafeExamBrowser.Communication.Contracts.Proxies
{
/// <summary>
/// Defines the functionality for a proxy to the communication host of the runtime application component.
/// </summary>
public interface IRuntimeProxy : ICommunicationProxy
{
/// <summary>
/// Retrieves the application configuration from the runtime.
/// </summary>
CommunicationResult<ConfigurationResponse> GetConfiguration();
/// <summary>
/// Informs the runtime that the client is ready.
/// </summary>
CommunicationResult InformClientReady();
/// <summary>
/// Requests the runtime to shut down the application.
/// </summary>
CommunicationResult RequestShutdown();
/// <summary>
/// Requests the runtime to reconfigure the application with the specified configuration.
/// </summary>
CommunicationResult RequestReconfiguration(string filePath, string url);
/// <summary>
/// Submits the result of a server exam selection previously requested by the runtime. If the procedure was aborted by the user,
/// the selected exam identifier will be <see cref="default(string)"/>!
/// </summary>
CommunicationResult SubmitExamSelectionResult(Guid requestId, bool success, string selectedExamId = default(string));
/// <summary>
/// Submits the result of a message box input previously requested by the runtime.
/// </summary>
CommunicationResult SubmitMessageBoxResult(Guid requestId, int result);
/// <summary>
/// Submits the result of a password input previously requested by the runtime. If the procedure was aborted by the user,
/// the password parameter will be <see cref="default(string)"/>!
/// </summary>
CommunicationResult SubmitPassword(Guid requestId, bool success, string password = default(string));
/// <summary>
/// Submits the result of a server failure action selection previously requested by the runtime.
/// </summary>
CommunicationResult SubmitServerFailureActionResult(Guid requestId, bool abort, bool fallback, bool retry);
}
}

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;
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Proxies
{
/// <summary>
/// Defines the functionality for a proxy to the communication host of the service application component.
/// </summary>
public interface IServiceProxy : ICommunicationProxy
{
/// <summary>
/// Instructs the service to start a system configuration update.
/// </summary>
CommunicationResult RunSystemConfigurationUpdate();
/// <summary>
/// Instructs the service to start a new session according to the given configuration.
/// </summary>
CommunicationResult StartSession(ServiceConfiguration configuration);
/// <summary>
/// Instructs the service to stop the specified session.
/// </summary>
CommunicationResult StopSession(Guid sessionId);
}
}

View File

@@ -0,0 +1,122 @@
<?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>{0CD2C5FE-711A-4C32-AFE0-BB804FE8B220}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SafeExamBrowser.Communication.Contracts</RootNamespace>
<AssemblyName>SafeExamBrowser.Communication.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="System.ServiceModel" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Data\AuthenticationResponse.cs" />
<Compile Include="Data\ConfigurationResponse.cs" />
<Compile Include="Data\ConnectionResponse.cs" />
<Compile Include="Data\DisconnectionMessage.cs" />
<Compile Include="Data\DisconnectionResponse.cs" />
<Compile Include="Data\ExamSelectionReplyMessage.cs" />
<Compile Include="Data\ExamSelectionRequestMessage.cs" />
<Compile Include="Data\Message.cs" />
<Compile Include="Data\MessageBoxReplyMessage.cs" />
<Compile Include="Data\MessageBoxRequestMessage.cs" />
<Compile Include="Data\PasswordReplyMessage.cs" />
<Compile Include="Data\PasswordRequestMessage.cs" />
<Compile Include="Data\PasswordRequestPurpose.cs" />
<Compile Include="Data\ReconfigurationDeniedMessage.cs" />
<Compile Include="Data\ReconfigurationMessage.cs" />
<Compile Include="Data\Response.cs" />
<Compile Include="Data\ServerFailureActionReplyMessage.cs" />
<Compile Include="Data\ServerFailureActionRequestMessage.cs" />
<Compile Include="Data\SessionStartMessage.cs" />
<Compile Include="Data\SessionStopMessage.cs" />
<Compile Include="Data\SimpleMessage.cs" />
<Compile Include="Data\SimpleMessagePurport.cs" />
<Compile Include="Data\SimpleResponse.cs" />
<Compile Include="Data\SimpleResponsePurport.cs" />
<Compile Include="Events\ClientConfigurationEventArgs.cs" />
<Compile Include="Events\CommunicationEventArgs.cs" />
<Compile Include="Events\CommunicationEventHandler.cs" />
<Compile Include="Events\ExamSelectionReplyEventArgs.cs" />
<Compile Include="Events\ExamSelectionRequestEventArgs.cs" />
<Compile Include="Events\MessageBoxReplyEventArgs.cs" />
<Compile Include="Events\MessageBoxRequestEventArgs.cs" />
<Compile Include="Events\PasswordReplyEventArgs.cs" />
<Compile Include="Events\PasswordRequestEventArgs.cs" />
<Compile Include="Events\ReconfigurationEventArgs.cs" />
<Compile Include="Events\ServerFailureActionReplyEventArgs.cs" />
<Compile Include="Events\ServerFailureActionRequestEventArgs.cs" />
<Compile Include="Events\SessionStartEventArgs.cs" />
<Compile Include="Events\SessionStopEventArgs.cs" />
<Compile Include="Hosts\IClientHost.cs" />
<Compile Include="Hosts\IHostObject.cs" />
<Compile Include="Hosts\IHostObjectFactory.cs" />
<Compile Include="Hosts\IRuntimeHost.cs" />
<Compile Include="Hosts\IServiceHost.cs" />
<Compile Include="ICommunication.cs" />
<Compile Include="ICommunicationHost.cs" />
<Compile Include="ICommunicationProxy.cs" />
<Compile Include="Interlocutor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Proxies\CommunicationResult.cs" />
<Compile Include="Proxies\IClientProxy.cs" />
<Compile Include="Proxies\IProxyFactory.cs" />
<Compile Include="Proxies\IProxyObject.cs" />
<Compile Include="Proxies\IProxyObjectFactory.cs" />
<Compile Include="Proxies\IRuntimeProxy.cs" />
<Compile Include="Proxies\IServiceProxy.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.Configuration.Contracts\SafeExamBrowser.Configuration.Contracts.csproj">
<Project>{7d74555e-63e1-4c46-bd0a-8580552368c8}</Project>
<Name>SafeExamBrowser.Configuration.Contracts</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>