SEBWIN-569: Added message when down- and uploading is not allowed.

This commit is contained in:
Damian Büchel 2022-05-13 12:03:06 +02:00
parent ee852057ce
commit bc1583c070
11 changed files with 102 additions and 8 deletions

View file

@ -78,6 +78,7 @@ namespace SafeExamBrowser.Browser
control.AuthCredentialsRequired += (w, b, o, i, h, p, r, s, c, a) => a.Value = requestHandler.GetAuthCredentials(w, b, o, i, h, p, r, s, c);
control.BeforeBrowse += (w, b, f, r, u, i, a) => a.Value = requestHandler.OnBeforeBrowse(w, b, f, r, u, i);
control.BeforeDownload += (w, b, d, c) => downloadHandler.OnBeforeDownload(w, b, d, c);
control.CanDownload += (w, b, u, r, a) => a.Value = downloadHandler.CanDownload(w, b, u, r);
control.DownloadUpdated += (w, b, d, c) => downloadHandler.OnDownloadUpdated(w, b, d, c);
control.FaviconUrlChanged += (w, b, u) => displayHandler.OnFaviconUrlChange(w, b, u);
control.FileDialogRequested += (w, b, m, f, t, d, a, s, c) => dialogHandler.OnFileDialog(w, b, m, f, t, d, a, s, c);

View file

@ -156,6 +156,7 @@ namespace SafeExamBrowser.Browser
displayHandler.FaviconChanged += DisplayHandler_FaviconChanged;
displayHandler.ProgressChanged += DisplayHandler_ProgressChanged;
downloadHandler.ConfigurationDownloadRequested += DownloadHandler_ConfigurationDownloadRequested;
downloadHandler.DownloadAborted += DownloadHandler_DownloadAborted;
downloadHandler.DownloadUpdated += DownloadHandler_DownloadUpdated;
keyboardHandler.FindRequested += KeyboardHandler_FindRequested;
keyboardHandler.HomeNavigationRequested += HomeNavigationRequested;
@ -352,6 +353,7 @@ namespace SafeExamBrowser.Browser
else
{
logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed.");
ShowDownUploadNotAllowedMessage(isDownload);
}
}
@ -401,6 +403,11 @@ namespace SafeExamBrowser.Browser
}
}
private void DownloadHandler_DownloadAborted()
{
ShowDownUploadNotAllowedMessage();
}
private void DownloadHandler_DownloadUpdated(DownloadItemState state)
{
window.UpdateDownloadState(state);
@ -610,6 +617,14 @@ namespace SafeExamBrowser.Browser
}
}
private void ShowDownUploadNotAllowedMessage(bool isDownload = true)
{
var message = isDownload ? TextKey.MessageBox_DownloadNotAllowed : TextKey.MessageBox_UploadNotAllowed;
var title = isDownload ? TextKey.MessageBox_DownloadNotAllowedTitle : TextKey.MessageBox_UploadNotAllowedTitle;
messageBox.Show(message, title, icon: MessageBoxIcon.Warning, parent: window);
}
private void Window_AddressChanged(string address)
{
var isValid = Uri.TryCreate(address, UriKind.Absolute, out _) || Uri.TryCreate($"https://{address}", UriKind.Absolute, out _);
@ -704,7 +719,7 @@ namespace SafeExamBrowser.Browser
private void TabPressed(bool shiftPressed)
{
this.Control.ExecuteJavascript("document.activeElement.tagName", result =>
Control.ExecuteJavascript("document.activeElement.tagName", result =>
{
var tagName = result.Result as string;
if (tagName != null)
@ -718,7 +733,7 @@ namespace SafeExamBrowser.Browser
}
else
{
this.LoseFocusRequested?.Invoke(true);
LoseFocusRequested?.Invoke(true);
}
}
}
@ -734,8 +749,7 @@ namespace SafeExamBrowser.Browser
else
{
window.FocusBrowser();
this.Activate();
Activate();
}
}

View file

@ -0,0 +1,12 @@
/*
* Copyright (c) 2022 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Browser.Events
{
internal delegate void DownloadAbortedEventHandler();
}

View file

@ -32,6 +32,7 @@ namespace SafeExamBrowser.Browser.Handlers
private readonly WindowSettings windowSettings;
internal event DownloadRequestedEventHandler ConfigurationDownloadRequested;
internal event DownloadAbortedEventHandler DownloadAborted;
internal event DownloadUpdatedEventHandler DownloadUpdated;
internal DownloadHandler(AppConfig appConfig, ILogger logger, BrowserSettings settings, WindowSettings windowSettings)
@ -73,6 +74,7 @@ namespace SafeExamBrowser.Browser.Handlers
else
{
logger.Info($"Aborted download request{(windowSettings.UrlPolicy.CanLog() ? $" for '{uri}'" : "")}, as downloading is not allowed.");
Task.Run(() => DownloadAborted?.Invoke());
}
}

View file

@ -82,6 +82,7 @@
<Compile Include="BrowserWindow.cs" />
<Compile Include="Events\DialogRequestedEventArgs.cs" />
<Compile Include="Events\DialogRequestedEventHandler.cs" />
<Compile Include="Events\DownloadAbortedEventHandler.cs" />
<Compile Include="Events\DownloadUpdatedEventHandler.cs" />
<Compile Include="Events\FaviconChangedEventHandler.cs" />
<Compile Include="Events\WindowClosedEventHandler.cs" />

View file

@ -94,6 +94,12 @@ namespace SafeExamBrowser.I18n.Contracts
MessageBox_ClientConfigurationQuestionTitle,
MessageBox_ConfigurationDownloadError,
MessageBox_ConfigurationDownloadErrorTitle,
MessageBox_DisplayConfigurationError,
MessageBox_DisplayConfigurationErrorTitle,
MessageBox_DisplayConfigurationInternal,
MessageBox_DisplayConfigurationInternalOrExternal,
MessageBox_DownloadNotAllowed,
MessageBox_DownloadNotAllowedTitle,
MessageBox_InvalidConfigurationData,
MessageBox_InvalidConfigurationDataTitle,
MessageBox_InvalidHomePassword,
@ -105,10 +111,6 @@ namespace SafeExamBrowser.I18n.Contracts
MessageBox_InvalidUnlockPassword,
MessageBox_InvalidUnlockPasswordTitle,
MessageBox_NoButton,
MessageBox_DisplayConfigurationError,
MessageBox_DisplayConfigurationErrorTitle,
MessageBox_DisplayConfigurationInternal,
MessageBox_DisplayConfigurationInternalOrExternal,
MessageBox_NotSupportedConfigurationResource,
MessageBox_NotSupportedConfigurationResourceTitle,
MessageBox_OkButton,
@ -140,6 +142,8 @@ namespace SafeExamBrowser.I18n.Contracts
MessageBox_StartupErrorTitle,
MessageBox_UnexpectedConfigurationError,
MessageBox_UnexpectedConfigurationErrorTitle,
MessageBox_UploadNotAllowed,
MessageBox_UploadNotAllowedTitle,
MessageBox_VirtualMachineNotAllowed,
MessageBox_VirtualMachineNotAllowedTitle,
MessageBox_YesButton,

View file

@ -252,6 +252,12 @@
<Entry key="MessageBox_DisplayConfigurationInternalOrExternal">
interne(r) oder externe(r)
</Entry>
<Entry key="MessageBox_DownloadNotAllowed">
Das Herunterladen von Dateien ist in den aktuellen SEB-Einstellungen nicht erlaubt. Bitte melden Sie dies Ihrem Prüfungsanbieter.
</Entry>
<Entry key="MessageBox_DownloadNotAllowedTitle">
Herunterladen nicht erlaubt!
</Entry>
<Entry key="MessageBox_InvalidConfigurationData">
Die Konfigurations-Ressource "%%URI%%" enthält ungültige Daten!
</Entry>
@ -378,6 +384,12 @@
<Entry key="MessageBox_UnexpectedConfigurationErrorTitle">
Konfigurations-Fehler
</Entry>
<Entry key="MessageBox_UploadNotAllowed">
Das Hochladen von Dateien ist in den aktuellen SEB-Einstellungen nicht erlaubt. Bitte melden Sie dies Ihrem Prüfungsanbieter.
</Entry>
<Entry key="MessageBox_UploadNotAllowedTitle">
Hochladen nicht erlaubt!
</Entry>
<Entry key="MessageBox_VirtualMachineNotAllowed">
Dieser Computer scheint eine virtuelle Maschine zu sein. Die ausgewählte Konfiguration erlaubt es nicht, SEB in einer virtuellen Maschine auszuführen.
</Entry>

View file

@ -252,6 +252,12 @@
<Entry key="MessageBox_DisplayConfigurationInternalOrExternal">
internal or external
</Entry>
<Entry key="MessageBox_DownloadNotAllowed">
Downloading files is not allowed in the current SEB settings. Please report this to your exam provider.
</Entry>
<Entry key="MessageBox_DownloadNotAllowedTitle">
Downloading Not Allowed!
</Entry>
<Entry key="MessageBox_InvalidConfigurationData">
The configuration resource "%%URI%%" contains invalid data!
</Entry>
@ -378,6 +384,12 @@
<Entry key="MessageBox_UnexpectedConfigurationErrorTitle">
Configuration Error
</Entry>
<Entry key="MessageBox_UploadNotAllowed">
Uploading files is not allowed in the current SEB settings. Please report this to your exam provider.
</Entry>
<Entry key="MessageBox_UploadNotAllowedTitle">
Uploading Not Allowed!
</Entry>
<Entry key="MessageBox_VirtualMachineNotAllowed">
This computer appears to be a virtual machine. The selected configuration does not allow SEB to be run in a virtual machine.
</Entry>

View file

@ -252,6 +252,12 @@
<Entry key="MessageBox_DisplayConfigurationInternalOrExternal">
interne(s) ou externe(s)
</Entry>
<Entry key="MessageBox_DownloadNotAllowed">
Le téléchargement de fichiers n'est pas autorisé dans les paramètres SEB actuels. Veuillez le signaler à votre fournisseur d'examen.
</Entry>
<Entry key="MessageBox_DownloadNotAllowedTitle">
Téléchargement non autorisé!
</Entry>
<Entry key="MessageBox_InvalidConfigurationData">
La ressource de configuration "%%URI%%" contient des données non valides!
</Entry>
@ -378,6 +384,12 @@
<Entry key="MessageBox_UnexpectedConfigurationErrorTitle">
Erreur de configuration
</Entry>
<Entry key="MessageBox_UploadNotAllowed">
Le téléchargement de fichiers n'est pas autorisé dans les paramètres SEB actuels. Veuillez le signaler à votre fournisseur d'examen.
</Entry>
<Entry key="MessageBox_UploadNotAllowedTitle">
Téléchargement non autorisé!
</Entry>
<Entry key="MessageBox_VirtualMachineNotAllowed">
Cet ordinateur semble être une machine virtuelle. La configuration sélectionnée ne permet pas à SEB de fonctionner dans une machine virtuelle.
</Entry>

View file

@ -252,6 +252,12 @@
<Entry key="MessageBox_DisplayConfigurationInternalOrExternal">
interno/i o esterno/i
</Entry>
<Entry key="MessageBox_DownloadNotAllowed">
Il download di file non è consentito nelle impostazioni SEB correnti. Si prega di segnalarlo al fornitore dell'esame.
</Entry>
<Entry key="MessageBox_DownloadNotAllowedTitle">
Download non consentito!
</Entry>
<Entry key="MessageBox_InvalidConfigurationData">
La risorsa di configurazione "%%URI%%" contiene dati non validi!
</Entry>
@ -378,6 +384,12 @@
<Entry key="MessageBox_UnexpectedConfigurationErrorTitle">
Errore di configurazione
</Entry>
<Entry key="MessageBox_UploadNotAllowed">
Il upload di file non è consentito nelle impostazioni SEB correnti. Si prega di segnalarlo al fornitore dell'esame.
</Entry>
<Entry key="MessageBox_UploadNotAllowedTitle">
Upload non consentito!
</Entry>
<Entry key="MessageBox_VirtualMachineNotAllowed">
Questo computer sembra essere una macchina virtuale. La configurazione selezionata non consente l'esecuzione di SEB in una macchina virtuale.
</Entry>

View file

@ -222,6 +222,12 @@
<Entry key="MessageBox_DisplayConfigurationInternalOrExternal">
内部或外部
</Entry>
<Entry key="MessageBox_DownloadNotAllowed">
当前 SEB 设置中不允许下载文件。 请将此情况报告给您的考试提供商。
</Entry>
<Entry key="MessageBox_DownloadNotAllowedTitle">
不允许下载!
</Entry>
<Entry key="MessageBox_InvalidConfigurationData">
配置"%%URI%%" 中包含无效数据。
</Entry>
@ -342,6 +348,12 @@
<Entry key="MessageBox_UnexpectedConfigurationErrorTitle">
配置错误
</Entry>
<Entry key="MessageBox_UploadNotAllowed">
当前 SEB 设置中不允许上传文件。 请将此情况报告给您的考试提供商。
</Entry>
<Entry key="MessageBox_UploadNotAllowedTitle">
不允许上传!
</Entry>
<Entry key="MessageBox_VirtualMachineNotAllowed">
这台电脑是一个虚拟机。所选配置不允许防作弊考试专用浏览器在虚拟机中运行。
</Entry>