// ********************************** // Output an error or warning message // ********************************** public static DialogResult Show(string messageTitle, string messageText, MessageBoxIcon messageBoxIcon, MessageBoxButtons messageButtons, bool neverShowTouchOptimized = false) { // If we are running in SebWindowsClient we need to activate it before showing the password dialog if (SEBClientInfo.SebWindowsClientForm != null) { SebWindowsClientMain.SEBToForeground(); } DialogResult messageBoxResult; if (!neverShowTouchOptimized && (Boolean)SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized] == true) { messageBoxResult = MetroMessageBox.Show( new Form() { TopMost = true, Top = 0, Left = 0, Width = Screen.PrimaryScreen.Bounds.Width, Height = Screen.PrimaryScreen.Bounds.Height }, messageText, messageTitle, messageButtons, messageBoxIcon); } else { messageBoxResult = MessageBox.Show(new Form() { TopMost = true }, messageText, messageTitle, messageButtons, messageBoxIcon); } return(messageBoxResult); }
public static DialogResult Show(string messageTitle, string messageText, MessageBoxIcon messageBoxIcon, MessageBoxButtons messageButtons, bool neverShowTouchOptimized = false) { if (SEBClientInfo.SebWindowsClientForm != null) { SebWindowsClientMain.SEBToForeground(); } DialogResult dialogResult; if (!neverShowTouchOptimized && (bool)SEBClientInfo.getSebSetting("touchOptimized")["touchOptimized"]) { Form form = new Form(); form.TopMost = true; int num1 = 0; form.Top = num1; int num2 = 0; form.Left = num2; Rectangle bounds = Screen.PrimaryScreen.Bounds; int width = bounds.Width; form.Width = width; bounds = Screen.PrimaryScreen.Bounds; int height1 = bounds.Height; form.Height = height1; string message = messageText; string title = messageTitle; int num3 = (int)messageButtons; int num4 = (int)messageBoxIcon; int height2 = 211; dialogResult = MetroMessageBox.Show((IWin32Window)form, message, title, (MessageBoxButtons)num3, (MessageBoxIcon)num4, height2); } else { Form form = new Form(); form.TopMost = true; string text = messageText; string caption = messageTitle; int num1 = (int)messageButtons; int num2 = (int)messageBoxIcon; dialogResult = MessageBox.Show((IWin32Window)form, text, caption, (MessageBoxButtons)num1, (MessageBoxIcon)num2); } return(dialogResult); }
private static void OnClientMessageBinary(byte[] obj) { // Check if we're running in exam mode already, if yes, then refuse to load a .seb file if (SEBClientInfo.examMode) { Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data is not allowed because it is already running in exam mode, sending command ReconfigureAborted to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted)); SebWindowsClientMain.LoadingSebFile(false); SebWindowsClientForm.ShowReconfigureNotAllowed(); return; } HasBeenReconfiguredByMessage = true; Logger.AddInformation("Received downloaded Config File data, " + obj.Length + " bytes. Sending command SebFileTransfer to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.SebFileTransfer, true)); if (SEBClientInfo.SebWindowsClientForm.ReconfigureWithSettings(obj)) { Logger.AddInformation("SEB was successfully reconfigured using the downloaded Config File data"); // Convert new URL Filter rules to XUL seb2 rules // and add Start URL to allowed rules SEBURLFilter urlFilter = new SEBURLFilter(); urlFilter.UpdateFilterRules(); // Create JSON object with XULRunner parameters to pass to firefox.exe as base64 string var xulRunnerSettings = DeepClone(SEBSettings.settingsCurrent); string XULRunnerParameters = SEBXulRunnerSettings.XULRunnerConfigDictionarySerialize(xulRunnerSettings); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.Reconfigure, new { configBase64 = XULRunnerParameters })); } else { Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data failed, sending command ReconfigureAborted to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted)); } HasBeenReconfiguredByMessage = false; }
/// ---------------------------------------------------------------------------------------- /// <summary> /// Decrypt, parse and use new SEB settings /// </summary> /// ---------------------------------------------------------------------------------------- public static bool StoreDecryptedSEBSettings(byte[] sebData) { DictObj sebPreferencesDict; string sebFilePassword = null; bool passwordIsHash = false; X509Certificate2 sebFileCertificateRef = null; sebPreferencesDict = DecryptSEBSettings(sebData, false, ref sebFilePassword, ref passwordIsHash, ref sebFileCertificateRef); if (sebPreferencesDict == null) { return(false); //Decryption didn't work, we abort } Logger.AddInformation("Reconfiguring"); // Reset SEB, close third party applications SEBClientInfo.SebWindowsClientForm.closeSebClient = false; Logger.AddInformation("Attempting to CloseSEBForm for reconfiguration"); SEBClientInfo.SebWindowsClientForm.CloseSEBForm(); Logger.AddInformation("Succesfully CloseSEBForm for reconfiguration"); SEBClientInfo.SebWindowsClientForm.closeSebClient = true; //SEBClientInfo.SebWindowsClientForm.Close(); //SEBClientInfo.SebWindowsClientForm.Dispose(); // We need to check if setting for createNewDesktop changed SEBClientInfo.CreateNewDesktopOldValue = (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyCreateNewDesktop); if ((int)sebPreferencesDict[SEBSettings.KeySebConfigPurpose] == (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam) { /// /// If these SEB settings are ment to start an exam /// Logger.AddInformation("Reconfiguring to start an exam"); /// If these SEB settings are ment to start an exam // Store decrypted settings Logger.AddInformation("Attempting to StoreSebClientSettings"); SEBSettings.StoreSebClientSettings(sebPreferencesDict); Logger.AddInformation("Successfully StoreSebClientSettings"); // Set the flag that SEB is running in exam mode now SEBClientInfo.examMode = true; //Re-initialize logger SEBClientInfo.InitializeLogger(); // Check if SEB is running on the standard desktop and the new settings demand to run in new desktop (createNewDesktop = true) // or the other way around! if (SEBClientInfo.CreateNewDesktopOldValue != (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyCreateNewDesktop)) { // If it did, SEB needs to quit and be restarted manually for the new setting to take effekt if (SEBClientInfo.CreateNewDesktopOldValue == false) { SEBMessageBox.Show(SEBUIStrings.settingsRequireNewDesktop, SEBUIStrings.settingsRequireNewDesktopReason, MessageBoxIcon.Error, MessageBoxButtons.OK); } else { SEBMessageBox.Show(SEBUIStrings.settingsRequireNotNewDesktop, SEBUIStrings.settingsRequireNotNewDesktopReason, MessageBoxIcon.Error, MessageBoxButtons.OK); } //SEBClientInfo.SebWindowsClientForm.closeSebClient = true; SEBClientInfo.SebWindowsClientForm.ExitApplication(); } // Re-Initialize SEB according to the new settings Logger.AddInformation("Attemting to InitSEBDesktop for reconfiguration"); if (!SebWindowsClientMain.InitSEBDesktop()) { return(false); } Logger.AddInformation("Sucessfully InitSEBDesktop for reconfiguration"); // Re-open the main form //SEBClientInfo.SebWindowsClientForm = new SebWindowsClientForm(); //SebWindowsClientMain.singleInstanceController.SetMainForm(SEBClientInfo.SebWindowsClientForm); //return if initializing SEB with openend preferences was successful Logger.AddInformation("Attempting to OpenSEBForm for reconfiguration"); var ret = SEBClientInfo.SebWindowsClientForm.OpenSEBForm(); Logger.AddInformation("Successfully OpenSEBForm for reconfiguration"); return(ret); } else { /// /// If these SEB settings are ment to configure a client /// Logger.AddInformation("Reconfiguring to configure a client"); /// If these SEB settings are ment to configure a client // Check if we have embedded identities and import them into the Windows Certifcate Store ListObj embeddedCertificates = (ListObj)sebPreferencesDict[SEBSettings.KeyEmbeddedCertificates]; for (int i = embeddedCertificates.Count - 1; i >= 0; i--) { // Get the Embedded Certificate DictObj embeddedCertificate = (DictObj)embeddedCertificates[i]; // Is it an identity? if ((int)embeddedCertificate[SEBSettings.KeyType] == 1) { // Store the identity into the Windows Certificate Store SEBProtectionController.StoreCertificateIntoStore((byte[])embeddedCertificate[SEBSettings.KeyCertificateData]); } // Remove the identity from settings, as it should be only stored in the Certificate Store and not in the locally stored settings file embeddedCertificates.RemoveAt(i); } // Store decrypted settings SEBSettings.StoreSebClientSettings(sebPreferencesDict); //Re-initialize logger SEBClientInfo.InitializeLogger(); // Write new settings to the localapp directory SEBSettings.WriteSebConfigurationFile(SEBClientInfo.SebClientSettingsAppDataFile, "", false, null, SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient); // Re-Initialize SEB desktop according to the new settings if (!SebWindowsClientMain.InitSEBDesktop()) { return(false); } if (SEBClientInfo.SebWindowsClientForm.OpenSEBForm()) { // Activate SebWindowsClient so the message box gets focus //SEBClientInfo.SebWindowsClientForm.Activate(); // Check if setting for createNewDesktop changed if (SEBClientInfo.CreateNewDesktopOldValue != (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyCreateNewDesktop)) { // If it did, SEB needs to quit and be restarted manually for the new setting to take effekt SEBMessageBox.Show(SEBUIStrings.sebReconfiguredRestartNeeded, SEBUIStrings.sebReconfiguredRestartNeededReason, MessageBoxIcon.Warning, MessageBoxButtons.OK); //SEBClientInfo.SebWindowsClientForm.closeSebClient = true; SEBClientInfo.SebWindowsClientForm.ExitApplication(); } if (SEBMessageBox.Show(SEBUIStrings.sebReconfigured, SEBUIStrings.sebReconfiguredQuestion, MessageBoxIcon.Question, MessageBoxButtons.YesNo) == DialogResult.No) { //SEBClientInfo.SebWindowsClientForm.closeSebClient = true; SEBClientInfo.SebWindowsClientForm.ExitApplication(); } return(true); //reading preferences was successful } else { return(false); } } }
public static bool StoreDecryptedSEBSettings(byte[] sebData) { string sebFilePassword = (string)null; bool passwordIsHash = false; X509Certificate2 sebFileCertificateRef = (X509Certificate2)null; Dictionary <string, object> settingsDict = SEBConfigFileManager.DecryptSEBSettings(sebData, false, ref sebFilePassword, ref passwordIsHash, ref sebFileCertificateRef); if (settingsDict == null) { return(false); } Logger.AddInformation("Reconfiguring", (object)null, (Exception)null, (string)null); SEBClientInfo.SebWindowsClientForm.closeSebClient = false; Logger.AddInformation("Attempting to CloseSEBForm for reconfiguration", (object)null, (Exception)null, (string)null); SEBClientInfo.SebWindowsClientForm.CloseSEBForm(); Logger.AddInformation("Succesfully CloseSEBForm for reconfiguration", (object)null, (Exception)null, (string)null); SEBClientInfo.SebWindowsClientForm.closeSebClient = true; SEBClientInfo.CreateNewDesktopOldValue = (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, "createNewDesktop"); if ((int)settingsDict["sebConfigPurpose"] == 0) { Logger.AddInformation("Reconfiguring to start an exam", (object)null, (Exception)null, (string)null); Logger.AddInformation("Attempting to StoreSebClientSettings", (object)null, (Exception)null, (string)null); SEBSettings.StoreSebClientSettings(settingsDict); Logger.AddInformation("Successfully StoreSebClientSettings", (object)null, (Exception)null, (string)null); SEBClientInfo.examMode = true; SEBClientInfo.InitializeLogger(); if (SEBClientInfo.CreateNewDesktopOldValue != (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, "createNewDesktop")) { if (!SEBClientInfo.CreateNewDesktopOldValue) { int num1 = (int)SEBMessageBox.Show(SEBUIStrings.settingsRequireNewDesktop, SEBUIStrings.settingsRequireNewDesktopReason, MessageBoxIcon.Hand, MessageBoxButtons.OK, false); } else { int num2 = (int)SEBMessageBox.Show(SEBUIStrings.settingsRequireNotNewDesktop, SEBUIStrings.settingsRequireNotNewDesktopReason, MessageBoxIcon.Hand, MessageBoxButtons.OK, false); } SEBClientInfo.SebWindowsClientForm.ExitApplication(true); } Logger.AddInformation("Attemting to InitSEBDesktop for reconfiguration", (object)null, (Exception)null, (string)null); if (!SebWindowsClientMain.InitSEBDesktop()) { return(false); } Logger.AddInformation("Sucessfully InitSEBDesktop for reconfiguration", (object)null, (Exception)null, (string)null); Logger.AddInformation("Attempting to OpenSEBForm for reconfiguration", (object)null, (Exception)null, (string)null); int num = SEBClientInfo.SebWindowsClientForm.OpenSEBForm() ? 1 : 0; Logger.AddInformation("Successfully OpenSEBForm for reconfiguration", (object)null, (Exception)null, (string)null); return(num != 0); } Logger.AddInformation("Reconfiguring to configure a client", (object)null, (Exception)null, (string)null); List <object> objectList = (List <object>)settingsDict["embeddedCertificates"]; for (int index = objectList.Count - 1; index >= 0; --index) { Dictionary <string, object> dictionary = (Dictionary <string, object>)objectList[index]; if ((int)dictionary["type"] == 1) { SEBProtectionController.StoreCertificateIntoStore((byte[])dictionary["certificateData"]); } objectList.RemoveAt(index); } SEBSettings.StoreSebClientSettings(settingsDict); SEBClientInfo.InitializeLogger(); SEBSettings.WriteSebConfigurationFile(SEBClientInfo.SebClientSettingsAppDataFile, "", false, (X509Certificate2)null, SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient, false); if (!SebWindowsClientMain.InitSEBDesktop() || !SEBClientInfo.SebWindowsClientForm.OpenSEBForm()) { return(false); } if (SEBClientInfo.CreateNewDesktopOldValue != (bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, "createNewDesktop")) { int num = (int)SEBMessageBox.Show(SEBUIStrings.sebReconfiguredRestartNeeded, SEBUIStrings.sebReconfiguredRestartNeededReason, MessageBoxIcon.Exclamation, MessageBoxButtons.OK, false); SEBClientInfo.SebWindowsClientForm.ExitApplication(true); } if (SEBMessageBox.Show(SEBUIStrings.sebReconfigured, SEBUIStrings.sebReconfiguredQuestion, MessageBoxIcon.Question, MessageBoxButtons.YesNo, false) == DialogResult.No) { SEBClientInfo.SebWindowsClientForm.ExitApplication(true); } return(true); }