SEBWIN-337: It is with great pain that I must declare in this here commit message that the utter abomination which is the legacy configuration tool now is integrated into the solution. May it soon become obsolete for good and be swiftly exterminated thereafter!

This commit is contained in:
dbuechel 2019-08-07 10:10:37 +02:00
parent 9f9b3c35ed
commit b8ea068d17
57 changed files with 30643 additions and 0 deletions

View file

@ -72,6 +72,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "Setup\Setup.wixpro
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SetupBundle", "SetupBundle\SetupBundle.wixproj", "{95B68CBF-C483-4824-BB39-663E840519A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SebWindowsConfig", "SebWindowsConfig\SebWindowsConfig.csproj", "{BEF73897-0D04-4F40-AD89-62E24D260CD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -306,6 +308,14 @@ Global
{95B68CBF-C483-4824-BB39-663E840519A0}.Release|Any CPU.ActiveCfg = Release|x86
{95B68CBF-C483-4824-BB39-663E840519A0}.Release|x86.ActiveCfg = Release|x86
{95B68CBF-C483-4824-BB39-663E840519A0}.Release|x86.Build.0 = Release|x86
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Debug|x86.ActiveCfg = Debug|x86
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Debug|x86.Build.0 = Debug|x86
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Release|Any CPU.Build.0 = Release|Any CPU
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Release|x86.ActiveCfg = Release|x86
{BEF73897-0D04-4F40-AD89-62E24D260CD0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -0,0 +1,661 @@
namespace SebWindowsConfig.Controls
{
partial class AdditionalResources
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdditionalResources));
this.buttonAdditionalResourcesAddSubResource = new System.Windows.Forms.Button();
this.buttonAdditionalResourcesMoveDown = new System.Windows.Forms.Button();
this.buttonAdditionalResourcesMoveUp = new System.Windows.Forms.Button();
this.buttonAdditionalResourcesAdd = new System.Windows.Forms.Button();
this.buttonadditionalResourcesRemove = new System.Windows.Forms.Button();
this.groupBoxAdditionalResourceDetails = new System.Windows.Forms.GroupBox();
this.UrlFilterGroupBox = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.checkBoxShowButton = new System.Windows.Forms.CheckBox();
this.checkBoxAdditionalResourceAutoOpen = new System.Windows.Forms.CheckBox();
this.textBoxLinkURL = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.comboBoxModifiers = new System.Windows.Forms.ComboBox();
this.textBoxKey = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.textBoxRefererFilter = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBoxConfirmBoxText = new System.Windows.Forms.TextBox();
this.checkBoxConfirm = new System.Windows.Forms.CheckBox();
this.label10 = new System.Windows.Forms.Label();
this.labelAdditionalResourcesFilename = new System.Windows.Forms.Label();
this.checkBoxResetSession = new System.Windows.Forms.CheckBox();
this.comboBoxAdditionalResourcesChooseFileToLaunch = new System.Windows.Forms.ComboBox();
this.buttonAdditionalResourcesChooseEmbeddedFolder = new System.Windows.Forms.Button();
this.labelAdditionalResourceUrl = new System.Windows.Forms.Label();
this.labelAdditionalResourcesResourceDataLaunchWith = new System.Windows.Forms.Label();
this.textBoxAdditionalResourceUrl = new System.Windows.Forms.TextBox();
this.comboBoxAdditionalResourcesResourceDataLauncher = new System.Windows.Forms.ComboBox();
this.buttonAdditionalResourceRemoveResourceData = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.buttonAdditionalResourceEmbededResourceOpen = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.buttonAdditionalResourceChooseEmbededResource = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBoxAdditionalResourcesTitle = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.buttonAdditionalResourcesChooseIcon = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.pictureBoxAdditionalResourceIcon = new System.Windows.Forms.PictureBox();
this.checkBoxAdditionalResourceActive = new System.Windows.Forms.CheckBox();
this.treeViewAdditionalResources = new System.Windows.Forms.TreeView();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.groupBoxAdditionalResourceDetails.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAdditionalResourceIcon)).BeginInit();
this.SuspendLayout();
//
// buttonAdditionalResourcesAddSubResource
//
this.buttonAdditionalResourcesAddSubResource.Location = new System.Drawing.Point(179, 568);
this.buttonAdditionalResourcesAddSubResource.Name = "buttonAdditionalResourcesAddSubResource";
this.buttonAdditionalResourcesAddSubResource.Size = new System.Drawing.Size(26, 26);
this.buttonAdditionalResourcesAddSubResource.TabIndex = 14;
this.buttonAdditionalResourcesAddSubResource.Text = "(+)";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesAddSubResource, "Create a submenu");
this.buttonAdditionalResourcesAddSubResource.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesAddSubResource.Click += new System.EventHandler(this.buttonAdditionalResourcesAddSubResource_Click);
//
// buttonAdditionalResourcesMoveDown
//
this.buttonAdditionalResourcesMoveDown.Location = new System.Drawing.Point(35, 568);
this.buttonAdditionalResourcesMoveDown.Name = "buttonAdditionalResourcesMoveDown";
this.buttonAdditionalResourcesMoveDown.Size = new System.Drawing.Size(26, 26);
this.buttonAdditionalResourcesMoveDown.TabIndex = 13;
this.buttonAdditionalResourcesMoveDown.Text = "v";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesMoveDown, "Move resource down in the list");
this.buttonAdditionalResourcesMoveDown.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesMoveDown.Click += new System.EventHandler(this.buttonAdditionalResourcesMoveDown_Click);
//
// buttonAdditionalResourcesMoveUp
//
this.buttonAdditionalResourcesMoveUp.Location = new System.Drawing.Point(3, 568);
this.buttonAdditionalResourcesMoveUp.Name = "buttonAdditionalResourcesMoveUp";
this.buttonAdditionalResourcesMoveUp.Size = new System.Drawing.Size(26, 26);
this.buttonAdditionalResourcesMoveUp.TabIndex = 12;
this.buttonAdditionalResourcesMoveUp.Text = "^";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesMoveUp, "Move resource up in the list");
this.buttonAdditionalResourcesMoveUp.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesMoveUp.Click += new System.EventHandler(this.buttonAdditionalResourcesMoveUp_Click);
//
// buttonAdditionalResourcesAdd
//
this.buttonAdditionalResourcesAdd.Location = new System.Drawing.Point(221, 568);
this.buttonAdditionalResourcesAdd.Name = "buttonAdditionalResourcesAdd";
this.buttonAdditionalResourcesAdd.Size = new System.Drawing.Size(26, 26);
this.buttonAdditionalResourcesAdd.TabIndex = 11;
this.buttonAdditionalResourcesAdd.Text = "+";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesAdd, "Add resource");
this.buttonAdditionalResourcesAdd.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesAdd.Click += new System.EventHandler(this.buttonAdditionalResourcesAdd_Click);
//
// buttonadditionalResourcesRemove
//
this.buttonadditionalResourcesRemove.Location = new System.Drawing.Point(254, 568);
this.buttonadditionalResourcesRemove.Name = "buttonadditionalResourcesRemove";
this.buttonadditionalResourcesRemove.Size = new System.Drawing.Size(26, 26);
this.buttonadditionalResourcesRemove.TabIndex = 10;
this.buttonadditionalResourcesRemove.Text = "-";
this.toolTip1.SetToolTip(this.buttonadditionalResourcesRemove, "Remove resource");
this.buttonadditionalResourcesRemove.UseVisualStyleBackColor = true;
this.buttonadditionalResourcesRemove.Click += new System.EventHandler(this.buttonadditionalResourcesRemove_Click);
//
// groupBoxAdditionalResourceDetails
//
this.groupBoxAdditionalResourceDetails.Controls.Add(this.UrlFilterGroupBox);
this.groupBoxAdditionalResourceDetails.Controls.Add(this.groupBox3);
this.groupBoxAdditionalResourceDetails.Controls.Add(this.groupBox2);
this.groupBoxAdditionalResourceDetails.Controls.Add(this.groupBox1);
this.groupBoxAdditionalResourceDetails.Controls.Add(this.checkBoxAdditionalResourceActive);
this.groupBoxAdditionalResourceDetails.Location = new System.Drawing.Point(285, 3);
this.groupBoxAdditionalResourceDetails.Name = "groupBoxAdditionalResourceDetails";
this.groupBoxAdditionalResourceDetails.Size = new System.Drawing.Size(932, 591);
this.groupBoxAdditionalResourceDetails.TabIndex = 9;
this.groupBoxAdditionalResourceDetails.TabStop = false;
this.groupBoxAdditionalResourceDetails.Text = "Selected Resource";
//
// UrlFilterGroupBox
//
this.UrlFilterGroupBox.Location = new System.Drawing.Point(9, 337);
this.UrlFilterGroupBox.Margin = new System.Windows.Forms.Padding(2);
this.UrlFilterGroupBox.Name = "UrlFilterGroupBox";
this.UrlFilterGroupBox.Padding = new System.Windows.Forms.Padding(2);
this.UrlFilterGroupBox.Size = new System.Drawing.Size(918, 249);
this.UrlFilterGroupBox.TabIndex = 34;
this.UrlFilterGroupBox.TabStop = false;
this.UrlFilterGroupBox.Text = "URL Filter";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.checkBoxShowButton);
this.groupBox3.Controls.Add(this.checkBoxAdditionalResourceAutoOpen);
this.groupBox3.Controls.Add(this.textBoxLinkURL);
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.comboBoxModifiers);
this.groupBox3.Controls.Add(this.textBoxKey);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.textBoxRefererFilter);
this.groupBox3.Location = new System.Drawing.Point(439, 38);
this.groupBox3.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox3.Size = new System.Drawing.Size(484, 127);
this.groupBox3.TabIndex = 33;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Activation";
//
// checkBoxShowButton
//
this.checkBoxShowButton.AutoSize = true;
this.checkBoxShowButton.Location = new System.Drawing.Point(172, 16);
this.checkBoxShowButton.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoxShowButton.Name = "checkBoxShowButton";
this.checkBoxShowButton.Size = new System.Drawing.Size(102, 17);
this.checkBoxShowButton.TabIndex = 21;
this.checkBoxShowButton.Text = "Show button (B)";
this.toolTip1.SetToolTip(this.checkBoxShowButton, "Shows the icon for the resource or its pop-up menu entry. If you\'re using a link " +
"URL to open the resource, you might not want users to be able to manually open t" +
"he resource.");
this.checkBoxShowButton.UseVisualStyleBackColor = true;
this.checkBoxShowButton.CheckedChanged += new System.EventHandler(this.checkBoxShowButton_CheckedChanged);
//
// checkBoxAdditionalResourceAutoOpen
//
this.checkBoxAdditionalResourceAutoOpen.AutoSize = true;
this.checkBoxAdditionalResourceAutoOpen.Location = new System.Drawing.Point(77, 16);
this.checkBoxAdditionalResourceAutoOpen.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoxAdditionalResourceAutoOpen.Name = "checkBoxAdditionalResourceAutoOpen";
this.checkBoxAdditionalResourceAutoOpen.Size = new System.Drawing.Size(91, 17);
this.checkBoxAdditionalResourceAutoOpen.TabIndex = 5;
this.checkBoxAdditionalResourceAutoOpen.Text = "Auto open (A)";
this.toolTip1.SetToolTip(this.checkBoxAdditionalResourceAutoOpen, "SEB opens the resource after starting automatically.");
this.checkBoxAdditionalResourceAutoOpen.UseVisualStyleBackColor = true;
this.checkBoxAdditionalResourceAutoOpen.CheckedChanged += new System.EventHandler(this.checkBoxAdditionalResourceAutoOpen_CheckedChanged);
//
// textBoxLinkURL
//
this.textBoxLinkURL.Location = new System.Drawing.Point(77, 38);
this.textBoxLinkURL.Name = "textBoxLinkURL";
this.textBoxLinkURL.Size = new System.Drawing.Size(403, 20);
this.textBoxLinkURL.TabIndex = 19;
this.textBoxLinkURL.TextChanged += new System.EventHandler(this.textBoxLinkURL_TextChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(26, 40);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(49, 13);
this.label5.TabIndex = 20;
this.label5.Text = "LinkURL";
//
// comboBoxModifiers
//
this.comboBoxModifiers.FormattingEnabled = true;
this.comboBoxModifiers.Items.AddRange(new object[] {
"control",
"alt",
"control + alt"});
this.comboBoxModifiers.Location = new System.Drawing.Point(158, 90);
this.comboBoxModifiers.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.comboBoxModifiers.Name = "comboBoxModifiers";
this.comboBoxModifiers.Size = new System.Drawing.Size(92, 21);
this.comboBoxModifiers.TabIndex = 27;
this.toolTip1.SetToolTip(this.comboBoxModifiers, "This modifier key has to be pressed together with the key.");
this.comboBoxModifiers.SelectedIndexChanged += new System.EventHandler(this.comboBoxModifiers_SelectedIndexChanged);
//
// textBoxKey
//
this.textBoxKey.Location = new System.Drawing.Point(77, 90);
this.textBoxKey.MaxLength = 1;
this.textBoxKey.Name = "textBoxKey";
this.textBoxKey.Size = new System.Drawing.Size(23, 20);
this.textBoxKey.TabIndex = 25;
this.toolTip1.SetToolTip(this.textBoxKey, "This key shortcut can be used to open the resource.");
this.textBoxKey.TextChanged += new System.EventHandler(this.textBoxKey_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(47, 92);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(25, 13);
this.label7.TabIndex = 26;
this.label7.Text = "Key";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(5, 65);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(67, 13);
this.label6.TabIndex = 23;
this.label6.Text = "Referrer filter";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(104, 92);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(49, 13);
this.label8.TabIndex = 26;
this.label8.Text = "Modifiers";
//
// textBoxRefererFilter
//
this.textBoxRefererFilter.Location = new System.Drawing.Point(77, 62);
this.textBoxRefererFilter.Name = "textBoxRefererFilter";
this.textBoxRefererFilter.Size = new System.Drawing.Size(403, 20);
this.textBoxRefererFilter.TabIndex = 22;
this.toolTip1.SetToolTip(this.textBoxRefererFilter, "The activation link URL works only on a web page with this referrer filter URL. Y" +
"ou can also use the \'*\' wildcard character in this referrer filter.");
this.textBoxRefererFilter.TextChanged += new System.EventHandler(this.textBoxRefererFilter_TextChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.textBoxConfirmBoxText);
this.groupBox2.Controls.Add(this.checkBoxConfirm);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.labelAdditionalResourcesFilename);
this.groupBox2.Controls.Add(this.checkBoxResetSession);
this.groupBox2.Controls.Add(this.comboBoxAdditionalResourcesChooseFileToLaunch);
this.groupBox2.Controls.Add(this.buttonAdditionalResourcesChooseEmbeddedFolder);
this.groupBox2.Controls.Add(this.labelAdditionalResourceUrl);
this.groupBox2.Controls.Add(this.labelAdditionalResourcesResourceDataLaunchWith);
this.groupBox2.Controls.Add(this.textBoxAdditionalResourceUrl);
this.groupBox2.Controls.Add(this.comboBoxAdditionalResourcesResourceDataLauncher);
this.groupBox2.Controls.Add(this.buttonAdditionalResourceRemoveResourceData);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.buttonAdditionalResourceEmbededResourceOpen);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.buttonAdditionalResourceChooseEmbededResource);
this.groupBox2.Location = new System.Drawing.Point(9, 165);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox2.Size = new System.Drawing.Size(918, 167);
this.groupBox2.TabIndex = 32;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Behavior";
//
// textBoxConfirmBoxText
//
this.textBoxConfirmBoxText.Location = new System.Drawing.Point(119, 97);
this.textBoxConfirmBoxText.Name = "textBoxConfirmBoxText";
this.textBoxConfirmBoxText.Size = new System.Drawing.Size(301, 20);
this.textBoxConfirmBoxText.TabIndex = 29;
this.toolTip1.SetToolTip(this.textBoxConfirmBoxText, "Optional custom confirm text");
this.textBoxConfirmBoxText.TextChanged += new System.EventHandler(this.textBoxConfirmBoxText_TextChanged);
//
// checkBoxConfirm
//
this.checkBoxConfirm.AutoSize = true;
this.checkBoxConfirm.Location = new System.Drawing.Point(30, 67);
this.checkBoxConfirm.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoxConfirm.Name = "checkBoxConfirm";
this.checkBoxConfirm.Size = new System.Drawing.Size(110, 17);
this.checkBoxConfirm.TabIndex = 28;
this.checkBoxConfirm.Text = "Show confirm box";
this.toolTip1.SetToolTip(this.checkBoxConfirm, "Before opening the resource, the user has to confirm this in a message box.");
this.checkBoxConfirm.UseVisualStyleBackColor = true;
this.checkBoxConfirm.CheckedChanged += new System.EventHandler(this.checkBoxConfirm_CheckedChanged);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(27, 99);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(82, 13);
this.label10.TabIndex = 30;
this.label10.Text = "Confirm box text";
this.toolTip1.SetToolTip(this.label10, "Custom text for the confirm message box.");
//
// labelAdditionalResourcesFilename
//
this.labelAdditionalResourcesFilename.AutoSize = true;
this.labelAdditionalResourcesFilename.Location = new System.Drawing.Point(503, 62);
this.labelAdditionalResourcesFilename.Name = "labelAdditionalResourcesFilename";
this.labelAdditionalResourcesFilename.Size = new System.Drawing.Size(70, 26);
this.labelAdditionalResourcesFilename.TabIndex = 18;
this.labelAdditionalResourcesFilename.Text = "Filename / \r\nFile to launch";
//
// checkBoxResetSession
//
this.checkBoxResetSession.AutoSize = true;
this.checkBoxResetSession.Location = new System.Drawing.Point(30, 128);
this.checkBoxResetSession.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoxResetSession.Name = "checkBoxResetSession";
this.checkBoxResetSession.Size = new System.Drawing.Size(132, 17);
this.checkBoxResetSession.TabIndex = 24;
this.checkBoxResetSession.Text = "Reset browser session";
this.toolTip1.SetToolTip(this.checkBoxResetSession, "When opening the resource, the browser session is reset, which for example logs o" +
"ur users.");
this.checkBoxResetSession.UseVisualStyleBackColor = true;
this.checkBoxResetSession.CheckedChanged += new System.EventHandler(this.checkBoxResetSession_CheckedChanged);
//
// comboBoxAdditionalResourcesChooseFileToLaunch
//
this.comboBoxAdditionalResourcesChooseFileToLaunch.FormattingEnabled = true;
this.comboBoxAdditionalResourcesChooseFileToLaunch.Location = new System.Drawing.Point(578, 66);
this.comboBoxAdditionalResourcesChooseFileToLaunch.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.comboBoxAdditionalResourcesChooseFileToLaunch.Name = "comboBoxAdditionalResourcesChooseFileToLaunch";
this.comboBoxAdditionalResourcesChooseFileToLaunch.Size = new System.Drawing.Size(331, 21);
this.comboBoxAdditionalResourcesChooseFileToLaunch.TabIndex = 17;
this.toolTip1.SetToolTip(this.comboBoxAdditionalResourcesChooseFileToLaunch, resources.GetString("comboBoxAdditionalResourcesChooseFileToLaunch.ToolTip"));
this.comboBoxAdditionalResourcesChooseFileToLaunch.SelectedIndexChanged += new System.EventHandler(this.comboBoxAdditionalResourcesChooseFileToLaunch_SelectedIndexChanged);
//
// buttonAdditionalResourcesChooseEmbeddedFolder
//
this.buttonAdditionalResourcesChooseEmbeddedFolder.Location = new System.Drawing.Point(634, 21);
this.buttonAdditionalResourcesChooseEmbeddedFolder.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonAdditionalResourcesChooseEmbeddedFolder.Name = "buttonAdditionalResourcesChooseEmbeddedFolder";
this.buttonAdditionalResourcesChooseEmbeddedFolder.Size = new System.Drawing.Size(100, 25);
this.buttonAdditionalResourcesChooseEmbeddedFolder.TabIndex = 16;
this.buttonAdditionalResourcesChooseEmbeddedFolder.Text = "Choose Folder";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesChooseEmbeddedFolder, resources.GetString("buttonAdditionalResourcesChooseEmbeddedFolder.ToolTip"));
this.buttonAdditionalResourcesChooseEmbeddedFolder.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesChooseEmbeddedFolder.Click += new System.EventHandler(this.buttonAdditionalResourcesChooseEmbeddedFolder_Click);
//
// labelAdditionalResourceUrl
//
this.labelAdditionalResourceUrl.AutoSize = true;
this.labelAdditionalResourceUrl.Location = new System.Drawing.Point(25, 27);
this.labelAdditionalResourceUrl.Name = "labelAdditionalResourceUrl";
this.labelAdditionalResourceUrl.Size = new System.Drawing.Size(46, 13);
this.labelAdditionalResourceUrl.TabIndex = 4;
this.labelAdditionalResourceUrl.Text = "URL (U)";
//
// labelAdditionalResourcesResourceDataLaunchWith
//
this.labelAdditionalResourcesResourceDataLaunchWith.AutoSize = true;
this.labelAdditionalResourcesResourceDataLaunchWith.Location = new System.Drawing.Point(503, 99);
this.labelAdditionalResourcesResourceDataLaunchWith.Name = "labelAdditionalResourcesResourceDataLaunchWith";
this.labelAdditionalResourcesResourceDataLaunchWith.Size = new System.Drawing.Size(68, 13);
this.labelAdditionalResourcesResourceDataLaunchWith.TabIndex = 12;
this.labelAdditionalResourcesResourceDataLaunchWith.Text = "Launch with:";
//
// textBoxAdditionalResourceUrl
//
this.textBoxAdditionalResourceUrl.Location = new System.Drawing.Point(77, 25);
this.textBoxAdditionalResourceUrl.Name = "textBoxAdditionalResourceUrl";
this.textBoxAdditionalResourceUrl.Size = new System.Drawing.Size(343, 20);
this.textBoxAdditionalResourceUrl.TabIndex = 3;
this.toolTip1.SetToolTip(this.textBoxAdditionalResourceUrl, "Enter the URL of an external resource here. SEB will create a matching URL filter" +
" rule (see below) and activate URL filtering in the Network / Filter Pane.");
this.textBoxAdditionalResourceUrl.TextChanged += new System.EventHandler(this.textBoxAdditionalResourceUrl_TextChanged);
this.textBoxAdditionalResourceUrl.Leave += new System.EventHandler(this.textBoxAdditionalResourceUrl_Leave);
//
// comboBoxAdditionalResourcesResourceDataLauncher
//
this.comboBoxAdditionalResourcesResourceDataLauncher.FormattingEnabled = true;
this.comboBoxAdditionalResourcesResourceDataLauncher.Location = new System.Drawing.Point(578, 96);
this.comboBoxAdditionalResourcesResourceDataLauncher.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.comboBoxAdditionalResourcesResourceDataLauncher.Name = "comboBoxAdditionalResourcesResourceDataLauncher";
this.comboBoxAdditionalResourcesResourceDataLauncher.Size = new System.Drawing.Size(331, 21);
this.comboBoxAdditionalResourcesResourceDataLauncher.TabIndex = 11;
this.toolTip1.SetToolTip(this.comboBoxAdditionalResourcesResourceDataLauncher, resources.GetString("comboBoxAdditionalResourcesResourceDataLauncher.ToolTip"));
this.comboBoxAdditionalResourcesResourceDataLauncher.SelectedIndexChanged += new System.EventHandler(this.comboBoxAdditionalResourcesResourceDataLauncher_SelectedIndexChanged);
//
// buttonAdditionalResourceRemoveResourceData
//
this.buttonAdditionalResourceRemoveResourceData.Location = new System.Drawing.Point(644, 128);
this.buttonAdditionalResourceRemoveResourceData.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonAdditionalResourceRemoveResourceData.Name = "buttonAdditionalResourceRemoveResourceData";
this.buttonAdditionalResourceRemoveResourceData.Size = new System.Drawing.Size(56, 25);
this.buttonAdditionalResourceRemoveResourceData.TabIndex = 10;
this.buttonAdditionalResourceRemoveResourceData.Text = "Remove";
this.buttonAdditionalResourceRemoveResourceData.UseVisualStyleBackColor = true;
this.buttonAdditionalResourceRemoveResourceData.Click += new System.EventHandler(this.buttonAdditionalResourceRemoveResourceData_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(431, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(69, 26);
this.label1.TabIndex = 6;
this.label1.Text = "Embedded\r\nResource (E)";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// buttonAdditionalResourceEmbededResourceOpen
//
this.buttonAdditionalResourceEmbededResourceOpen.Location = new System.Drawing.Point(578, 128);
this.buttonAdditionalResourceEmbededResourceOpen.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonAdditionalResourceEmbededResourceOpen.Name = "buttonAdditionalResourceEmbededResourceOpen";
this.buttonAdditionalResourceEmbededResourceOpen.Size = new System.Drawing.Size(56, 25);
this.buttonAdditionalResourceEmbededResourceOpen.TabIndex = 9;
this.buttonAdditionalResourceEmbededResourceOpen.Text = "Open";
this.buttonAdditionalResourceEmbededResourceOpen.UseVisualStyleBackColor = true;
this.buttonAdditionalResourceEmbededResourceOpen.Click += new System.EventHandler(this.buttonAdditionalResourceEmbededResourceOpen_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(612, 27);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(16, 13);
this.label2.TabIndex = 7;
this.label2.Text = "or";
//
// buttonAdditionalResourceChooseEmbededResource
//
this.buttonAdditionalResourceChooseEmbededResource.Location = new System.Drawing.Point(506, 21);
this.buttonAdditionalResourceChooseEmbededResource.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonAdditionalResourceChooseEmbededResource.Name = "buttonAdditionalResourceChooseEmbededResource";
this.buttonAdditionalResourceChooseEmbededResource.Size = new System.Drawing.Size(100, 25);
this.buttonAdditionalResourceChooseEmbededResource.TabIndex = 8;
this.buttonAdditionalResourceChooseEmbededResource.Text = "Choose File";
this.toolTip1.SetToolTip(this.buttonAdditionalResourceChooseEmbededResource, "Select a single file to embed into the SEB Config File. After choosing a file, th" +
"e filename and the setting Lauch with is displayed.");
this.buttonAdditionalResourceChooseEmbededResource.UseVisualStyleBackColor = true;
this.buttonAdditionalResourceChooseEmbededResource.Click += new System.EventHandler(this.buttonAdditionalResourceChooseEmbededResource_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBoxAdditionalResourcesTitle);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.buttonAdditionalResourcesChooseIcon);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.pictureBoxAdditionalResourceIcon);
this.groupBox1.Location = new System.Drawing.Point(9, 38);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.groupBox1.Size = new System.Drawing.Size(424, 127);
this.groupBox1.TabIndex = 31;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Appearance";
//
// textBoxAdditionalResourcesTitle
//
this.textBoxAdditionalResourcesTitle.Location = new System.Drawing.Point(41, 20);
this.textBoxAdditionalResourcesTitle.Name = "textBoxAdditionalResourcesTitle";
this.textBoxAdditionalResourcesTitle.Size = new System.Drawing.Size(378, 20);
this.textBoxAdditionalResourcesTitle.TabIndex = 0;
this.toolTip1.SetToolTip(this.textBoxAdditionalResourcesTitle, resources.GetString("textBoxAdditionalResourcesTitle.ToolTip"));
this.textBoxAdditionalResourcesTitle.TextChanged += new System.EventHandler(this.textBoxAdditionalResourcesTitle_TextChanged);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(8, 22);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(27, 13);
this.label9.TabIndex = 1;
this.label9.Text = "Title";
//
// buttonAdditionalResourcesChooseIcon
//
this.buttonAdditionalResourcesChooseIcon.Location = new System.Drawing.Point(41, 43);
this.buttonAdditionalResourcesChooseIcon.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.buttonAdditionalResourcesChooseIcon.Name = "buttonAdditionalResourcesChooseIcon";
this.buttonAdditionalResourcesChooseIcon.Size = new System.Drawing.Size(100, 25);
this.buttonAdditionalResourcesChooseIcon.TabIndex = 14;
this.buttonAdditionalResourcesChooseIcon.Text = "Choose...";
this.toolTip1.SetToolTip(this.buttonAdditionalResourcesChooseIcon, resources.GetString("buttonAdditionalResourcesChooseIcon.ToolTip"));
this.buttonAdditionalResourcesChooseIcon.UseVisualStyleBackColor = true;
this.buttonAdditionalResourcesChooseIcon.Click += new System.EventHandler(this.buttonAdditionalResourcesChooseIcon_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 49);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(28, 13);
this.label4.TabIndex = 13;
this.label4.Text = "Icon";
//
// pictureBoxAdditionalResourceIcon
//
this.pictureBoxAdditionalResourceIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxAdditionalResourceIcon.Location = new System.Drawing.Point(68, 71);
this.pictureBoxAdditionalResourceIcon.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.pictureBoxAdditionalResourceIcon.Name = "pictureBoxAdditionalResourceIcon";
this.pictureBoxAdditionalResourceIcon.Size = new System.Drawing.Size(38, 41);
this.pictureBoxAdditionalResourceIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxAdditionalResourceIcon.TabIndex = 15;
this.pictureBoxAdditionalResourceIcon.TabStop = false;
//
// checkBoxAdditionalResourceActive
//
this.checkBoxAdditionalResourceActive.AutoSize = true;
this.checkBoxAdditionalResourceActive.Location = new System.Drawing.Point(16, 17);
this.checkBoxAdditionalResourceActive.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.checkBoxAdditionalResourceActive.Name = "checkBoxAdditionalResourceActive";
this.checkBoxAdditionalResourceActive.Size = new System.Drawing.Size(56, 17);
this.checkBoxAdditionalResourceActive.TabIndex = 2;
this.checkBoxAdditionalResourceActive.Text = "Active";
this.toolTip1.SetToolTip(this.checkBoxAdditionalResourceActive, "By deactivating a resource, it won\'t be displayed, also its child resources (if s" +
"ome exist) won\'t be visible. URL filter rules (see below) defined for the deacti" +
"vated resource also won\'t be active.");
this.checkBoxAdditionalResourceActive.UseVisualStyleBackColor = true;
this.checkBoxAdditionalResourceActive.CheckedChanged += new System.EventHandler(this.checkBoxAdditionalResourceActive_CheckedChanged);
//
// treeViewAdditionalResources
//
this.treeViewAdditionalResources.Location = new System.Drawing.Point(3, 3);
this.treeViewAdditionalResources.Name = "treeViewAdditionalResources";
this.treeViewAdditionalResources.Size = new System.Drawing.Size(276, 559);
this.treeViewAdditionalResources.TabIndex = 8;
this.treeViewAdditionalResources.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewAdditionalResources_AfterSelect);
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 15000;
this.toolTip1.InitialDelay = 500;
this.toolTip1.ReshowDelay = 100;
//
// AdditionalResources
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonAdditionalResourcesAddSubResource);
this.Controls.Add(this.buttonAdditionalResourcesMoveDown);
this.Controls.Add(this.buttonAdditionalResourcesMoveUp);
this.Controls.Add(this.buttonAdditionalResourcesAdd);
this.Controls.Add(this.buttonadditionalResourcesRemove);
this.Controls.Add(this.groupBoxAdditionalResourceDetails);
this.Controls.Add(this.treeViewAdditionalResources);
this.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.Name = "AdditionalResources";
this.Size = new System.Drawing.Size(1222, 599);
this.groupBoxAdditionalResourceDetails.ResumeLayout(false);
this.groupBoxAdditionalResourceDetails.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAdditionalResourceIcon)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonAdditionalResourcesAddSubResource;
private System.Windows.Forms.Button buttonAdditionalResourcesMoveDown;
private System.Windows.Forms.Button buttonAdditionalResourcesMoveUp;
private System.Windows.Forms.Button buttonAdditionalResourcesAdd;
private System.Windows.Forms.Button buttonadditionalResourcesRemove;
private System.Windows.Forms.GroupBox groupBoxAdditionalResourceDetails;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBoxAdditionalResourcesTitle;
private System.Windows.Forms.TreeView treeViewAdditionalResources;
private System.Windows.Forms.CheckBox checkBoxAdditionalResourceActive;
private System.Windows.Forms.Label labelAdditionalResourceUrl;
private System.Windows.Forms.TextBox textBoxAdditionalResourceUrl;
private System.Windows.Forms.CheckBox checkBoxAdditionalResourceAutoOpen;
private System.Windows.Forms.Button buttonAdditionalResourceChooseEmbededResource;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button buttonAdditionalResourceEmbededResourceOpen;
private System.Windows.Forms.Button buttonAdditionalResourceRemoveResourceData;
private System.Windows.Forms.Label labelAdditionalResourcesResourceDataLaunchWith;
private System.Windows.Forms.ComboBox comboBoxAdditionalResourcesResourceDataLauncher;
private System.Windows.Forms.Button buttonAdditionalResourcesChooseIcon;
private System.Windows.Forms.PictureBox pictureBoxAdditionalResourceIcon;
private System.Windows.Forms.Button buttonAdditionalResourcesChooseEmbeddedFolder;
private System.Windows.Forms.ComboBox comboBoxAdditionalResourcesChooseFileToLaunch;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label labelAdditionalResourcesFilename;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBoxLinkURL;
private System.Windows.Forms.CheckBox checkBoxShowButton;
private System.Windows.Forms.CheckBox checkBoxResetSession;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBoxRefererFilter;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox textBoxConfirmBoxText;
private System.Windows.Forms.CheckBox checkBoxConfirm;
private System.Windows.Forms.ComboBox comboBoxModifiers;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBoxKey;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox UrlFilterGroupBox;
private System.Windows.Forms.ToolTip toolTip1;
}
}

View file

@ -0,0 +1,811 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using SebWindowsConfig.Entities;
using SebWindowsConfig.Utilities;
using DictObj = System.Collections.Generic.Dictionary<string, object>;
using ListObj = System.Collections.Generic.List<object>;
namespace SebWindowsConfig.Controls
{
public partial class AdditionalResources : UserControl
{
private IFileCompressor _fileCompressor;
private SEBURLFilter urlFilter;
public AdditionalResources()
{
InitializeComponent();
_fileCompressor = new FileCompressor();
groupBoxAdditionalResourceDetails.Visible = false;
SEBSettings.additionalResourcesList = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyAdditionalResources];
textBoxAdditionalResourcesTitle.Text = "";
treeViewAdditionalResources.Nodes.Clear();
foreach (DictObj l0Resource in SEBSettings.additionalResourcesList)
{
var l0Node = treeViewAdditionalResources.Nodes.Add(l0Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l0Resource));
foreach (DictObj l1Resource in (ListObj)l0Resource[SEBSettings.KeyAdditionalResources])
{
var l1Node = l0Node.Nodes.Add(l1Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l1Resource));
foreach (DictObj l2Resource in (ListObj)l1Resource[SEBSettings.KeyAdditionalResources])
{
l1Node.Nodes.Add(l2Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l2Resource));
}
}
}
urlFilter = new SEBURLFilter();
}
private string GetDisplayTitle(DictObj resource)
{
return string.Concat(
resource[SEBSettings.KeyAdditionalResourcesTitle],
(bool) resource[SEBSettings.KeyAdditionalResourcesActive] ? "" : " (inactive)",
(bool) resource[SEBSettings.KeyAdditionalResourcesAutoOpen] ? " (A)" : "",
resource.ContainsKey(SEBSettings.KeyAdditionalResourcesShowButton) ? (bool) resource[SEBSettings.KeyAdditionalResourcesShowButton] ? " (B)" : "" : "",
!string.IsNullOrEmpty((string)resource[SEBSettings.KeyAdditionalResourcesResourceData]) ? " (E)" : "",
!string.IsNullOrEmpty((string)resource[SEBSettings.KeyAdditionalResourcesUrl]) ? " (U)" : "");
}
private void buttonAdditionalResourcesAdd_Click(object sender, EventArgs e)
{
// Get the process list
SEBSettings.additionalResourcesList = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyAdditionalResources];
int newIndex = treeViewAdditionalResources.Nodes.Count;
SEBSettings.additionalResourcesList.Insert(newIndex, CreateNewResource(newIndex.ToString()));
treeViewAdditionalResources.SelectedNode = treeViewAdditionalResources.Nodes.Add(newIndex.ToString(), "New Resource");
treeViewAdditionalResources.Focus();
}
private DictObj CreateNewResource(string identifier)
{
DictObj resourceData = new DictObj();
resourceData[SEBSettings.KeyAdditionalResourcesIdentifier] = identifier;
return SetDefaultValuesOnResource(resourceData);
}
private void buttonAdditionalResourcesAddSubResource_Click(object sender, EventArgs e)
{
var node = treeViewAdditionalResources.SelectedNode;
if (node == null)
{
MessageBox.Show("No node selected");
return;
}
if (node.Level == 2)
{
MessageBox.Show("Maximum 3 levels");
return;
}
var selectedResource = GetSelectedResource();
ListObj resourceList = (ListObj)selectedResource[SEBSettings.KeyAdditionalResources];
var newIndex = node.Nodes.Count;
if (node.Level == 0)
{
resourceList.Add(CreateNewResource(node.Index + "." + newIndex));
treeViewAdditionalResources.SelectedNode = treeViewAdditionalResources.SelectedNode.Nodes.Add(node.Index + "." + newIndex, "New Resource");
}
if (node.Level == 1)
{
resourceList.Add(CreateNewResource(node.Parent.Index + "." + node.Index + "." + newIndex));
treeViewAdditionalResources.SelectedNode = treeViewAdditionalResources.SelectedNode.Nodes.Add(node.Parent.Index + "." + node.Index + "." + newIndex, "New Resource");
}
treeViewAdditionalResources.Focus();
}
private void treeViewAdditionalResources_AfterSelect(object sender, TreeViewEventArgs e)
{
DictObj selectedResource = GetSelectedResource();
if (selectedResource != null)
{
textBoxAdditionalResourcesTitle.Text = (string)selectedResource[SEBSettings.KeyAdditionalResourcesTitle];
checkBoxAdditionalResourceActive.Checked = (bool)selectedResource[SEBSettings.KeyAdditionalResourcesActive];
textBoxAdditionalResourceUrl.Text = (string)selectedResource[SEBSettings.KeyAdditionalResourcesUrl];
checkBoxAdditionalResourceAutoOpen.Checked = (bool)selectedResource[SEBSettings.KeyAdditionalResourcesAutoOpen];
textBoxLinkURL.Text = (string)selectedResource[SEBSettings.KeyAdditionalResourcesLinkUrl];
textBoxRefererFilter.Text = (string) selectedResource[SEBSettings.KeyAdditionalResourcesRefererFilter];
checkBoxResetSession.Checked = (bool) selectedResource[SEBSettings.KeyAdditionalResourcesResetSession];
textBoxKey.Text = (string) selectedResource[SEBSettings.KeyAdditionalResourcesKey];
checkBoxConfirm.Checked = (bool)selectedResource[SEBSettings.KeyAdditionalResourcesConfirm];
textBoxConfirmBoxText.Text = (string) selectedResource[SEBSettings.KeyAdditionalResourcesConfirmText];
checkBoxShowButton.Checked = (bool) selectedResource[SEBSettings.KeyAdditionalResourcesShowButton];
comboBoxModifiers.SelectedItem = string.IsNullOrEmpty((string) selectedResource[SEBSettings.KeyAdditionalResourcesModifiers]) ? null : (string)selectedResource[SEBSettings.KeyAdditionalResourcesModifiers];
InitializeUrlFilters(selectedResource);
if (!string.IsNullOrEmpty((string)selectedResource[SEBSettings.KeyAdditionalResourcesResourceData]))
{
buttonAdditionalResourceRemoveResourceData.Visible = true;
buttonAdditionalResourceEmbededResourceOpen.Visible = true;
labelAdditionalResourcesResourceDataLaunchWith.Visible = true;
labelAdditionalResourcesFilename.Visible = true;
comboBoxAdditionalResourcesResourceDataLauncher.Visible = true;
textBoxAdditionalResourceUrl.Enabled = false;
comboBoxAdditionalResourcesChooseFileToLaunch.Visible = true;
comboBoxAdditionalResourcesChooseFileToLaunch.Enabled = false;
var indexBefore = (int) selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataLauncher];
comboBoxAdditionalResourcesResourceDataLauncher.DataSource = GetLaunchers();
comboBoxAdditionalResourcesResourceDataLauncher.SelectedIndex = indexBefore;
comboBoxAdditionalResourcesChooseFileToLaunch.Text =
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataFilename].ToString();
}
else
{
buttonAdditionalResourceRemoveResourceData.Visible = false;
buttonAdditionalResourceEmbededResourceOpen.Visible = false;
labelAdditionalResourcesResourceDataLaunchWith.Visible = false;
labelAdditionalResourcesFilename.Visible = false;
comboBoxAdditionalResourcesResourceDataLauncher.Visible = false;
textBoxAdditionalResourceUrl.Enabled = true;
comboBoxAdditionalResourcesChooseFileToLaunch.Visible = false;
}
if (!string.IsNullOrEmpty((string) selectedResource[SEBSettings.KeyAdditionalResourcesUrl]))
{
buttonAdditionalResourceChooseEmbededResource.Enabled = false;
}
else
{
buttonAdditionalResourceChooseEmbededResource.Enabled = true;
}
if (((ListObj) selectedResource[SEBSettings.KeyAdditionalResourcesResourceIcons]).Count > 0)
{
var icon =
(DictObj) ((ListObj) selectedResource[SEBSettings.KeyAdditionalResourcesResourceIcons])[0];
var memoryStream =
_fileCompressor.DeCompressAndDecode(
(string) icon[SEBSettings.KeyAdditionalResourcesResourceIconsIconData]);
var image = Image.FromStream(memoryStream);
pictureBoxAdditionalResourceIcon.Image = image;
}
else
{
pictureBoxAdditionalResourceIcon.Image = null;
}
}
groupBoxAdditionalResourceDetails.Visible = selectedResource != null;
}
public void InitializeUrlFilters(DictObj resourceConfig)
{
var filterControl = new FilterRuleControl();
if (resourceConfig.ContainsKey(SEBSettings.KeyURLFilterRules))
{
foreach (DictObj config in resourceConfig[SEBSettings.KeyURLFilterRules] as ListObj)
{
var rule = FilterRule.FromConfig(config);
filterControl.AddRule(rule);
}
}
filterControl.Dock = DockStyle.Fill;
filterControl.DataChanged += (rules) =>
{
var configs = new ListObj();
foreach (var rule in rules)
{
var config = FilterRule.ToConfig(rule);
configs.Add(config);
}
resourceConfig[SEBSettings.KeyURLFilterRules] = configs;
};
UrlFilterGroupBox.Controls.Clear();
UrlFilterGroupBox.Controls.Add(filterControl);
}
private List<string> GetLaunchers()
{
var res = new List<string>();
foreach (DictObj permittedProcess in SEBSettings.permittedProcessList)
{
res.Add((string)permittedProcess[SEBSettings.KeyTitle]);
}
return res;
}
private DictObj GetSelectedResource()
{
var node = treeViewAdditionalResources.SelectedNode;
if (node.Level == 0)
{
return SetDefaultValuesOnResource((DictObj)SEBSettings.additionalResourcesList[node.Index]);
}
else if (node.Level == 1)
{
DictObj rootResource = (DictObj)SEBSettings.additionalResourcesList[node.Parent.Index];
ListObj level1List = (ListObj)rootResource[SEBSettings.KeyAdditionalResources];
return SetDefaultValuesOnResource((DictObj)level1List[node.Index]);
}
else if (node.Level == 2)
{
DictObj rootResource = (DictObj)SEBSettings.additionalResourcesList[treeViewAdditionalResources.SelectedNode.Parent.Parent.Index];
ListObj level1List = (ListObj)rootResource[SEBSettings.KeyAdditionalResources];
DictObj level1Resource = (DictObj)level1List[treeViewAdditionalResources.SelectedNode.Parent.Index];
ListObj level2List = (ListObj)level1Resource[SEBSettings.KeyAdditionalResources];
return SetDefaultValuesOnResource((DictObj)level2List[node.Index]);
}
return null;
}
private DictObj SetDefaultValuesOnResource(DictObj resourceData)
{
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResources))
resourceData[SEBSettings.KeyAdditionalResources] = new ListObj();
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesActive))
resourceData[SEBSettings.KeyAdditionalResourcesActive] = true;
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesAutoOpen))
resourceData[SEBSettings.KeyAdditionalResourcesAutoOpen] = false;
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesIdentifier))
resourceData[SEBSettings.KeyAdditionalResourcesIdentifier] = "";
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesResourceIcons))
resourceData[SEBSettings.KeyAdditionalResourcesResourceIcons] = new ListObj();
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesTitle))
resourceData[SEBSettings.KeyAdditionalResourcesTitle] = "New Resource";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesUrl))
resourceData[SEBSettings.KeyAdditionalResourcesUrl] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesURLFilterRules))
resourceData[SEBSettings.KeyAdditionalResourcesURLFilterRules] = new ListObj();
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesResourceData))
resourceData[SEBSettings.KeyAdditionalResourcesResourceData] = "";
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesResourceDataFilename))
resourceData[SEBSettings.KeyAdditionalResourcesResourceDataFilename] = "";
if(!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesResourceDataLauncher))
resourceData[SEBSettings.KeyAdditionalResourcesResourceDataLauncher] = 0;
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesLinkUrl))
resourceData[SEBSettings.KeyAdditionalResourcesLinkUrl] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesRefererFilter))
resourceData[SEBSettings.KeyAdditionalResourcesRefererFilter] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesResetSession))
resourceData[SEBSettings.KeyAdditionalResourcesResetSession] = false;
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesKey))
resourceData[SEBSettings.KeyAdditionalResourcesKey] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesModifiers))
resourceData[SEBSettings.KeyAdditionalResourcesModifiers] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesConfirm))
resourceData[SEBSettings.KeyAdditionalResourcesConfirm] = false;
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesConfirmText))
resourceData[SEBSettings.KeyAdditionalResourcesConfirmText] = "";
if (!resourceData.ContainsKey(SEBSettings.KeyAdditionalResourcesShowButton))
resourceData[SEBSettings.KeyAdditionalResourcesShowButton] = true;
return resourceData;
}
private void UpdateAdditionalResourceIdentifiers()
{
foreach (TreeNode l0Node in treeViewAdditionalResources.Nodes)
{
DictObj l0resource = (DictObj)SEBSettings.additionalResourcesList[l0Node.Index];
l0resource[SEBSettings.KeyAdditionalResourcesIdentifier] = l0Node.Index.ToString();
foreach (TreeNode l1Node in l0Node.Nodes)
{
ListObj l1resources = (ListObj)l0resource[SEBSettings.KeyAdditionalResources];
DictObj l1resource = (DictObj) l1resources[l1Node.Index];
l1resource[SEBSettings.KeyAdditionalResourcesIdentifier] = l0Node.Index + "." + l1Node.Index;
foreach (TreeNode l2Node in l1Node.Nodes)
{
ListObj l2resources = (ListObj)l1resource[SEBSettings.KeyAdditionalResources];
DictObj l2resource = (DictObj)l2resources[l2Node.Index];
l2resource[SEBSettings.KeyAdditionalResourcesIdentifier] = l0Node.Index + "." + l1Node.Index + "." + l2Node.Index;
}
}
}
}
private void buttonAdditionalResourcesMoveUp_Click(object sender, EventArgs e)
{
var nodeToMove = treeViewAdditionalResources.SelectedNode;
if (nodeToMove.Index == 0)
return;
var oldIndex = nodeToMove.Index;
var parent = treeViewAdditionalResources.SelectedNode.Parent;
if (parent == null)
{
var nodeToMoveDown = treeViewAdditionalResources.Nodes[oldIndex - 1];
treeViewAdditionalResources.Nodes.RemoveAt(oldIndex - 1);
treeViewAdditionalResources.Nodes.Insert(oldIndex, nodeToMoveDown);
DictObj resourceToMoveDown = (DictObj)SEBSettings.additionalResourcesList[oldIndex - 1];
SEBSettings.additionalResourcesList.RemoveAt(oldIndex -1);
SEBSettings.additionalResourcesList.Insert(oldIndex, resourceToMoveDown);
}
else
{
var nodeToMoveDown = parent.Nodes[oldIndex - 1];
parent.Nodes.RemoveAt(oldIndex - 1);
parent.Nodes.Insert(oldIndex, nodeToMoveDown);
DictObj parentResource = new DictObj();
if (parent.Level == 0)
{
parentResource = (DictObj)SEBSettings.additionalResourcesList[parent.Index];
}
if (parent.Level == 1)
{
DictObj l0Resource = (DictObj)SEBSettings.additionalResourcesList[parent.Parent.Index];
ListObj l0ResourcesList = (ListObj)l0Resource[SEBSettings.KeyAdditionalResources];
parentResource = (DictObj)l0ResourcesList[parent.Index];
}
ListObj parentResourceList = (ListObj) parentResource[SEBSettings.KeyAdditionalResources];
DictObj resourceToMoveDown = (DictObj)parentResourceList[oldIndex - 1];
parentResourceList.RemoveAt(oldIndex -1);
parentResourceList.Insert(oldIndex, resourceToMoveDown);
}
UpdateAdditionalResourceIdentifiers();
}
private void buttonAdditionalResourcesMoveDown_Click(object sender, EventArgs e)
{
var nodeToMove = treeViewAdditionalResources.SelectedNode;
var oldIndex = nodeToMove.Index;
var parent = treeViewAdditionalResources.SelectedNode.Parent;
if (parent == null)
{
if (nodeToMove.Index == treeViewAdditionalResources.Nodes.Count -1)
return;
var nodeToMoveUp = treeViewAdditionalResources.Nodes[oldIndex + 1];
treeViewAdditionalResources.Nodes.RemoveAt(oldIndex + 1);
treeViewAdditionalResources.Nodes.Insert(oldIndex, nodeToMoveUp);
DictObj resourceToMoveUp = (DictObj) SEBSettings.additionalResourcesList[oldIndex + 1];
SEBSettings.additionalResourcesList.RemoveAt(oldIndex + 1);
SEBSettings.additionalResourcesList.Insert(oldIndex, resourceToMoveUp);
}
else
{
if (nodeToMove.Index == parent.Nodes.Count -1 )
return;
var nodeToMoveUp = parent.Nodes[nodeToMove.Index + 1];
parent.Nodes.RemoveAt(nodeToMove.Index + 1);
parent.Nodes.Insert(oldIndex, nodeToMoveUp);
DictObj parentResource = new DictObj();
if (parent.Level == 0)
{
parentResource = (DictObj)SEBSettings.additionalResourcesList[parent.Index];
}
if (parent.Level == 1)
{
DictObj l0Resource = (DictObj)SEBSettings.additionalResourcesList[parent.Parent.Index];
ListObj l0ResourcesList = (ListObj)l0Resource[SEBSettings.KeyAdditionalResources];
parentResource = (DictObj)l0ResourcesList[parent.Index];
}
ListObj parentResourceList = (ListObj)parentResource[SEBSettings.KeyAdditionalResources];
DictObj resourceToMoveDown = (DictObj)parentResourceList[oldIndex + 1];
parentResourceList.RemoveAt(oldIndex + 1);
parentResourceList.Insert(oldIndex, resourceToMoveDown);
}
UpdateAdditionalResourceIdentifiers();
}
private void buttonadditionalResourcesRemove_Click(object sender, EventArgs e)
{
var node = treeViewAdditionalResources.SelectedNode;
if (node != null)
{
if (node.Level == 0)
{
SEBSettings.additionalResourcesList.RemoveAt(node.Index);
}
else if (node.Level == 1)
{
DictObj rootResource = (DictObj)SEBSettings.additionalResourcesList[node.Parent.Index];
ListObj level1List = (ListObj)rootResource[SEBSettings.KeyAdditionalResources];
level1List.RemoveAt(node.Index);
}
else if (node.Level == 2)
{
DictObj rootResource = (DictObj)SEBSettings.additionalResourcesList[treeViewAdditionalResources.SelectedNode.Parent.Parent.Index];
ListObj level1List = (ListObj)rootResource[SEBSettings.KeyAdditionalResources];
DictObj level1Resource = (DictObj)level1List[treeViewAdditionalResources.SelectedNode.Parent.Index];
ListObj level2List = (ListObj)level1Resource[SEBSettings.KeyAdditionalResources];
level2List.RemoveAt(node.Index);
}
node.Remove();
UpdateAdditionalResourceIdentifiers();
}
groupBoxAdditionalResourceDetails.Visible = treeViewAdditionalResources.SelectedNode != null;
}
private void checkBoxAdditionalResourceActive_CheckedChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesActive] = checkBoxAdditionalResourceActive.Checked;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
}
private void checkBoxAdditionalResourceAutoOpen_CheckedChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesAutoOpen] = checkBoxAdditionalResourceAutoOpen.Checked;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
}
private void textBoxAdditionalResourcesTitle_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesTitle] = textBoxAdditionalResourcesTitle.Text;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
}
private void textBoxAdditionalResourceUrl_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesUrl] = textBoxAdditionalResourceUrl.Text;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
buttonAdditionalResourcesChooseEmbeddedFolder.Enabled =
buttonAdditionalResourceChooseEmbededResource.Enabled = string.IsNullOrEmpty(textBoxAdditionalResourceUrl.Text);
}
private void buttonAdditionalResourceChooseEmbededResource_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog
{
CheckFileExists = true,
CheckPathExists = true,
Multiselect = false
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
var fileInfo = new FileInfo(openFileDialog.FileName);
var resourceData = _fileCompressor.CompressAndEncodeFile(openFileDialog.FileName);
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataFilename] = fileInfo.Name;
selectedResource[SEBSettings.KeyAdditionalResourcesResourceData] = resourceData;
comboBoxAdditionalResourcesChooseFileToLaunch.Visible = true;
comboBoxAdditionalResourcesChooseFileToLaunch.Enabled = false;
comboBoxAdditionalResourcesChooseFileToLaunch.Text = fileInfo.Name;
SetIconFromFile(openFileDialog.FileName);
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
EmbeddedResourceChosen();
}
catch (OutOfMemoryException)
{
MessageBox.Show("The chosen resource file is too large!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonAdditionalResourcesChooseEmbeddedFolder_Click(object sender, EventArgs e)
{
var chooseFolderDialog = new FolderBrowserDialog
{
ShowNewFolderButton = false,
Description = "Choose a folder to embed, including subdirectories. Afterwards you can select the file to start when the resource is selected"
};
if (chooseFolderDialog.ShowDialog() == DialogResult.OK)
{
try
{
var resourceData = _fileCompressor.CompressAndEncodeDirectory(chooseFolderDialog.SelectedPath, out List<string> containingFilenames);
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesResourceData] = resourceData;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
comboBoxAdditionalResourcesChooseFileToLaunch.DataSource = containingFilenames;
comboBoxAdditionalResourcesChooseFileToLaunch.Visible = true;
comboBoxAdditionalResourcesChooseFileToLaunch.Enabled = true;
EmbeddedResourceChosen();
}
catch (OutOfMemoryException)
{
MessageBox.Show("The chosen resource folder is too large!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void SetIconFromUrl(string url)
{
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
return;
try
{
var uri = new Uri(textBoxAdditionalResourceUrl.Text);
DictObj selectedResource = GetSelectedResource();
var ic = new DictObj();
ic[SEBSettings.KeyAdditionalResourcesResourceIconsIconData] =
_fileCompressor.CompressAndEncodeFavicon(uri);
ic[SEBSettings.KeyAdditionalResourcesResourceIconsFormat] = "png";
var icons = (ListObj)selectedResource[SEBSettings.KeyAdditionalResourcesResourceIcons];
if (icons.Count > 0)
{
icons[0] = ic;
}
else
{
icons.Add(ic);
}
var memoryStream = _fileCompressor.DeCompressAndDecode((string)ic[SEBSettings.KeyAdditionalResourcesResourceIconsIconData]);
var image = Image.FromStream(memoryStream);
pictureBoxAdditionalResourceIcon.Image = image;
}
catch (Exception ex)
{
Logger.AddError(string.Format("Unable to extract Icon of Url {0}", url), this, ex);
}
}
private void comboBoxAdditionalResourcesChooseFileToLaunch_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBoxAdditionalResourcesChooseFileToLaunch.SelectedItem != null)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataFilename] = comboBoxAdditionalResourcesChooseFileToLaunch.SelectedItem;
}
}
private void SetIconFromFile(string filename)
{
if (!File.Exists(filename))
return;
try
{
var icon = Icon.ExtractAssociatedIcon(filename);
if (icon != null)
{
DictObj selectedResource = GetSelectedResource();
var ic = new DictObj();
ic[SEBSettings.KeyAdditionalResourcesResourceIconsIconData] =
_fileCompressor.CompressAndEncodeIcon(icon);
ic[SEBSettings.KeyAdditionalResourcesResourceIconsFormat] = "png";
var icons = (ListObj)selectedResource[SEBSettings.KeyAdditionalResourcesResourceIcons];
if (icons.Count > 0)
{
icons[0] = ic;
}
else
{
icons.Add(ic);
}
var memoryStream = _fileCompressor.DeCompressAndDecode((string)ic[SEBSettings.KeyAdditionalResourcesResourceIconsIconData]);
var image = Image.FromStream(memoryStream);
pictureBoxAdditionalResourceIcon.Image = image;
}
}
catch (Exception ex)
{
Logger.AddError(string.Format("Unable to extract Icon of File {0}",filename),this,ex);
}
}
private void EmbeddedResourceChosen()
{
buttonAdditionalResourceRemoveResourceData.Visible = true;
buttonAdditionalResourceEmbededResourceOpen.Visible = true;
labelAdditionalResourcesResourceDataLaunchWith.Visible = true;
labelAdditionalResourcesFilename.Visible = true;
comboBoxAdditionalResourcesResourceDataLauncher.Visible = true;
textBoxAdditionalResourceUrl.Text = "";
textBoxAdditionalResourceUrl.Enabled = false;
comboBoxAdditionalResourcesResourceDataLauncher.DataSource = GetLaunchers();
}
private void buttonAdditionalResourceEmbededResourceOpen_Click(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
var filename = (string) selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataFilename];
var path =
_fileCompressor.DecompressDecodeAndSaveFile(
(string)selectedResource[SEBSettings.KeyAdditionalResourcesResourceData], filename, selectedResource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString());
Process.Start(path + filename);
}
private void buttonAdditionalResourceRemoveResourceData_Click(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesResourceData] = "";
selectedResource[SEBSettings.KeyAdditionalResourcesResourceIconsIconData] = "";
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataFilename] = "";
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataLauncher] = 0;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
buttonAdditionalResourceRemoveResourceData.Visible = false;
buttonAdditionalResourceEmbededResourceOpen.Visible = false;
labelAdditionalResourcesResourceDataLaunchWith.Visible = false;
labelAdditionalResourcesFilename.Visible = false;
comboBoxAdditionalResourcesResourceDataLauncher.Visible = false;
comboBoxAdditionalResourcesChooseFileToLaunch.Visible = false;
pictureBoxAdditionalResourceIcon.Image = null;
textBoxAdditionalResourceUrl.Enabled = true;
}
private void comboBoxAdditionalResourcesResourceDataLauncher_SelectedIndexChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
if ((int) selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataLauncher] !=
comboBoxAdditionalResourcesResourceDataLauncher.SelectedIndex)
{
selectedResource[SEBSettings.KeyAdditionalResourcesResourceDataLauncher] =
comboBoxAdditionalResourcesResourceDataLauncher.SelectedIndex;
}
}
private void buttonAdditionalResourcesChooseIcon_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog
{
CheckFileExists = true,
CheckPathExists = true,
Multiselect = false,
Filter = "PNG Images|*.png"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
DictObj selectedResource = GetSelectedResource();
var icon = new DictObj();
icon[SEBSettings.KeyAdditionalResourcesResourceIconsIconData] =
_fileCompressor.CompressAndEncodeFile(openFileDialog.FileName);
icon[SEBSettings.KeyAdditionalResourcesResourceIconsFormat] = "png";
var icons = (ListObj)selectedResource[SEBSettings.KeyAdditionalResourcesResourceIcons];
if (icons.Count > 0)
{
icons[0] = icon;
}
else
{
icons.Add(icon);
}
var memoryStream = _fileCompressor.DeCompressAndDecode((string)icon[SEBSettings.KeyAdditionalResourcesResourceIconsIconData]);
var image = Image.FromStream(memoryStream);
pictureBoxAdditionalResourceIcon.Image = image;
}
}
private void textBoxAdditionalResourceUrl_Leave(object sender, EventArgs e)
{
SetIconFromUrl(textBoxAdditionalResourceUrl.Text);
CreateURLFilterRule(textBoxAdditionalResourceUrl.Text);
// Make sure URL filter is enabled and show message box if not
if ((Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterEnable] == false)
{
SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterEnable] = true;
MessageBox.Show("URL Filter Enabled", "When adding an external additional resource, an according URL filter must be defined " +
"and URL filtering enabled. You can edit the filter(s) for the resource in its URL Filter list. " +
"You may also have to create filter rules for your exam in Network/Filter settings (SEB internally only creates a rule exactly matching the Start URL). " +
"For full control of displayed content, 'Filter also embedded content' (Network/Filter tab) should be activated as well.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void CreateURLFilterRule(string resourceURLString)
{
urlFilter.UpdateFilterRules();
// Check if resource URL gets allowed by current filter rules and if not, add a rule for the resource URL
if (Uri.TryCreate(resourceURLString, UriKind.Absolute, out Uri resourceURL))
{
if (urlFilter.TestURLAllowed(resourceURL) != URLFilterRuleActions.allow)
{
// If resource URL is not allowed: Create one using the full resource URL
DictObj selectedResource = GetSelectedResource();
ListObj resourceURLFilterRules;
if (selectedResource.TryGetValue(SEBSettings.KeyURLFilterRules, out object keyURLFilterRulesValue))
{
resourceURLFilterRules = (ListObj)keyURLFilterRulesValue;
} else
{
resourceURLFilterRules = new ListObj();
}
DictObj newURLFilterRule = new DictObj();
newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleAction, (int)URLFilterRuleActions.allow);
newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleActive, true);
newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleExpression, resourceURLString);
newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleRegex, false);
// Add this resource URL allow rule to the URL filters of this additional resource
resourceURLFilterRules.Add(newURLFilterRule);
selectedResource[SEBSettings.KeyURLFilterRules] = resourceURLFilterRules;
// Update UI
InitializeUrlFilters(selectedResource);
}
}
}
private void checkBoxShowButton_CheckedChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesShowButton] = checkBoxShowButton.Checked;
treeViewAdditionalResources.SelectedNode.Text = GetDisplayTitle(selectedResource);
}
private void textBoxLinkURL_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesLinkUrl] = textBoxLinkURL.Text;
}
private void checkBoxResetSession_CheckedChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesResetSession] = checkBoxResetSession.Checked;
}
private void textBoxRefererFilter_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesRefererFilter] = textBoxRefererFilter.Text;
}
private void textBoxKey_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesKey] = textBoxKey.Text;
}
private void comboBoxModifiers_SelectedIndexChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesModifiers] = comboBoxModifiers.SelectedItem;
}
private void checkBoxConfirm_CheckedChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesConfirm] = checkBoxConfirm.Checked;
}
private void textBoxConfirmBoxText_TextChanged(object sender, EventArgs e)
{
DictObj selectedResource = GetSelectedResource();
selectedResource[SEBSettings.KeyAdditionalResourcesConfirmText] = textBoxConfirmBoxText.Text;
}
}
}

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="comboBoxAdditionalResourcesChooseFileToLaunch.ToolTip" xml:space="preserve">
<value>Lists all files in the embedded folder (and its subfolders), you have to select one (for example an index.html file) which then is loaded by SEB or the permitted third party application selected in the Lauch with popup list.</value>
</data>
<data name="buttonAdditionalResourcesChooseEmbeddedFolder.ToolTip" xml:space="preserve">
<value>Select a folder to be embedded into the SEB Config File. After choosing a folder, a setting called Filename/File to launch and the setting Lauch with is displayed. In the File to launch popup list, all files in the embedded folder (and its subfolders) are listed, you have to select one which is opened first.</value>
</data>
<data name="comboBoxAdditionalResourcesResourceDataLauncher.ToolTip" xml:space="preserve">
<value>Select SEB (the internal SEB browser will be used to display the resource, this has to have a document type which can be displayed by the browser) or one of the permitted third party applications if there are some defined in the Permitted Processes Pane.</value>
</data>
<data name="textBoxAdditionalResourcesTitle.ToolTip" xml:space="preserve">
<value>Will be displayed either as a tool tip when hovering over the additional resource icon in the SEB task bar or as a menu entry in the additional resource popup menu if the resource is placed on the second or third hierarchy level.</value>
</data>
<data name="buttonAdditionalResourcesChooseIcon.ToolTip" xml:space="preserve">
<value>Select a image file used as an icon for the resource. If you define an external resource using its URL (see section Behavior), then the SEB Config Tool tries to load the Favicon of the website at that URL and uses it as the icon for the resource.</value>
</data>
</root>

View file

@ -0,0 +1,174 @@
namespace SebWindowsConfig.Controls
{
partial class FilterRuleControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.SplitContainer = new System.Windows.Forms.SplitContainer();
this.RuleDataGridView = new System.Windows.Forms.DataGridView();
this.ActiveColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.RegexColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.ExpressionColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ActionColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.RemoveButton = new System.Windows.Forms.Button();
this.AddButton = new System.Windows.Forms.Button();
this.ToolTip = new System.Windows.Forms.ToolTip(this.components);
((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
this.SplitContainer.Panel1.SuspendLayout();
this.SplitContainer.Panel2.SuspendLayout();
this.SplitContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RuleDataGridView)).BeginInit();
this.SuspendLayout();
//
// SplitContainer
//
this.SplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.SplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.SplitContainer.IsSplitterFixed = true;
this.SplitContainer.Location = new System.Drawing.Point(0, 0);
this.SplitContainer.Name = "SplitContainer";
this.SplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// SplitContainer.Panel1
//
this.SplitContainer.Panel1.Controls.Add(this.RuleDataGridView);
//
// SplitContainer.Panel2
//
this.SplitContainer.Panel2.Controls.Add(this.RemoveButton);
this.SplitContainer.Panel2.Controls.Add(this.AddButton);
this.SplitContainer.Panel2MinSize = 50;
this.SplitContainer.Size = new System.Drawing.Size(940, 671);
this.SplitContainer.SplitterDistance = 617;
this.SplitContainer.TabIndex = 0;
//
// RuleDataGridView
//
this.RuleDataGridView.AllowUserToAddRows = false;
this.RuleDataGridView.AllowUserToResizeRows = false;
this.RuleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.RuleDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ActiveColumn,
this.RegexColumn,
this.ExpressionColumn,
this.ActionColumn});
this.RuleDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.RuleDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.RuleDataGridView.Location = new System.Drawing.Point(0, 0);
this.RuleDataGridView.Name = "RuleDataGridView";
this.RuleDataGridView.Size = new System.Drawing.Size(940, 617);
this.RuleDataGridView.TabIndex = 0;
this.RuleDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.RuleDataGridView_CellContentClick);
this.RuleDataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.RuleDataGridView_CellValueChanged);
this.RuleDataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.RuleDataGridView_CurrentCellDirtyStateChanged);
this.RuleDataGridView.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.RuleDataGridView_RowsAdded);
this.RuleDataGridView.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.RuleDataGridView_RowsRemoved);
this.RuleDataGridView.RowValidating += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.RuleDataGridView_RowValidating);
//
// ActiveColumn
//
this.ActiveColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.ActiveColumn.HeaderText = "Active";
this.ActiveColumn.Name = "ActiveColumn";
this.ActiveColumn.Width = 58;
//
// RegexColumn
//
this.RegexColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.RegexColumn.HeaderText = "Regex";
this.RegexColumn.Name = "RegexColumn";
this.RegexColumn.Width = 61;
//
// ExpressionColumn
//
this.ExpressionColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ExpressionColumn.FillWeight = 80F;
this.ExpressionColumn.HeaderText = "Expression";
this.ExpressionColumn.Name = "ExpressionColumn";
//
// ActionColumn
//
this.ActionColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ActionColumn.FillWeight = 20F;
this.ActionColumn.HeaderText = "Action";
this.ActionColumn.Items.AddRange(new object[] {
"Allow",
"Block"});
this.ActionColumn.Name = "ActionColumn";
//
// RemoveButton
//
this.RemoveButton.Location = new System.Drawing.Point(57, 3);
this.RemoveButton.Name = "RemoveButton";
this.RemoveButton.Size = new System.Drawing.Size(48, 45);
this.RemoveButton.TabIndex = 1;
this.RemoveButton.Text = "-";
this.ToolTip.SetToolTip(this.RemoveButton, "Removes all selected rules");
this.RemoveButton.UseVisualStyleBackColor = true;
this.RemoveButton.Click += new System.EventHandler(this.RemoveButton_Click);
//
// AddButton
//
this.AddButton.Location = new System.Drawing.Point(3, 3);
this.AddButton.Name = "AddButton";
this.AddButton.Size = new System.Drawing.Size(48, 44);
this.AddButton.TabIndex = 0;
this.AddButton.Text = "+";
this.ToolTip.SetToolTip(this.AddButton, "Adds a new rule");
this.AddButton.UseVisualStyleBackColor = true;
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
//
// FilterRuleControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.SplitContainer);
this.Name = "FilterRuleControl";
this.Size = new System.Drawing.Size(940, 671);
this.SplitContainer.Panel1.ResumeLayout(false);
this.SplitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).EndInit();
this.SplitContainer.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.RuleDataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer SplitContainer;
private System.Windows.Forms.DataGridView RuleDataGridView;
private System.Windows.Forms.DataGridViewCheckBoxColumn ActiveColumn;
private System.Windows.Forms.DataGridViewCheckBoxColumn RegexColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn ExpressionColumn;
private System.Windows.Forms.DataGridViewComboBoxColumn ActionColumn;
private System.Windows.Forms.Button RemoveButton;
private System.Windows.Forms.ToolTip ToolTip;
private System.Windows.Forms.Button AddButton;
}
}

View file

@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using SebWindowsConfig.Entities;
using SebWindowsConfig.Utilities;
namespace SebWindowsConfig.Controls
{
public partial class FilterRuleControl : UserControl
{
public FilterRuleControl()
{
InitializeComponent();
}
internal delegate void DataChangedHandler(IEnumerable<FilterRule> rules);
internal event DataChangedHandler DataChanged;
internal void AddRule(FilterRule rule)
{
RuleDataGridView.Rows.Add(rule.IsActive, rule.IsRegex, rule.Expression, rule.Action.ToString());
}
internal IEnumerable<FilterRule> GetRules()
{
foreach (DataGridViewRow row in RuleDataGridView.Rows)
{
var isValid = true;
isValid &= row.Cells[ActiveColumn.Index].Value != null;
isValid &= row.Cells[RegexColumn.Index].Value != null;
isValid &= row.Cells[ActionColumn.Index].Value != null;
if (row.Cells[RegexColumn.Index].Value as bool? == true)
{
isValid &= IsValidRegexRule(row.Cells[ExpressionColumn.Index].Value as string);
}
else
{
isValid &= IsValidUrlRule(row.Cells[ExpressionColumn.Index].Value as string);
}
if (isValid)
{
yield return new FilterRule
{
IsActive = (bool) row.Cells[ActiveColumn.Index].Value,
IsRegex = (bool) row.Cells[RegexColumn.Index].Value,
Expression = row.Cells[ExpressionColumn.Index].Value as string,
Action = (FilterAction) Enum.Parse(typeof(FilterAction), row.Cells[ActionColumn.Index].Value as string)
};
}
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var isActive = true;
var isRegex = false;
RuleDataGridView.Rows.Add(isActive, isRegex);
}
private void RemoveButton_Click(object sender, EventArgs e)
{
if (RuleDataGridView.SelectedRows.Count != 0)
{
foreach (DataGridViewRow row in RuleDataGridView.SelectedRows)
{
RuleDataGridView.Rows.Remove(row);
}
} else
{
if (RuleDataGridView.CurrentRow != null)
{
RuleDataGridView.Rows.RemoveAt(RuleDataGridView.CurrentRow.Index);
}
}
}
private void RuleDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == ExpressionColumn.Index)
{
var row = RuleDataGridView.Rows[e.RowIndex];
var expression = row.Cells[ExpressionColumn.Index].Value as string;
if (expression == null)
{
RuleDataGridView.Rows.Remove(row);
}
}
DataChanged?.Invoke(GetRules());
}
private void RuleDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
DataChanged?.Invoke(GetRules());
}
private void RuleDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
{
DataChanged?.Invoke(GetRules());
}
private void RuleDataGridView_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if (e.RowIndex >= 0)
{
var row = RuleDataGridView.Rows[e.RowIndex];
var expression = (row.Cells[ExpressionColumn.Index].Value as string)?.Trim();
var isRegex = row.Cells[RegexColumn.Index].Value as bool? == true;
var isValidExpression = isRegex ? IsValidRegexRule(expression) : IsValidUrlRule(expression);
var isValidAction = !String.IsNullOrWhiteSpace(row.Cells[ActionColumn.Index].Value as string);
row.Cells[ActionColumn.Index].ErrorText = isValidAction ? null : "Please choose an action!";
row.Cells[ExpressionColumn.Index].ErrorText = isValidExpression ? null : (isRegex ? "Invalid regular expression!" : "Invalid URL rule!");
row.Cells[ExpressionColumn.Index].Value = expression;
}
}
private void RuleDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// The row should be updated as soon as the checkbox is changed, not just when the cell looses focus...
if (e.ColumnIndex == ActiveColumn.Index || e.ColumnIndex == RegexColumn.Index)
{
RuleDataGridView.EndEdit();
}
}
private void RuleDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
// If the current cell has changes, they need to be commited immediately. Otherwise, changes can be lost if the user
// chooses to save the settings via menu or key command since in that case the CellValueChanged event won't fire.
// See: https://stackoverflow.com/questions/963601/datagridview-value-does-not-gets-saved-if-selection-is-not-lost-from-a-cell
if (RuleDataGridView.IsCurrentCellDirty)
{
RuleDataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
private bool IsValidRegexRule(string regex)
{
try
{
new Regex(regex);
}
catch
{
return false;
}
return true;
}
private bool IsValidUrlRule(string rule)
{
return new SEBURLFilterExpression(rule) != null;
}
}
}

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ActiveColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RegexColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ExpressionColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ActionColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,8 @@
namespace SebWindowsConfig.Entities
{
enum FilterAction
{
Block,
Allow
}
}

View file

@ -0,0 +1,35 @@
using System.Collections.Generic;
namespace SebWindowsConfig.Entities
{
class FilterRule
{
public bool IsActive { get; set; }
public bool IsRegex { get; set; }
public string Expression { get; set; }
public FilterAction Action { get; set; }
internal static FilterRule FromConfig(IDictionary<string, object> config)
{
return new FilterRule
{
IsActive = config[SEBSettings.KeyURLFilterRuleActive] as bool? == true,
IsRegex = config[SEBSettings.KeyURLFilterRuleRegex] as bool? == true,
Expression = config[SEBSettings.KeyURLFilterRuleExpression] as string,
Action = config[SEBSettings.KeyURLFilterRuleAction] as int? == 1 ? FilterAction.Allow : FilterAction.Block
};
}
internal static IDictionary<string, object> ToConfig(FilterRule rule)
{
var config = new Dictionary<string, object>();
config[SEBSettings.KeyURLFilterRuleActive] = rule.IsActive;
config[SEBSettings.KeyURLFilterRuleRegex] = rule.IsRegex;
config[SEBSettings.KeyURLFilterRuleExpression] = rule.Expression;
config[SEBSettings.KeyURLFilterRuleAction] = rule.Action == FilterAction.Allow ? 1 : 0;
return config;
}
}
}

View file

@ -0,0 +1,10 @@
namespace SebWindowsConfig.Entities
{
public class PermittedApplicationInformation
{
public string Title { get; set; }
public string Executable { get; set; }
public string OriginalName { get; set; }
public string Path { get; set; }
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
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("SEB Config Tool")]
[assembly: AssemblyDescription("SEB Configuration Tool")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ETH Zurich")]
[assembly: AssemblyProduct("SEB Config Tool")]
[assembly: AssemblyCopyright("Copyright © 2010-2019 ETH Zurich, Educational Development and Technology (LET)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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("f7e6a767-de76-46c8-9ec7-387ff2a120c0")]
// 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("2.2.*")]
[assembly: AssemblyInformationalVersion("2.2.3")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SebWindowsConfig.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SebWindowsConfig.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SebWindowsConfig.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

File diff suppressed because it is too large Load diff

1143
SebWindowsConfig/SEBUIStrings.Designer.cs generated Normal file

File diff suppressed because it is too large Load diff

View file

View file

@ -0,0 +1,453 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="alertWebSocketPortBlocked" xml:space="preserve">
<value>WebSocket-Port blockiert</value>
</data>
<data name="alertWebSocketPortBlockedMessage" xml:space="preserve">
<value>Der TCP-Port 8706 ist blockiert. SEB benutzt diesen Port zur Kommunikation mit dem Browser. Obwohl SEB trotzdem läuft, ist keine volle Funktionalität garantiert.</value>
</data>
<data name="certificateNotFoundInStore" xml:space="preserve">
<value>Das zum Entschlüsseln der Einstellungen notwendige Zertifikat wurde nicht im Windows-Zertifikatsspeicher gefunden.</value>
</data>
<data name="closeProcesses" xml:space="preserve">
<value>Zugelassene oder verbotene Prozesse laufen</value>
</data>
<data name="closeProcessesQuestion" xml:space="preserve">
<value>Die untenstehenden Applikationen/Prozesse laufen momentan, sie müssen geschlossen werden, bevor die Prüfung gestartet wird. Wollen Sie diese Prozesse nun beenden (dies kann zu Datenverlust führen!)? Ansonsten wird SEB geschlossen und sie können diese Applikationen selber beenden, bevor Sie die Prüfung erneut starten.</value>
</data>
<data name="confirmQuitting" xml:space="preserve">
<value>Safe Exam Browser beenden</value>
</data>
<data name="confirmQuittingQuestion" xml:space="preserve">
<value>SEB wirklich beenden?</value>
</data>
<data name="createNewDesktopFailed" xml:space="preserve">
<value>Öffnen des neuen Desktops fehlgeschlagen</value>
</data>
<data name="createNewDesktopFailedReason" xml:space="preserve">
<value>Befehl "SetThreadDesktop" fehlgeschlagen: "Looks like the thread has hooks or windows in the current desktop."</value>
</data>
<data name="decryptingSettingsFailed" xml:space="preserve">
<value>Einstellungen konnten nicht entschlüsselt werden</value>
</data>
<data name="decryptingSettingsFailedReason" xml:space="preserve">
<value>Sie haben entweder das falsche Passwort eingegeben oder diese Einstellungen wurden mit einer inkompatiblen SEB-Version gespeichert.</value>
</data>
<data name="detectedVirtualMachine" xml:space="preserve">
<value>Virtuelle Maschine erkannt</value>
</data>
<data name="detectedVirtualMachineForbiddenMessage" xml:space="preserve">
<value>SEB darf nicht auf einer virtuellen Maschine ausgeführt werden! SEB wird jetzt beendet.</value>
</data>
<data name="detectedRemoteConnection" xml:space="preserve">
<value>Remote Session erkannt</value>
</data>
<data name="detectedRemoteConnectionMessage" xml:space="preserve">
<value>SEB darf nicht in einer Remote Session ausgeführt werden! SEB wird jetzt beendet.</value>
</data>
<data name="enterAdminPasswordRequired" xml:space="preserve">
<value>In diesen Einstellungen benutztes SEB-Administrator-Passwort eingeben:</value>
</data>
<data name="enterAdminPasswordRequiredAgain" xml:space="preserve">
<value>Falsches Passwort! In diesen Einstellungen benutztes SEB-Administrator-Passwort erneut eingeben:</value>
</data>
<data name="enterCurrentAdminPwdForReconfiguring" xml:space="preserve">
<value>SEB kann nur umkonfiguriert werden, wenn das aktuelle SEB-Administrator-Passwort eingegeben wird:</value>
</data>
<data name="enterCurrentAdminPwdForReconfiguringAgain" xml:space="preserve">
<value>Falsches Passwort! SEB-Administrator-Passwort erneut eingeben:</value>
</data>
<data name="enterEncryptionPassword" xml:space="preserve">
<value>Für die Verschlüsselung dieser Einstellungen benutztes Passwort eingeben:</value>
</data>
<data name="enterEncryptionPasswordAgain" xml:space="preserve">
<value>Falsches Passwort! Für die Verschlüsselung dieser Einstellungen benutztes Passwort erneut eingeben:</value>
</data>
<data name="enterPassword" xml:space="preserve">
<value>Passwort eingeben:</value>
</data>
<data name="enterPasswordAgain" xml:space="preserve">
<value>Falsches Passwort! Passwort erneut eingeben:</value>
</data>
<data name="ErrorCaption" xml:space="preserve">
<value>Fehler</value>
</data>
<data name="errorDecryptingSettings" xml:space="preserve">
<value>Fehler beim Entschlüsseln der Einstellungen</value>
</data>
<data name="ErrorWhenOpeningSettingsFile" xml:space="preserve">
<value>Fehler beim Öffnen der Datei SebClientSettings.seb!</value>
</data>
<data name="forceSebServiceMessage" xml:space="preserve">
<value>Der SEB-Windows-Dienst läuft nicht oder die SEB-Installation wurde beschädigt. Möglicherweise hilft ein Neustart des Rechners oder eine Neuinstallation von SEB. Informieren Sie Ihren Prüfungs-Administrator/Supporter. Die Prüfung kann nicht gestartet werden, SEB wird beendet.</value>
</data>
<data name="indicateMissingService" xml:space="preserve">
<value>SEB-Windows-Dienst nicht verfügbar</value>
</data>
<data name="indicateMissingServiceReason" xml:space="preserve">
<value>Der SEB-Windows-Dienst läuft nicht oder die SEB-Installation wurde beschädigt. Möglicherweise hilft ein Neustart des Rechners oder eine Neuinstallation von SEB. Informieren Sie Ihren Prüfungs-Administrator/Supporter. </value>
</data>
<data name="loadingSettings" xml:space="preserve">
<value>Einstellungen werden geladen</value>
</data>
<data name="loadingSettingsFailed" xml:space="preserve">
<value>Laden der Einstellungen fehlgeschlagen</value>
</data>
<data name="loadingSettingsFailedReason" xml:space="preserve">
<value>Diese Einstellungen sind beschädigt und können nicht verwendet werden.</value>
</data>
<data name="loadingSettingsFailedWrongAdminPwd" xml:space="preserve">
<value>Ohne das richtige Administrator-Passwort können diese Einstellungen nicht geöffnet werden.</value>
</data>
<data name="loadingSettingsNotAllowed" xml:space="preserve">
<value>Laden von neuen SEB-Einstellungen nicht erlaubt!</value>
</data>
<data name="loadingSettingsNotAllowedReason" xml:space="preserve">
<value>SEB läuft bereits im Prüfungsmodus und es ist nicht erlaubt, dies mittels Starten einer anderen Prüfung zu unterbrechen. Beenden Sie die Prüfung und schliessen Sie SEB, bevor Sie eine andere Prüfung starten.</value>
</data>
<data name="locatePermittedApplication" xml:space="preserve">
<value>Drittapplikation suchen</value>
</data>
<data name="noEncryptionChosen" xml:space="preserve">
<value>Keine Verschlüsselung ausgewählt</value>
</data>
<data name="noEncryptionChosenSaveUnencrypted" xml:space="preserve">
<value>Sie sollten entweder ein Passwort oder ein Zertifikat verwenden, um die Einstellungen zu verschlüsseln. Wollen Sie wirklich eine unverschlüsselte SEB-Einstellungsdatei speichern (für Prüfungseinsatz nicht empfohlen)?</value>
</data>
<data name="OSNotSupported" xml:space="preserve">
<value>Dieses Betriebssystem wird nicht unterstützt!</value>
</data>
<data name="permittedApplicationNotFound" xml:space="preserve">
<value>Drittapplikation nicht gefunden</value>
</data>
<data name="permittedApplicationNotFoundMessage" xml:space="preserve">
<value>Die zugelassene Applikation %s wurde auf diesem System nicht gefunden. Wenn in den Prüfungseinstellungen kein exakter Dateipfad angegeben ist, kann SEB Applikationen im Programme- oder Windows-Systemverzeichnis finden, und solche, die im System registriert sind.</value>
</data>
<data name="quittingFailed" xml:space="preserve">
<value>Beenden von SEB fehlgeschlagen: Falsches Passwort</value>
</data>
<data name="quittingFailedReason" xml:space="preserve">
<value>SEB kann nur nach Eingabe des korrekten Passworts beendet werden. Fragen Sie Ihren Prüfungs-Supporter nach dem Passwort. FÜHREN SIE KEINEN NEUSTART/RESET DURCH! Dies könnte unerwünschte Effekte auf Ihre Systemeinstellungen haben (siehe www.safeexambrowser.org/faq).</value>
</data>
<data name="reconfiguringLocalSettings" xml:space="preserve">
<value>Einstellungen zum Neu-Konfigurieren des Clients öffnen</value>
</data>
<data name="reconfiguringLocalSettingsFailed" xml:space="preserve">
<value>Öffnen der Einstellungen zum Neu-Konfigurieren des Clients fehlgeschlagen!</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongAdminPwd" xml:space="preserve">
<value>Ohne das richtige Administrator-Passwort aus diesen Einstellungen können diese nicht verwendet werden.</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongPassword" xml:space="preserve">
<value>Ohne das korrekte Passwort, mit dem diese Einstellungen verschlüsselt wurden, können diese nicht verwendet werden.</value>
</data>
<data name="reloadPage" xml:space="preserve">
<value>Seite neu laden</value>
</data>
<data name="reloadPageMessage" xml:space="preserve">
<value>Wollen Sie die geöffnete Webseite wirklich neu laden?</value>
</data>
<data name="restartExamDefaultTitle" xml:space="preserve">
<value>Zurück zum Start</value>
</data>
<data name="restartExamEnterPassword" xml:space="preserve">
<value>Beenden-/Neustart-Passwort eingeben: (Diese Funktion loggt Sie nicht aus, falls Sie sich auf einer Website eingeloggt haben)</value>
</data>
<data name="sebFileTypeName" xml:space="preserve">
<value>SEB Konfigurationsdateien</value>
</data>
<data name="sebReconfigured" xml:space="preserve">
<value>SEB neu konfiguriert</value>
</data>
<data name="sebReconfiguredQuestion" xml:space="preserve">
<value>Neue Konfiguration wurde gespeichert, diese wird benutzt, wenn SEB das nächste Mal gestartet wird. Wollen Sie SEB jetzt beenden?</value>
</data>
<data name="sebReconfiguredRestartNeeded" xml:space="preserve">
<value>SEB muss neu gestartet werden</value>
</data>
<data name="sebReconfiguredRestartNeededReason" xml:space="preserve">
<value>Die lokalen Client-Einstellungen von SEB wurden neu konfiguriert, aber wegen der geänderten "Create New Desktop"-Einstellung ist ein Neustart notwendig. SEB wird beendet, bitte manuell neu starten.</value>
</data>
<data name="settingsNotUsable" xml:space="preserve">
<value>Öffnen der neuen Einstellungen fehlgeschlagen</value>
</data>
<data name="settingsNotUsableReason" xml:space="preserve">
<value>Diese Einstellungen können nicht benutzt werden. Sie wurden möglicherweise mit einer neueren, inkompatiblen Version von SEB erstellt oder sind beschädigt.</value>
</data>
<data name="settingsRequireNewDesktop" xml:space="preserve">
<value>Einstellungen verlangen "Create new desktop"-Kiosk-Modus</value>
</data>
<data name="settingsRequireNewDesktopReason" xml:space="preserve">
<value>Die geöffneten Prüfungseinstellungen verlangen das Öffnen eines neuen Desktops, aber momentan läuf SEB auf dem Standard-Desktop. Ein Prüfungsadministrator/Supporter muss die lokalen SEB Client-Einstellungen ändern (Kiosk-Modus "Create new desktop"). SEB wird jetzt beendet.</value>
</data>
<data name="settingsRequireNotNewDesktop" xml:space="preserve">
<value>Einstellungen verlangen den Standard-Desktop</value>
</data>
<data name="settingsRequireNotNewDesktopReason" xml:space="preserve">
<value>Die geöffneten Prüfungseinstellungen verlangen den Standard-Desktop, aber momentan läuf SEB auf einem neuen Desktop. Ein Prüfungsadministrator/Supporter muss die lokalen SEB Client-Einstellungen ändern: Kiosk-Modus darf nicht auf "Create new desktop" gesetzt sein. SEB wird jetzt beendet.</value>
</data>
<data name="settingsTitleDefaultSettings" xml:space="preserve">
<value>Voreinstellungen</value>
</data>
<data name="settingsUntitledFilename" xml:space="preserve">
<value>Unbenannt</value>
</data>
<data name="unsavedChangesQuestion" xml:space="preserve">
<value>Aktuelle Einstellungen haben ungesicherte Änderungen. Wollen Sie diese speichern?</value>
</data>
<data name="unsavedChangesTitle" xml:space="preserve">
<value>Ungesicherte Änderungen</value>
</data>
<data name="KeyboardLayout_CURRENTCULTURE" xml:space="preserve">
<value>Keyboard-Layout: {0} - Zum Wechseln Anklicken</value>
</data>
<data name="identityExportError" xml:space="preserve">
<value>Export der kryptografischen Identität fehlgeschlagen</value>
</data>
<data name="toolTipConnectedToWiFiNetwork" xml:space="preserve">
<value>Verbunden mit {0}</value>
</data>
<data name="toolTipNotConnectedToWiFiNetwork" xml:space="preserve">
<value>Nicht verbunden</value>
</data>
<data name="toolTipNoWiFiInterface" xml:space="preserve">
<value>Kein WLAN-Adapter gefunden</value>
</data>
<data name="toolTipOnScreenKeyboard" xml:space="preserve">
<value>Bildschirmtastatur ein-/ausblenden</value>
</data>
<data name="identityExportErrorMessage" xml:space="preserve">
<value>Die Identität (Zertifikat mit privatem Schlüssel) '{0}' konnte nicht exportiert werden. Ihr privater Schlüssel könnte als nicht-exportierbar gekennzeichnet sein.</value>
</data>
<data name="certificateDecryptingError" xml:space="preserve">
<value>Das Entschlüsseln der Einstellungen mittels Zertifikat und privatem Schlüssel aus dem Windows-Zertifikatsspeicher schlug fehl mit Fehlermeldung: </value>
</data>
<data name="webSocketServerNotStarted" xml:space="preserve">
<value>Kommunikation mit dem SEB-Browser konnte nicht aufgebaut werden</value>
</data>
<data name="webSocketServerNotStartedMessage" xml:space="preserve">
<value>SEB wird beendet, versuchen Sie, SEB neu zu starten. Wenn dies nicht hilft, starten Sie Ihren Rechner neu.</value>
</data>
<data name="restartExamConfirm" xml:space="preserve">
<value>Sind Sie sicher? (Diese Funktion loggt Sie nicht aus, falls Sie sich auf einer Website eingeloggt haben)</value>
</data>
<data name="wrongQuitRestartPasswordText" xml:space="preserve">
<value>Falsches Beenden-/Neustart-Passwort</value>
</data>
<data name="toolTipOnScreenKeyboardNotEnabled" xml:space="preserve">
<value>Um die Bildschirmtastatur nutzen zu können, bitte den Windows Tablet-Modus aktivieren und die physische Tastatur entfernen</value>
</data>
<data name="tableModeNotEnabledWarningText" xml:space="preserve">
<value>Bitte den Windows Tablet Modus aktivieren und SEB erneut starten.</value>
</data>
<data name="tableModeNotEnabledWarningTitle" xml:space="preserve">
<value>Windows Tablet Modus aktivieren</value>
</data>
<data name="errorOpeningResource" xml:space="preserve">
<value>Eingebettete Ressource konnte nicht mit zugelassener Applikation geöffnet werden</value>
</data>
<data name="prohibitedProcessDetectedQuitPassword" xml:space="preserve">
<value>SEB hat einen verbotenen Prozess detektiert, welcher nicht beendet werden konnte. Geben Sie das Beenden-Passwort ein, um fortzufahren. </value>
</data>
<data name="prohibitedProcessDetectedText" xml:space="preserve">
<value>SEB hat einen verbotenen Prozess detektiert, welcher nicht beendet werden konnte: </value>
</data>
<data name="prohibitedProcessDetectedTitle" xml:space="preserve">
<value>Verbotener Prozess detektiert</value>
</data>
<data name="unableToCloseProcessesText" xml:space="preserve">
<value>SEB konnte die untenstehenden Prozesse nicht beennden, schliessen Sie diese manuell und starten Sie SEB danach wieder</value>
</data>
<data name="unableToCloseProcessesTitle" xml:space="preserve">
<value>SEB konnte Prozesse nicht beenden</value>
</data>
<data name="loadingString" xml:space="preserve">
<value>Laden</value>
</data>
<data name="cannotOpenSEBConfig" xml:space="preserve">
<value>SEB-Einstellungen können nicht geöffnet werden</value>
</data>
<data name="cannotOpenSEBConfigMessage" xml:space="preserve">
<value>Das Öffnen von externen SEB-Konfigurationen wird durch die lokalen Client-Einstellungen nicht erlaubt. Starten Sie die SEB-Applikation direkt.</value>
</data>
<data name="cannotOpenSEBLink" xml:space="preserve">
<value>SEB-Link kann nicht geöffnet werden</value>
</data>
<data name="cannotOpenSEBLinkMessage" xml:space="preserve">
<value>Öffnen des SEB-Links ist fehlgeschlagen. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.</value>
</data>
<data name="NoWLANInterface" xml:space="preserve">
<value>Kein WLAN-Interface gefunden</value>
</data>
<data name="openingSettingsFailed" xml:space="preserve">
<value>Öffnen der Einstellungen fehlgeschlagen</value>
</data>
<data name="openingSettingsFailedMessage" xml:space="preserve">
<value>Die Konfigurationsdatei konnte nicht geöffnet werden.</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongCurrentAdminPwd" xml:space="preserve">
<value>Ohne das aktuelle Administrator-Passwort können diese Einstellungen nicht verwendet werden.</value>
</data>
<data name="settingsDuplicateSuffix" xml:space="preserve">
<value> Kopie</value>
</data>
<data name="unconfirmedPasswordMessage" xml:space="preserve">
<value>Bitte zuerst das %s bestätigen.</value>
</data>
<data name="unconfirmedPasswordTitle" xml:space="preserve">
<value>Passwort nicht korrekt bestätigt</value>
</data>
<data name="WlanConnecting" xml:space="preserve">
<value>Verbinden...</value>
</data>
<data name="WlanConnectionFailedMessage" xml:space="preserve">
<value>Verbindung mit dem WLAN-Netzwerk ist fehlgeschlagen, bitte erneut versuchen.</value>
</data>
<data name="WlanConnectionFailedMessageTitle" xml:space="preserve">
<value>Verbindung fehlgeschlagen</value>
</data>
<data name="WlanNoNetworkInterfaceFound" xml:space="preserve">
<value>Kein Netzwerk-Interface gefunden</value>
</data>
<data name="WlanNoNetworksFound" xml:space="preserve">
<value>Keine bekannten Netzwerke gefunden</value>
</data>
<data name="WLANNotConnected" xml:space="preserve">
<value>Nicht verbunden</value>
</data>
<data name="WlanThatYouHaveUsedBefore" xml:space="preserve">
<value>die Sie zuvor benutzt haben.</value>
</data>
<data name="WlanYouCanOnlyConnectToNetworks" xml:space="preserve">
<value>Sie können sich nur mit Netzwerken verbinden</value>
</data>
<data name="AdditionalResourceConfirmMessage" xml:space="preserve">
<value>Möchten Sie die Ressource "%%TITLE%%" öffnen?</value>
</data>
<data name="AdditionalResourceConfirmTitle" xml:space="preserve">
<value>Ressource öffnen?</value>
</data>
<data name="spareBrowserFileNamesFound" xml:space="preserve">
<value>SEB Installation ist beschädigt </value>
</data>
<data name="spareBrowserFileNamesFoundText" xml:space="preserve">
<value>SEB hat irreguläre Dateien in seinem Programmverzeichnis gefunden. Diese könnten von einer älteren Version stammen, falls ein Fehler bei einem SEB-Update aufgetreten ist. Deinstallieren Sie SEB mittels des Windows Kontrollzentrums, danach löschen Sie das SafeExamBrowser-Unterverzeichnis aus dem Program Files (x86) Verzeichnis und installieren Sie diese SEB-Version neu. Liste der überzähligen Dateien:</value>
</data>
</root>

View file

@ -0,0 +1,480 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="alertWebSocketPortBlocked" xml:space="preserve">
<value>WebSocket Port Blocked</value>
</data>
<data name="alertWebSocketPortBlockedMessage" xml:space="preserve">
<value>Your TCP port 8706 is blocked. SEB uses this port to communicate with the browser. Although SEB is working without this, full functionality is not guaranteed.</value>
</data>
<data name="cannotOpenSEBLink" xml:space="preserve">
<value>Cannot Open SEB Link</value>
</data>
<data name="cannotOpenSEBLinkMessage" xml:space="preserve">
<value>Opening the SEB link failed. Check your internet connection and try again.</value>
</data>
<data name="certificateNotFoundInStore" xml:space="preserve">
<value>The certificate needed to decrypt settings has not been found in the Windows Certificate Store.</value>
</data>
<data name="closeProcesses" xml:space="preserve">
<value>Permitted or Prohibited Processes Are Running</value>
</data>
<data name="closeProcessesQuestion" xml:space="preserve">
<value>The processes below are running, they need to be closed before starting the exam. Do you want to close those processes now (this may lead to loss of data!)? Otherwise SEB will quit and you can close those applications yourself before trying to start the exam again.</value>
</data>
<data name="confirmQuitting" xml:space="preserve">
<value>Quit Safe Exam Browser</value>
</data>
<data name="confirmQuittingQuestion" xml:space="preserve">
<value>Are you sure you want to quit SEB?</value>
</data>
<data name="createNewDesktopFailed" xml:space="preserve">
<value>Creating New Desktop Failed</value>
</data>
<data name="createNewDesktopFailedReason" xml:space="preserve">
<value>SetThreadDesktop failed! Looks like the thread has hooks or windows in the current desktop.</value>
</data>
<data name="decryptingSettingsFailed" xml:space="preserve">
<value>Cannot Decrypt Settings</value>
</data>
<data name="decryptingSettingsFailedReason" xml:space="preserve">
<value>You either entered the wrong password or these settings were saved with an incompatible SEB version.</value>
</data>
<data name="detectedVirtualMachine" xml:space="preserve">
<value>Virtual Machine Detected</value>
</data>
<data name="detectedVirtualMachineForbiddenMessage" xml:space="preserve">
<value>It is not allowed to run SEB on a virtual machine! SEB will quit now.</value>
</data>
<data name="detectedRemoteConnection" xml:space="preserve">
<value>Remote Connection Detected</value>
</data>
<data name="detectedRemoteConnectionMessage" xml:space="preserve">
<value>It is not allowed to run SEB in a remote session! SEB will quit now.</value>
</data>
<data name="enterAdminPasswordRequired" xml:space="preserve">
<value>Enter the SEB administrator password used in these settings:</value>
</data>
<data name="enterAdminPasswordRequiredAgain" xml:space="preserve">
<value>Wrong password! Try again to enter the correct SEB administrator password from these settings:</value>
</data>
<data name="enterCurrentAdminPwdForReconfiguring" xml:space="preserve">
<value>You can only reconfigure SEB by entering the current SEB administrator password:</value>
</data>
<data name="enterCurrentAdminPwdForReconfiguringAgain" xml:space="preserve">
<value>Wrong password! Try again to enter the correct current SEB administrator password:</value>
</data>
<data name="enterEncryptionPassword" xml:space="preserve">
<value>Enter password used to encrypt these settings:</value>
</data>
<data name="enterEncryptionPasswordAgain" xml:space="preserve">
<value>Wrong password! Try again to enter the correct password used to encrypt these settings:</value>
</data>
<data name="enterPassword" xml:space="preserve">
<value>Enter password:</value>
</data>
<data name="enterPasswordAgain" xml:space="preserve">
<value>Wrong password! Try again to enter the correct password:</value>
</data>
<data name="errorDecryptingSettings" xml:space="preserve">
<value>Error Decrypting Settings</value>
</data>
<data name="forceSebServiceMessage" xml:space="preserve">
<value>SEB Windows service is stopped or the installed SEB got corrupted. Rebooting your machine or reinstalling SEB might help. Inform your exam administrator/supporter. The exam cannot be started, SEB will quit now.</value>
</data>
<data name="indicateMissingService" xml:space="preserve">
<value>SEB Windows Service Not Available</value>
</data>
<data name="indicateMissingServiceReason" xml:space="preserve">
<value>SEB Windows service is stopped or the installed SEB got corrupted. Rebooting your machine or reinstalling SEB might help. Inform your exam administrator/supporter. </value>
</data>
<data name="loadingSettings" xml:space="preserve">
<value>Loading Settings</value>
</data>
<data name="loadingSettingsFailed" xml:space="preserve">
<value>Loading Settings Failed</value>
</data>
<data name="loadingSettingsFailedReason" xml:space="preserve">
<value>These settings are corrupted and cannot be used.</value>
</data>
<data name="loadingSettingsFailedWrongAdminPwd" xml:space="preserve">
<value>If you don't enter the right administrator password from these settings you cannot open them.</value>
</data>
<data name="loadingSettingsNotAllowed" xml:space="preserve">
<value>Loading New SEB Settings Not Allowed!</value>
</data>
<data name="loadingSettingsNotAllowedReason" xml:space="preserve">
<value>SEB is already running in exam mode and it is not allowed to interupt this by starting another exam. Finish the exam and quit SEB before starting another exam.</value>
</data>
<data name="locatePermittedApplication" xml:space="preserve">
<value>Locate Third Party Application</value>
</data>
<data name="noEncryptionChosen" xml:space="preserve">
<value>No Encryption Credentials Chosen</value>
</data>
<data name="noEncryptionChosenSaveUnencrypted" xml:space="preserve">
<value>You should either enter a password or choose a certificate to encrypt the settings file. Do you really want to save an unencrypted SEB file (not recommended for use in exams)?</value>
</data>
<data name="openingSettingsFailed" xml:space="preserve">
<value>Opening Settings Failed</value>
</data>
<data name="openingSettingsFailedMessage" xml:space="preserve">
<value>The configuration file could not be openend.</value>
</data>
<data name="permittedApplicationNotFound" xml:space="preserve">
<value>Third Party Application Not Found</value>
</data>
<data name="permittedApplicationNotFoundMessage" xml:space="preserve">
<value>The permitted application %s wasn't found on this system. If exam settings don't indicate a precise path, SEB can find applications installed in the Program Files or Windows System directory and those which are registered in the system.</value>
</data>
<data name="quittingFailed" xml:space="preserve">
<value>Wrong Password: Quitting SEB Failed</value>
</data>
<data name="quittingFailedReason" xml:space="preserve">
<value>You can only quit SEB by entering the correct quit password. Ask your exam supporter for the correct password. DO NOT RESET YOUR MACHINE! This may have undesired effects on your system's settings (see www.safeexambrowser.org/faq).</value>
</data>
<data name="reconfiguringLocalSettings" xml:space="preserve">
<value>Opening Settings for Reconfiguring Client</value>
</data>
<data name="reconfiguringLocalSettingsFailed" xml:space="preserve">
<value>Opening Settings for Reconfiguring Client Failed</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongAdminPwd" xml:space="preserve">
<value>If you don't enter the right administrator password from these settings you cannot use them.</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongPassword" xml:space="preserve">
<value>If you don't enter the correct password these settings were encrypted with, you cannot use them.</value>
</data>
<data name="reloadPage" xml:space="preserve">
<value>Reload Current Page</value>
</data>
<data name="reloadPageMessage" xml:space="preserve">
<value>Do you really want to reload the current web page?</value>
</data>
<data name="restartExamDefaultTitle" xml:space="preserve">
<value>Back to Start</value>
</data>
<data name="restartExamEnterPassword" xml:space="preserve">
<value>Enter quit/restart password: (This function doesn't log you out if you are logged in on a website)</value>
</data>
<data name="savingSettingsFailed" xml:space="preserve">
<value>Saving Settings Failed</value>
</data>
<data name="savingSettingsFailedMessage" xml:space="preserve">
<value>The configuration file could not be saved.</value>
</data>
<data name="sebFileTypeName" xml:space="preserve">
<value>SEB Configuration Files</value>
</data>
<data name="sebReconfigured" xml:space="preserve">
<value>SEB Re-Configured</value>
</data>
<data name="sebReconfiguredQuestion" xml:space="preserve">
<value>New settings have been saved, they will be used when you start SEB next time again. Do you want to quit SEB for now?</value>
</data>
<data name="sebReconfiguredRestartNeeded" xml:space="preserve">
<value>SEB Needs to be Restarted</value>
</data>
<data name="sebReconfiguredRestartNeededReason" xml:space="preserve">
<value>Local settings have been reconfigured, but SEB needs to be restarted for the changed "Create new desktop" setting to take effect. SEB will quit now, please restart it manually.</value>
</data>
<data name="settingsDuplicateSuffix" xml:space="preserve">
<value> copy</value>
</data>
<data name="settingsNotUsable" xml:space="preserve">
<value>Opening New Settings Failed</value>
</data>
<data name="settingsNotUsableReason" xml:space="preserve">
<value>These settings cannot be used. They may have been created by an newer, incompatible version of SEB or are corrupted.</value>
</data>
<data name="settingsRequireNewDesktop" xml:space="preserve">
<value>Settings Require New Desktop Kiosk Mode</value>
</data>
<data name="settingsRequireNewDesktopReason" xml:space="preserve">
<value>Loaded exam settings require a new desktop, but currently SEB is running on the standard desktop. Ask your exam administrator/supporter to reconfigure local SEB client settings with the "Create new desktop" kiosk mode. SEB will quit now.</value>
</data>
<data name="settingsRequireNotNewDesktop" xml:space="preserve">
<value>Settings Require Standard Desktop</value>
</data>
<data name="settingsRequireNotNewDesktopReason" xml:space="preserve">
<value>Loaded exam settings require the standard desktop, but currently SEB is running on a new desktop. Ask your exam administrator/supporter to reconfigure local SEB client settings with the kiosk mode set to another than "Create new desktop". SEB will quit now.</value>
</data>
<data name="settingsTitleDefaultSettings" xml:space="preserve">
<value>Default Settings</value>
</data>
<data name="settingsUntitledFilename" xml:space="preserve">
<value>untitled</value>
</data>
<data name="unsavedChangesQuestion" xml:space="preserve">
<value>Current settings have unsaved changes. Do you want to save those first?</value>
</data>
<data name="unsavedChangesTitle" xml:space="preserve">
<value>Unsaved Changes</value>
</data>
<data name="KeyboardLayout_CURRENTCULTURE" xml:space="preserve">
<value>Keyboard Layout: {0} - Click to change</value>
</data>
<data name="ChooseEmbeddedCert" xml:space="preserve">
<value>Choose certificate to add</value>
</data>
<data name="ErrorCaption" xml:space="preserve">
<value>Error</value>
</data>
<data name="ErrorWhenOpeningSettingsFile" xml:space="preserve">
<value>Error when opening the file SebClientSettings.seb!</value>
</data>
<data name="OSNotSupported" xml:space="preserve">
<value>This OS is not supported!</value>
</data>
<data name="passwordAdmin" xml:space="preserve">
<value>administrator password</value>
</data>
<data name="passwordQuit" xml:space="preserve">
<value>quit/restart password</value>
</data>
<data name="passwordSettings" xml:space="preserve">
<value>settings password</value>
</data>
<data name="unconfirmedPasswordMessage" xml:space="preserve">
<value>Please enter the correct confirm %s first.</value>
</data>
<data name="unconfirmedPasswordTitle" xml:space="preserve">
<value>No Correct Confirm Password</value>
</data>
<data name="toolTipConnectedToWiFiNetwork" xml:space="preserve">
<value>Connected to {0}</value>
</data>
<data name="toolTipNotConnectedToWiFiNetwork" xml:space="preserve">
<value>Not Connected</value>
</data>
<data name="toolTipNoWiFiInterface" xml:space="preserve">
<value>No WiFi Interface Found</value>
</data>
<data name="toolTipOnScreenKeyboard" xml:space="preserve">
<value>Show/Hide On-Screen Keyboard</value>
</data>
<data name="identityExportError" xml:space="preserve">
<value>Exporting Identity Failed</value>
</data>
<data name="identityExportErrorMessage" xml:space="preserve">
<value>The identity (certificate with private key) '{0}' could not be exported. Its private key might be flagged as non-exportable.</value>
</data>
<data name="certificateDecryptingError" xml:space="preserve">
<value>Decrypting settings using a certificate and private key stored in the Windows Certificate Store failed with error: </value>
</data>
<data name="webSocketServerNotStarted" xml:space="preserve">
<value>Couldn't Establish Communication with the SEB Browser</value>
</data>
<data name="webSocketServerNotStartedMessage" xml:space="preserve">
<value>SEB will quit, try to restart SEB, if this doesn't help restart your machine.</value>
</data>
<data name="reconfiguringLocalSettingsFailedWrongCurrentAdminPwd" xml:space="preserve">
<value>You didn't enter the correct current SEB administrator password.</value>
</data>
<data name="savingSettingsSucceeded" xml:space="preserve">
<value>Saved Settings Purpose</value>
</data>
<data name="savingSettingsSucceededMessageConfigureClient" xml:space="preserve">
<value>Settings have been saved, use this file to configure local settings of a SEB client.</value>
</data>
<data name="savingSettingsSucceededStartExam" xml:space="preserve">
<value>Settings have been saved, use this file to start an exam with SEB.</value>
</data>
<data name="NoWLANInterface" xml:space="preserve">
<value>No WiFi Interface found</value>
</data>
<data name="WLANNotConnected" xml:space="preserve">
<value>Not connected</value>
</data>
<data name="wrongQuitRestartPasswordText" xml:space="preserve">
<value>Wrong quit/restart password</value>
</data>
<data name="restartExamConfirm" xml:space="preserve">
<value>Are you sure? (This function doesn't log you out if you are logged in on a website)</value>
</data>
<data name="WlanConnectionFailedMessage" xml:space="preserve">
<value>Connection to WiFi network failed, try again.</value>
</data>
<data name="WlanConnectionFailedMessageTitle" xml:space="preserve">
<value>Connection failed</value>
</data>
<data name="WlanConnecting" xml:space="preserve">
<value>Connecting...</value>
</data>
<data name="WlanNoNetworkInterfaceFound" xml:space="preserve">
<value>No network interface found</value>
</data>
<data name="WlanNoNetworksFound" xml:space="preserve">
<value>No known networks found!</value>
</data>
<data name="WlanYouCanOnlyConnectToNetworks" xml:space="preserve">
<value>you can only connect to networks</value>
</data>
<data name="WlanThatYouHaveUsedBefore" xml:space="preserve">
<value>that you have used before.</value>
</data>
<data name="toolTipOnScreenKeyboardNotEnabled" xml:space="preserve">
<value>To use the on-screen-keyboard, enable tablet mode and detach the keyboard</value>
</data>
<data name="tableModeNotEnabledWarningText" xml:space="preserve">
<value>Please enable Windows Tablet Mode and start SEB again.</value>
</data>
<data name="tableModeNotEnabledWarningTitle" xml:space="preserve">
<value>Enable Windows Tablet Mode</value>
</data>
<data name="errorOpeningResource" xml:space="preserve">
<value>Opening embedded resource with permitted application failed</value>
</data>
<data name="prohibitedProcessDetectedQuitPassword" xml:space="preserve">
<value>SEB detected a prohibited process which it was unable to exit, enter the quit password to continue. </value>
</data>
<data name="prohibitedProcessDetectedText" xml:space="preserve">
<value>SEB detected a prohibited process which it was unable to exit: </value>
</data>
<data name="prohibitedProcessDetectedTitle" xml:space="preserve">
<value>Prohibited Process detected</value>
</data>
<data name="unableToCloseProcessesText" xml:space="preserve">
<value>SEB was unable to terminate the following processes, close them manually and restart SEB afterwards</value>
</data>
<data name="unableToCloseProcessesTitle" xml:space="preserve">
<value>SEB was unable to close processes</value>
</data>
<data name="loadingString" xml:space="preserve">
<value>Loading</value>
</data>
<data name="cannotOpenSEBConfig" xml:space="preserve">
<value>Cannot Open SEB Config</value>
</data>
<data name="cannotOpenSEBConfigMessage" xml:space="preserve">
<value>Opening an external SEB config is disabled in current settings. Start the SEB application directly.</value>
</data>
<data name="AdditionalResourceConfirmMessage" xml:space="preserve">
<value>Would you like to open the resource "%%TITLE%%"?</value>
</data>
<data name="AdditionalResourceConfirmTitle" xml:space="preserve">
<value>Open Resource?</value>
</data>
<data name="spareBrowserFileNamesFound" xml:space="preserve">
<value>SEB installation is corrupted </value>
</data>
<data name="spareBrowserFileNamesFoundText" xml:space="preserve">
<value>SEB found irregular files in its program directory. These might have been left from an older SEB version if an update failed. Uninstall SEB using the Windows Control Panel, afterwards delete the SafeExamBrowser subdirectory from the Program Files (x86) directory and re-install this SEB version freshly. List of spare files:</value>
</data>
</root>

View file

@ -0,0 +1,94 @@
namespace SebWindowsConfig
{
partial class SebPasswordDialogForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SebPasswordDialogForm));
this.txtSEBPassword = new System.Windows.Forms.MaskedTextBox();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.lblSEBPassword = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtSEBPassword
//
resources.ApplyResources(this.txtSEBPassword, "txtSEBPassword");
this.txtSEBPassword.Name = "txtSEBPassword";
this.txtSEBPassword.PasswordChar = '●';
this.txtSEBPassword.Enter += new System.EventHandler(this.txtSEBPassword_Enter);
this.txtSEBPassword.Leave += new System.EventHandler(this.txtSEBPassword_Leave);
//
// btnOk
//
resources.ApplyResources(this.btnOk, "btnOk");
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.Name = "btnOk";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
resources.ApplyResources(this.btnCancel, "btnCancel");
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Name = "btnCancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// lblSEBPassword
//
resources.ApplyResources(this.lblSEBPassword, "lblSEBPassword");
this.lblSEBPassword.Name = "lblSEBPassword";
//
// SebPasswordDialogForm
//
this.AcceptButton = this.btnOk;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ControlBox = false;
this.Controls.Add(this.lblSEBPassword);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.txtSEBPassword);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SebPasswordDialogForm";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label lblSEBPassword;
public System.Windows.Forms.MaskedTextBox txtSEBPassword;
}
}

View file

@ -0,0 +1,141 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SebWindowsConfig.Utilities;
namespace SebWindowsConfig
{
public partial class SebPasswordDialogForm : Form
{
[DllImportAttribute("User32.dll")]
public static extern IntPtr SetForegroundWindow(IntPtr hWnd);
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Show SEB Password Dialog Form.
/// </summary>
/// ----------------------------------------------------------------------------------------
public static string ShowPasswordDialogForm(string title, string passwordRequestText)
{
using (SebPasswordDialogForm sebPasswordDialogForm = new SebPasswordDialogForm())
{
SetForegroundWindow(sebPasswordDialogForm.Handle);
sebPasswordDialogForm.TopMost = true;
// Set the title of the dialog window
sebPasswordDialogForm.Text = title;
// Set the text of the dialog
sebPasswordDialogForm.LabelText = passwordRequestText;
sebPasswordDialogForm.txtSEBPassword.Focus();
// If we are running in SebWindowsClient we need to activate it before showing the password dialog
// Don't do this; it will fail when the password dialog is running in a separate thread
//if (SEBClientInfo.SebWindowsClientForm != null) SEBClientInfo.SebWindowsClientForm.Activate();
// Show password dialog as a modal dialog and determine if DialogResult = OK.
if (sebPasswordDialogForm.ShowDialog() == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
string password = sebPasswordDialogForm.txtSEBPassword.Text;
sebPasswordDialogForm.txtSEBPassword.Text = "";
//sebPasswordDialogForm.txtSEBPassword.Focus();
return password;
}
else
{
return null;
}
}
}
public SebPasswordDialogForm()
{
InitializeComponent();
try
{
if ((Boolean) SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized] ==
true)
{
InitializeForTouch();
}
else
{
InitializeForNonTouch();
}
}
//if used to decrypt the settings, then the settings are not yet initialized...
catch{}
}
public void InitializeForTouch()
{
this.Font = new Font(FontFamily.GenericSansSerif, 12);
IntPtr hwnd = this.Handle;
this.FormBorderStyle = FormBorderStyle.None;
this.Top = 0;
this.Left = 0;
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = Screen.PrimaryScreen.Bounds.Height;
this.btnCancel.BackColor = Color.Red;
this.btnCancel.FlatStyle = FlatStyle.Flat;
this.btnCancel.Height = 35;
this.btnCancel.Width = 120;
this.btnCancel.Left = (Screen.PrimaryScreen.Bounds.Width / 2) - (this.btnCancel.Width / 2) + 100;
this.btnOk.BackColor = Color.Green;
this.btnOk.FlatStyle = FlatStyle.Flat;
this.btnOk.Height = 35;
this.btnOk.Width = 120;
this.btnOk.Left = (Screen.PrimaryScreen.Bounds.Width / 2) - (this.btnOk.Width / 2) - 100;
this.txtSEBPassword.Width = 400;
this.txtSEBPassword.Left = (Screen.PrimaryScreen.Bounds.Width / 2) - (this.txtSEBPassword.Width / 2);
this.txtSEBPassword.Height = 30;
}
public void InitializeForNonTouch()
{
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.txtSEBPassword.Text = "";
}
private void btnOk_Click(object sender, EventArgs e)
{
this.Visible = false;
}
// Expose the label for changing from outside of the form
public string LabelText
{
get
{
return this.lblSEBPassword.Text;
}
set
{
this.lblSEBPassword.Text = value;
try
{
if ((Boolean)SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized] == true)
{
this.lblSEBPassword.Left = (Screen.PrimaryScreen.Bounds.Width / 2) - (this.lblSEBPassword.Width / 2);
}
}
catch (Exception)
{
}
}
}
private void txtSEBPassword_Enter(object sender, EventArgs e)
{
}
private void txtSEBPassword_Leave(object sender, EventArgs e)
{
}
}
}

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="btnCancel.Text" xml:space="preserve">
<value>Abbrechen</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Lokale SEB-Einstellungen umkonfigurieren</value>
</data>
</root>

View file

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="&gt;&gt;btnOk.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnOk.Name" xml:space="preserve">
<value>btnOk</value>
</data>
<data name="&gt;&gt;lblSEBPassword.Name" xml:space="preserve">
<value>lblSEBPassword</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>SebPasswordDialogForm</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnOk.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="&gt;&gt;txtSEBPassword.Name" xml:space="preserve">
<value>txtSEBPassword</value>
</data>
<data name="lblSEBPassword.Size" type="System.Drawing.Size, System.Drawing">
<value>0, 13</value>
</data>
<data name="&gt;&gt;btnCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="txtSEBPassword.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 55</value>
</data>
<data name="btnOk.Location" type="System.Drawing.Point, System.Drawing">
<value>94, 91</value>
</data>
<data name="&gt;&gt;txtSEBPassword.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>349, 136</value>
</data>
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>180, 91</value>
</data>
<data name="lblSEBPassword.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 20</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
</data>
<data name="&gt;&gt;lblSEBPassword.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;btnOk.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="&gt;&gt;btnOk.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;txtSEBPassword.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnCancel.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="lblSEBPassword.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="&gt;&gt;btnCancel.Name" xml:space="preserve">
<value>btnCancel</value>
</data>
<data name="&gt;&gt;txtSEBPassword.Type" xml:space="preserve">
<value>System.Windows.Forms.MaskedTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="btnCancel.Text" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="&gt;&gt;btnCancel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="lblSEBPassword.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>325, 30</value>
</data>
<data name="btnOk.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;lblSEBPassword.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lblSEBPassword.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="txtSEBPassword.Size" type="System.Drawing.Size, System.Drawing">
<value>325, 20</value>
</data>
<data name="btnOk.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="txtSEBPassword.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Reconfiguring Local SEB Settings</value>
</data>
<data name="&gt;&gt;lblSEBPassword.Parent" xml:space="preserve">
<value>$this</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>de</value>
</metadata>
</root>

View file

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BEF73897-0D04-4F40-AD89-62E24D260CD0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SebWindowsConfig</RootNamespace>
<AssemblyName>SEBConfigTool</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>SEBConfigToolIcon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetZip, Version=1.13.3.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.3\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\FilterRuleControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\FilterRuleControl.Designer.cs">
<DependentUpon>FilterRuleControl.cs</DependentUpon>
</Compile>
<Compile Include="Entities\FilterAction.cs" />
<Compile Include="Entities\FilterRule.cs" />
<Compile Include="Entities\PermittedApplicationInformation.cs" />
<Compile Include="SebPasswordDialogForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SebPasswordDialogForm.Designer.cs" />
<Compile Include="SEBUIStrings.de.Designer.cs" />
<Compile Include="SEBUIStrings.Designer.cs" />
<Compile Include="SebWindowsConfigGUIManagement.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SebWindowsConfigForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SebWindowsConfigForm.Designer.cs">
<DependentUpon>SebWindowsConfigForm.cs</DependentUpon>
</Compile>
<Compile Include="SebWindowsConfigProgram.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Controls\AdditionalResources.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\AdditionalResources.Designer.cs">
<DependentUpon>AdditionalResources.cs</DependentUpon>
</Compile>
<Compile Include="Utilities\FileCompressor.cs" />
<Compile Include="Utilities\IFileCompressor.cs" />
<Compile Include="Utilities\LogCollector.cs" />
<Compile Include="Utilities\Logger.cs" />
<Compile Include="Utilities\Plist.cs" />
<Compile Include="Utilities\SEBClientInfo.cs" />
<Compile Include="SEBSettings.cs" />
<Compile Include="Utilities\SEBConfigFileManager.cs" />
<Compile Include="Utilities\SEBProtectionController.cs" />
<Compile Include="Utilities\SEBURLFilter.cs" />
<Compile Include="Utilities\SEBURLFilterExpression.cs" />
<Compile Include="Utilities\SEBURLFilterRegexExpression.cs" />
<EmbeddedResource Include="Controls\FilterRuleControl.resx">
<DependentUpon>FilterRuleControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SebPasswordDialogForm.de.resx" />
<EmbeddedResource Include="SebPasswordDialogForm.resx" />
<EmbeddedResource Include="SEBUIStrings.de.resx" />
<EmbeddedResource Include="SEBUIStrings.resx" />
<EmbeddedResource Include="SebWindowsConfigForm.resx">
<DependentUpon>SebWindowsConfigForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Controls\AdditionalResources.resx">
<DependentUpon>AdditionalResources.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
<Visible>False</Visible>
<ProductName>Windows Installer 4.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="SEBConfigToolIcon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,564 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SebWindowsConfig.Utilities;
namespace SebWindowsConfig
{
public partial class SebWindowsConfigForm : Form
{
// *************************
// Constants for GUI widgets
// *************************
// Boolean values
const int IntFalse = 0;
const int IntTrue = 1;
// Operating systems
const int IntOSX = 0;
const int IntWin = 1;
const String StringOSX = "OS X";
const String StringWin = "Win";
// URL filter actions
const int IntBlock = 0;
const int IntAllow = 1;
const int IntSkip = 2;
const int IntAnd = 3;
const int IntOr = 4;
const String StringBlock = "block";
const String StringAllow = "allow";
const String StringSkip = "skip";
const String StringAnd = "and";
const String StringOr = "or";
// URL filter table operations
const String StringCollapse = "Collapse";
const String StringExpand = "Expand";
const int IntOperationInsert = 0;
const int IntOperationPaste = 1;
const int IntOperationDelete = 2;
const int IntOperationCut = 3;
const int IntOperationCopy = 4;
const int IntLocationBefore = 0;
const int IntLocationAfter = 1;
const int IntLocationAt = 2;
// Embedded Certificate types
const int IntSSLClientCertificate = 0;
const int IntIdentity = 1;
const int IntCACertificate = 2;
const int IntSSLDebugCertificate = 3;
const String StringSSLServerCertificate = "SSL Certificate";
const String StringIdentity = "Identity";
const String StringCACertificate = "CA Certificate";
const String StringSSLDebugCertificate = "Debug Certificate";
// Proxy Protocol types
const int IntProxyAutoDiscovery = 0;
const int IntProxyAutoConfiguration = 1;
const int IntProxyHTTP = 2;
const int IntProxyHTTPS = 3;
const int IntProxyFTP = 4;
const int IntProxySOCKS = 5;
const int IntProxyRTSP = 6;
const int NumProxyProtocols = 7;
// Captions for table dataGridViewProxyProtocols
const String StringTableCaptionProxyAutoDiscovery = "Auto Proxy Discovery";
const String StringTableCaptionProxyAutoConfiguration = "Automatic Proxy Configuration";
const String StringTableCaptionProxyHTTP = "Web Proxy (HTTP)";
const String StringTableCaptionProxyHTTPS = "Secure Web Proxy (HTTPS)";
const String StringTableCaptionProxyFTP = "FTP Proxy";
const String StringTableCaptionProxySOCKS = "SOCKS Proxy";
const String StringTableCaptionProxyRTSP = "Streaming Proxy (RTSP)";
// Texts for labelProxyServerHost
const String StringServerLabelProxyAutoDiscovery = "";
const String StringServerLabelProxyAutoConfiguration = "";
const String StringServerLabelProxyHTTP = "Web";
const String StringServerLabelProxyHTTPS = "Secure Web";
const String StringServerLabelProxyFTP = "FTP";
const String StringServerLabelProxySOCKS = "SOCKS";
const String StringServerLabelProxyRTSP = "Streaming";
// Permitted and Prohibited Processes table columns (0,1,2,3).
// Permitted Processes: Active, OS, Executable, Title
// Prohibited Processes: Active, OS, Executable, Description
// Process Arguments: ArgumentActive, ArgumentParameter
const int IntColumnProcessActive = 0;
const int IntColumnProcessOS = 1;
const int IntColumnProcessExecutable = 2;
const int IntColumnProcessTitle = 3;
const int IntColumnProcessDescription = 3;
const int IntColumnProcessArgument = 1;
/*
const String StringColumnProcessActive = "Active";
const String StringColumnProcessOS = "OS";
const String StringColumnProcessExecutable = "Executable";
const String StringColumnProcessTitle = "Title";
const String StringColumnProcessDescription = "Description";
const String StringColumnProcessArgument = "Argument";
*/
// URL Filter Rules table columns (0,1,2,3,4).
// Show, Active, Regex, Expression, Action
const int IntColumnURLFilterRuleShow = 0;
const int IntColumnURLFilterRuleActive = 1;
const int IntColumnURLFilterRuleRegex = 2;
const int IntColumnURLFilterRuleExpression = 3;
const int IntColumnURLFilterRuleAction = 4;
/*
const String StringColumnURLFilterRuleShow = "Show";
const String StringColumnURLFilterRuleActive = "Active";
const String StringColumnURLFilterRuleRegex = "Regex";
const String StringColumnURLFilterRuleExpression = "Expression";
const String StringColumnURLFilterRuleAction = "Action";
*/
// Embedded Certificates table columns (0,1).
// Type, Name
const int IntColumnCertificateType = 0;
const int IntColumnCertificateName = 1;
//const String StringColumnCertificateType = "Type";
//const String StringColumnCertificateName = "Name";
// Proxy Protocols table columns (0,1).
// Enable, Type
const int IntColumnProxyProtocolEnable = 0;
const int IntColumnProxyProtocolType = 1;
//const String StringColumnProxyProtocolEnable = "Enable";
//const String StringColumnProxyProtocolType = "Type";
// Bypassed Proxies table column (0).
// DomainHostPort
const int IntColumnDomainHostPort = 0;
//const String StringColumnDomainHostPort = "Domain, Host, Port";
// ********************************
// Global Variables for GUI widgets
// ********************************
// Prevent double events from switching to false process index
static Boolean ignoreCellEventPermittedProcessesActive = false;
static Boolean ignoreCellEventPermittedProcessesOS = false;
static Boolean ignoreCellEventPermittedProcessesExecutable = false;
static Boolean ignoreCellEventPermittedProcessesTitle = false;
static Boolean ignoreCellEventProhibitedProcessesActive = false;
static Boolean ignoreCellEventProhibitedProcessesOS = false;
static Boolean ignoreCellEventProhibitedProcessesExecutable = false;
static Boolean ignoreCellEventProhibitedProcessesDescription = false;
static Boolean ignoreWidgetEventPermittedProcessesActive = false;
static Boolean ignoreWidgetEventPermittedProcessesOS = false;
static Boolean ignoreWidgetEventPermittedProcessesExecutable = false;
static Boolean ignoreWidgetEventPermittedProcessesTitle = false;
static Boolean ignoreWidgetEventProhibitedProcessesActive = false;
static Boolean ignoreWidgetEventProhibitedProcessesOS = false;
static Boolean ignoreWidgetEventProhibitedProcessesExecutable = false;
static Boolean ignoreWidgetEventProhibitedProcessesDescription = false;
// The current SEB configuration file
static String currentDireSebConfigFile;
static String currentFileSebConfigFile;
static String lastPathSebConfigFile;
static String currentPathSebConfigFile;
static bool currentSebConfigFileWasDuplicated = false;
static bool sebConfigPurposeChanged = false;
// Strings for encryption identities (KeyChain, Certificate Store)
//static ArrayList chooseIdentityStringArrayList = new ArrayList();
//static String[] chooseIdentityStringArray = new String[1];
static List<String> StringCryptoIdentity = new List<String>();
static ArrayList certificateReferences = new ArrayList();
static ArrayList certificateSSLReferences = new ArrayList();
// Entries of ListBoxes
//static Byte[] ByteArrayExamKeySalt = new Byte[] {};
static String[] StringCryptoIdentityArray;
static String[] StringSebPurpose = new String[2];
static String[] StringSebMode = new String[2];
static String[] StringBrowserViewMode = new String[2];
static String[] StringWindowWidth = new String[5];
static String[] StringWindowHeight = new String[5];
static String[] StringWindowPositioning = new String[3];
static String[] StringTaskBarHeight = new String[3];
static String[] StringPolicyLinkOpening = new String[3];
static String[] StringPolicyFileUpload = new String[3];
static String[] StringPolicyProxySettings = new String[2];
static String[] StringPolicySebService = new String[3];
static String[] StringFunctionKey = new String[12];
static String[] StringActive = new String[2];
static String[] StringOS = new String[2];
static String[] StringAction = new String[5];
static String[] StringCertificateType = new String[4];
static String[] StringProxyProtocolTableCaption = new String[7];
static String[] StringProxyProtocolServerLabel = new String[7];
static Boolean[] BooleanProxyProtocolEnabled = new Boolean[7];
static String[] KeyProxyProtocolType = new String[7];
static String[] KeyProxyProtocolAttribute = new String[7];
static String[] KeyProxyProtocolEnable = new String[7];
static String[] StringMinMacOSVersion = new String[8];
static String[] StringAllowedDisplaysMaxNumber = new String[3];
// ***********************
// Methods for GUI widgets
// ***********************
// *****************************************************************
// Initialise the global variables for the lists and subdictionaries
// *****************************************************************
private void InitialiseGlobalVariablesForGUIWidgets()
{
SEBSettings. permittedProcessIndex = 0;
SEBSettings. prohibitedProcessIndex = 0;
SEBSettings.embeddedCertificateIndex = 0;
SEBSettings. bypassedProxyIndex = 0;
// Define the strings for the Encryption Identity
StringCryptoIdentity.Add("none");
StringCryptoIdentity.Add("alpha");
StringCryptoIdentity.Add("beta");
StringCryptoIdentity.Add("gamma");
StringCryptoIdentity.Add("delta");
StringCryptoIdentityArray = StringCryptoIdentity.ToArray();
// Define the strings for the SEB purpose
StringSebPurpose[0] = "starting an exam";
StringSebPurpose[1] = "configuring a client";
// Define the strings for the SEB mode
StringSebMode[0] = "use local settings and load the start URL";
StringSebMode[1] = "connect to the SEB server";
// Define the strings for the Browser View Mode
StringBrowserViewMode[0] = "use browser window";
StringBrowserViewMode[1] = "use full screen mode";
// Define the strings for the Window Width
StringWindowWidth[0] = "";
StringWindowWidth[1] = "50%";
StringWindowWidth[2] = "100%";
StringWindowWidth[3] = "800";
StringWindowWidth[4] = "1000";
// Define the strings for the Window Height
StringWindowHeight[0] = "";
StringWindowHeight[1] = "80%";
StringWindowHeight[2] = "100%";
StringWindowHeight[3] = "600";
StringWindowHeight[4] = "800";
// Define the strings for the Window Positioning
StringWindowPositioning[0] = "Left";
StringWindowPositioning[1] = "Center";
StringWindowPositioning[2] = "Right";
// Define the strings for the taskbar Height
StringTaskBarHeight[0] = "40";
StringTaskBarHeight[1] = "60";
StringTaskBarHeight[2] = "80";
// Define the strings for the Link Opening Policy
StringPolicyLinkOpening[0] = "get generally blocked";
StringPolicyLinkOpening[1] = "open in same window";
StringPolicyLinkOpening[2] = "open in new window";
// Define the strings for the File Upload Policy
StringPolicyFileUpload[0] = "manually with file requester";
StringPolicyFileUpload[1] = "by attempting to upload the same file downloaded before";
StringPolicyFileUpload[2] = "by only allowing to upload the same file downloaded before";
// Define the strings for the Proxy Settings Policy
StringPolicyProxySettings[0] = "Use system proxy settings";
StringPolicyProxySettings[1] = "Use SEB proxy settings";
// Define the strings for the SEB Service Policy
StringPolicySebService[0] = "allow to run SEB without service";
StringPolicySebService[1] = "display warning when service is not running";
StringPolicySebService[2] = "allow to use SEB only with service";
// Define the strings for the Function Keys F1, F2, ..., F12
for (int i = 1; i <= 12; i++)
{
StringFunctionKey[i - 1] = "F" + i.ToString();
}
// Define the strings for the Permitted and Prohibited Processes
StringActive[IntFalse] = "false";
StringActive[IntTrue ] = "true";
StringOS[IntOSX] = StringOSX;
StringOS[IntWin] = StringWin;
// Define the strings for the URL Filter Rule Actions
StringAction[IntBlock] = StringBlock;
StringAction[IntAllow] = StringAllow;
StringAction[IntSkip ] = StringSkip;
StringAction[IntAnd ] = StringAnd;
StringAction[IntOr ] = StringOr;
// Define the strings for the Embedded Certificates
StringCertificateType[IntSSLClientCertificate] = StringSSLServerCertificate;
StringCertificateType[IntIdentity] = StringIdentity;
StringCertificateType[IntCACertificate] = StringCACertificate;
StringCertificateType[IntSSLDebugCertificate] = StringSSLDebugCertificate;
// Define the strings for the Proxy Protocol Table Captions
StringProxyProtocolTableCaption[0] = StringTableCaptionProxyAutoDiscovery;
StringProxyProtocolTableCaption[1] = StringTableCaptionProxyAutoConfiguration;
StringProxyProtocolTableCaption[2] = StringTableCaptionProxyHTTP;
StringProxyProtocolTableCaption[3] = StringTableCaptionProxyHTTPS;
StringProxyProtocolTableCaption[4] = StringTableCaptionProxyFTP;
StringProxyProtocolTableCaption[5] = StringTableCaptionProxySOCKS;
StringProxyProtocolTableCaption[6] = StringTableCaptionProxyRTSP;
// Define the strings for the Proxy Protocol Server Labels
StringProxyProtocolServerLabel[0] = StringServerLabelProxyAutoDiscovery;
StringProxyProtocolServerLabel[1] = StringServerLabelProxyAutoConfiguration;
StringProxyProtocolServerLabel[2] = StringServerLabelProxyHTTP;
StringProxyProtocolServerLabel[3] = StringServerLabelProxyHTTPS;
StringProxyProtocolServerLabel[4] = StringServerLabelProxyFTP;
StringProxyProtocolServerLabel[5] = StringServerLabelProxySOCKS;
StringProxyProtocolServerLabel[6] = StringServerLabelProxyRTSP;
// Initialise the booleans for the Proxy Protocols
for (int i = 0; i < NumProxyProtocols; i++)
{
BooleanProxyProtocolEnabled[i] = false;
}
// Define the strings for the Proxy Protocol Types
KeyProxyProtocolType[0] = SEBSettings.KeyAutoDiscovery;
KeyProxyProtocolType[1] = SEBSettings.KeyAutoConfiguration;
KeyProxyProtocolType[2] = SEBSettings.KeyHTTP;
KeyProxyProtocolType[3] = SEBSettings.KeyHTTPS;
KeyProxyProtocolType[4] = SEBSettings.KeyFTP;
KeyProxyProtocolType[5] = SEBSettings.KeySOCKS;
KeyProxyProtocolType[6] = SEBSettings.KeyRTSP;
// Define the strings for the Proxy Protocol Attributes
KeyProxyProtocolAttribute[0] = SEBSettings.KeyEnable;
KeyProxyProtocolAttribute[1] = SEBSettings.KeyPort;
KeyProxyProtocolAttribute[2] = SEBSettings.KeyHost;
KeyProxyProtocolAttribute[3] = SEBSettings.KeyRequires;
KeyProxyProtocolAttribute[4] = SEBSettings.KeyUsername;
KeyProxyProtocolAttribute[5] = SEBSettings.KeyPassword;
// Define the strings for the Proxy Protocol Enables
KeyProxyProtocolEnable[0] = SEBSettings.KeyAutoDiscoveryEnabled;
KeyProxyProtocolEnable[1] = SEBSettings.KeyAutoConfigurationEnabled;
KeyProxyProtocolEnable[2] = SEBSettings.KeyHTTPEnable;
KeyProxyProtocolEnable[3] = SEBSettings.KeyHTTPSEnable;
KeyProxyProtocolEnable[4] = SEBSettings.KeyFTPEnable;
KeyProxyProtocolEnable[5] = SEBSettings.KeySOCKSEnable;
KeyProxyProtocolEnable[6] = SEBSettings.KeyRTSPEnable;
// Define the strings for the Min Mac OS Version
StringMinMacOSVersion[0] = "OS X 10.7 Lion";
StringMinMacOSVersion[1] = "OS X 10.8 Mountain Lion";
StringMinMacOSVersion[2] = "OS X 10.9 Mavericks";
StringMinMacOSVersion[3] = "OS X 10.10 Yosemite";
StringMinMacOSVersion[4] = "OS X 10.11 El Capitan";
StringMinMacOSVersion[5] = "macOS 10.12 Sierra";
StringMinMacOSVersion[6] = "macOS 10.13 High Sierra";
StringMinMacOSVersion[7] = "macOS 10.14 Mojave";
// Define the strings for the Min Mac OS Version
StringAllowedDisplaysMaxNumber[0] = "1";
StringAllowedDisplaysMaxNumber[1] = "2";
StringAllowedDisplaysMaxNumber[2] = "3";
}
// *******************************************************
// Initialise the GUI widgets of this configuration editor
// *******************************************************
private void InitialiseGUIWidgets()
{
// At program start, the local client settings configuration file is loaded
currentDireSebConfigFile = SEBClientInfo.SebClientSettingsAppDataDirectory;
currentFileSebConfigFile = SEBClientInfo.SEB_CLIENT_CONFIG;
StringBuilder sebClientSettingsAppDataBuilder = new StringBuilder(currentDireSebConfigFile).Append(currentFileSebConfigFile);
currentPathSebConfigFile = sebClientSettingsAppDataBuilder.ToString();
openFileDialogSebConfigFile.InitialDirectory = Environment.CurrentDirectory;
saveFileDialogSebConfigFile.InitialDirectory = Environment.CurrentDirectory;
//folderBrowserDialogDownloadDirectoryWin.RootFolder = Environment.SpecialFolder.DesktopDirectory;
//folderBrowserDialogLogDirectoryWin .RootFolder = Environment.SpecialFolder.MyDocuments;
// Assign the fixed entries to the ListBoxes and ComboBoxes
listBoxExitKey1.Items.AddRange(StringFunctionKey);
listBoxExitKey2.Items.AddRange(StringFunctionKey);
listBoxExitKey3.Items.AddRange(StringFunctionKey);
// Assing the list of cryptographic identities/certificates to the ComboBox
ArrayList certificateNames = new ArrayList();
certificateReferences = SEBProtectionController.GetCertificatesAndNames(ref certificateNames);
comboBoxCryptoIdentity.Items.Add("None");
comboBoxCryptoIdentity.Items.AddRange(certificateNames.ToArray());
comboBoxChooseIdentityToEmbed.Items.AddRange(certificateNames.ToArray());
comboBoxChooseIdentityToEmbed.Text = SEBUIStrings.ChooseEmbeddedCert;
ArrayList certificateSSLNames = new ArrayList();
certificateSSLReferences = SEBProtectionController.GetSSLCertificatesAndNames(ref certificateSSLNames);
comboBoxChooseSSLServerCertificate.Items.AddRange(certificateSSLNames.ToArray());
comboBoxChooseSSLServerCertificate.Text = SEBUIStrings.ChooseEmbeddedCert;
comboBoxChooseCACertificate.Items.AddRange(certificateSSLNames.ToArray());
comboBoxChooseCACertificate.Text = SEBUIStrings.ChooseEmbeddedCert;
// At program start, no file has yet been opened, so revert is not possible
buttonRevertToLastOpened.Enabled = false;
comboBoxMainBrowserWindowWidth .Items.AddRange(StringWindowWidth);
comboBoxMainBrowserWindowHeight .Items.AddRange(StringWindowHeight);
listBoxMainBrowserWindowPositioning.Items.AddRange(StringWindowPositioning);
comboBoxNewBrowserWindowWidth .Items.AddRange(StringWindowWidth);
comboBoxNewBrowserWindowHeight .Items.AddRange(StringWindowHeight);
listBoxNewBrowserWindowPositioning .Items.AddRange(StringWindowPositioning);
comboBoxTaskBarHeight.Items.AddRange(StringTaskBarHeight);
listBoxOpenLinksHTML.Items.AddRange(StringPolicyLinkOpening);
listBoxChooseFileToUploadPolicy.Items.AddRange(StringPolicyFileUpload);
listBoxSebServicePolicy .Items.AddRange(StringPolicySebService);
comboBoxMinMacOSVersion.Items.AddRange(StringMinMacOSVersion);
comboBoxAllowedDisplaysMaxNumber.Items.AddRange(StringAllowedDisplaysMaxNumber);
// Initialise the DataGridViews:
// Set "AllowUserToAddRows" to false, to avoid an initial empty first row
// Set "RowHeadersVisible" to false, to avoid an initial empty first column
// Set "FullRowSelect" to true , to select whole row when clicking on a cell
dataGridViewPermittedProcesses.Enabled = false;
dataGridViewPermittedProcesses.ReadOnly = false;
dataGridViewPermittedProcesses.AllowUserToAddRows = false;
dataGridViewPermittedProcesses.RowHeadersVisible = false;
dataGridViewPermittedProcesses.MultiSelect = false;
dataGridViewPermittedProcesses.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewPermittedProcessArguments.Enabled = false;
dataGridViewPermittedProcessArguments.ReadOnly = false;
dataGridViewPermittedProcessArguments.AllowUserToAddRows = false;
dataGridViewPermittedProcessArguments.RowHeadersVisible = false;
dataGridViewPermittedProcessArguments.MultiSelect = false;
dataGridViewPermittedProcessArguments.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewProhibitedProcesses.Enabled = false;
dataGridViewProhibitedProcesses.ReadOnly = false;
dataGridViewProhibitedProcesses.AllowUserToAddRows = false;
dataGridViewProhibitedProcesses.RowHeadersVisible = false;
dataGridViewProhibitedProcesses.MultiSelect = false;
dataGridViewProhibitedProcesses.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewEmbeddedCertificates.Enabled = false;
dataGridViewEmbeddedCertificates.ReadOnly = false;
dataGridViewEmbeddedCertificates.AllowUserToAddRows = false;
dataGridViewEmbeddedCertificates.RowHeadersVisible = false;
dataGridViewEmbeddedCertificates.MultiSelect = false;
dataGridViewEmbeddedCertificates.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewProxyProtocols.Enabled = false;
dataGridViewProxyProtocols.ReadOnly = false;
dataGridViewProxyProtocols.AllowUserToAddRows = false;
dataGridViewProxyProtocols.RowHeadersVisible = false;
dataGridViewProxyProtocols.MultiSelect = false;
dataGridViewProxyProtocols.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewPermittedProcesses.Columns[IntColumnProcessActive ].ValueType = typeof(Boolean);
dataGridViewPermittedProcesses.Columns[IntColumnProcessOS ].ValueType = typeof(String);
dataGridViewPermittedProcesses.Columns[IntColumnProcessExecutable].ValueType = typeof(String);
dataGridViewPermittedProcesses.Columns[IntColumnProcessTitle ].ValueType = typeof(String);
dataGridViewPermittedProcessArguments.Columns[IntColumnProcessActive ].ValueType = typeof(Boolean);
dataGridViewPermittedProcessArguments.Columns[IntColumnProcessArgument].ValueType = typeof(String);
dataGridViewProhibitedProcesses.Columns[IntColumnProcessActive ].ValueType = typeof(Boolean);
dataGridViewProhibitedProcesses.Columns[IntColumnProcessOS ].ValueType = typeof(String);
dataGridViewProhibitedProcesses.Columns[IntColumnProcessExecutable ].ValueType = typeof(String);
dataGridViewProhibitedProcesses.Columns[IntColumnProcessDescription].ValueType = typeof(String);
dataGridViewEmbeddedCertificates.Columns[IntColumnCertificateType].ValueType = typeof(String);
dataGridViewEmbeddedCertificates.Columns[IntColumnCertificateName].ValueType = typeof(String);
dataGridViewProxyProtocols.Columns[IntColumnProxyProtocolEnable].ValueType = typeof(Boolean);
dataGridViewProxyProtocols.Columns[IntColumnProxyProtocolType ].ValueType = typeof(String);
dataGridViewProxyProtocols.Columns[IntColumnProxyProtocolEnable].ReadOnly = false;
dataGridViewProxyProtocols.Columns[IntColumnProxyProtocolType ].ReadOnly = true;
// Assign the column names to the DataGridViews
/*
dataGridViewPermittedProcesses.Columns.Add(StringColumnActive , StringColumnActive);
dataGridViewPermittedProcesses.Columns.Add(StringColumnOS , StringColumnOS);
dataGridViewPermittedProcesses.Columns.Add(StringColumnExecutable, StringColumnExecutable);
dataGridViewPermittedProcesses.Columns.Add(StringColumnTitle , StringColumnTitle);
dataGridViewPermittedProcessArguments.Columns.Add(StringColumnActive , StringColumnActive);
dataGridViewPermittedProcessArguments.Columns.Add(StringColumnArgument, StringColumnArgument);
dataGridViewProhibitedProcesses.Columns.Add(StringColumnActive , StringColumnActive);
dataGridViewProhibitedProcesses.Columns.Add(StringColumnOS , StringColumnOS);
dataGridViewProhibitedProcesses.Columns.Add(StringColumnExecutable , StringColumnExecutable);
dataGridViewProhibitedProcesses.Columns.Add(StringColumnDescription, StringColumnDescription);
dataGridViewURLFilterRules.Columns.Add(StringColumnURLFilterRuleShow , StringColumnURLFilterRuleShow);
dataGridViewURLFilterRules.Columns.Add(StringColumnURLFilterRuleActive , StringColumnURLFilterRuleActive);
dataGridViewURLFilterRules.Columns.Add(StringColumnURLFilterRuleRegex , StringColumnURLFilterRuleRegex);
dataGridViewURLFilterRules.Columns.Add(StringColumnURLFilterRuleExpression, StringColumnURLFilterRuleExpression);
dataGridViewURLFilterRules.Columns.Add(StringColumnURLFilterRuleAction , StringColumnURLFilterRuleAction);
dataGridViewEmbeddedCertificates.Columns.Add(StringColumnCertificateType, StringColumnCertificateType);
dataGridViewEmbeddedCertificates.Columns.Add(StringColumnCertificateName, StringColumnCertificateName);
dataGridViewProxyProtocols.Columns.Add(StringColumnProxyProtocolEnable, StringColumnProxyProtocolEnable);
dataGridViewProxyProtocols.Columns.Add(StringColumnProxyProtocolType , StringColumnProxyProtocolType);
dataGridViewBypassedProxies.Columns.Add(StringColumnDomainHostPort, StringColumnDomainHostPort);
*/
groupBoxPermittedProcess .Enabled = false;
groupBoxProhibitedProcess.Enabled = false;
listBoxPermittedProcessOS .Items.AddRange(StringOS);
listBoxProhibitedProcessOS.Items.AddRange(StringOS);
// Auto-resize the columns and cells
//dataGridViewPermittedProcesses .AutoResizeColumns();
//dataGridViewProhibitedProcesses .AutoResizeColumns();
//dataGridViewURLFilterRules .AutoResizeColumns();
//dataGridViewEmbeddedCertificates.AutoResizeColumns();
//dataGridViewProxyProtocols .AutoResizeColumns();
//dataGridViewBypassedProxies .AutoResizeColumns();
//dataGridViewPermittedProcesses .AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
//dataGridViewProhibitedProcesses .AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
//dataGridViewURLFilterRules .AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
//dataGridViewEmbeddedCertificates.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
//dataGridViewProxyProtocols .AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
//dataGridViewBypassedProxies .AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
} // end of class SebWindowsConfigForm
} // end of namespace SebWindowsConfig

View file

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
//
// SEBWindowsClientForm.cs
// SafeExamBrowser
//
// Copyright (c) 2010-2019 Viktor Tomas, Dirk Bauer, Daniel R. Schneider, Pascal Wyss,
// ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen
// Project concept: Thomas Piendl, Daniel R. Schneider,
// Dirk Bauer, Kai Reuter, Tobias Halbherr, Karsten Burger, Marco Lehre,
// Brigitte Schmucki, Oliver Rahs. French localization: Nicolas Dunand
//
// ``The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is Safe Exam Browser for Windows.
//
// The Initial Developers of the Original Code are Viktor Tomas,
// Dirk Bauer, Daniel R. Schneider, Pascal Wyss.
// Portions created by Viktor Tomas, Dirk Bauer, Daniel R. Schneider, Pascal Wyss
// are Copyright (c) 2010-2019 Viktor Tomas, Dirk Bauer, Daniel R. Schneider,
// Pascal Wyss, ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen. All Rights Reserved.
//
// Contributor(s): ______________________________________.
//
namespace SebWindowsConfig
{
static class SebWindowsConfigProgram
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SebWindowsConfigForm());
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,207 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading;
using Ionic.Zip;
namespace SebWindowsConfig.Utilities
{
public class FileCompressor : IFileCompressor
{
private static readonly string TempDirectory = SEBClientInfo.SebClientSettingsAppDataDirectory + "temp\\";
private static readonly string TempIconFilename = SEBClientInfo.SebClientSettingsAppDataDirectory + "temp\\tempIcon.png";
public static void CleanupTempDirectory()
{
try
{
if (Directory.Exists(TempDirectory))
{
DeleteDirectory(TempDirectory);
Logger.AddInformation("Successfully deleted temporary directory.");
}
}
catch (Exception e)
{
Logger.AddError("Error when trying to delete temporary directory: ", null, e);
}
}
/// <summary>
/// Attempt to fix the issue happening when deleting the TempDirectory (see SEBWIN-49).
/// Source: https://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/1703799#1703799
/// </summary>
private static void DeleteDirectory(string path)
{
foreach (string directory in Directory.GetDirectories(path))
{
DeleteDirectory(directory);
}
try
{
Directory.Delete(path, true);
}
catch (IOException e)
{
Logger.AddWarning(String.Format("Failed to delete {0} with IOException: {1}", path, e.Message), null);
Thread.Sleep(100);
Directory.Delete(path, true);
}
catch (UnauthorizedAccessException e)
{
Logger.AddWarning(String.Format("Failed to delete {0} with UnauthorizedAccessException: {1}", path, e.Message), null);
Thread.Sleep(100);
Directory.Delete(path, true);
}
}
public string CompressAndEncodeFile(string filename)
{
var zip = new ZipFile();
zip.AddFile(filename,"");
var stream = new MemoryStream();
zip.Save(stream);
return base64_encode(stream.ToArray());
}
public string CompressAndEncodeIcon(Icon icon)
{
//Save the file first locally
icon.ToBitmap().Save(TempIconFilename, ImageFormat.Png);
return CompressAndEncodeFile(TempIconFilename);
}
public string CompressAndEncodeFavicon(Uri uri)
{
if (File.Exists(TempIconFilename))
{
File.Delete(TempIconFilename);
}
if (!Directory.Exists(TempDirectory))
{
Directory.CreateDirectory(TempDirectory);
}
var client = new System.Net.WebClient();
client.DownloadFile(
string.Format(@"http://www.google.com/s2/favicons?domain_url={0}", uri.Host),
TempIconFilename);
return CompressAndEncodeFile(TempIconFilename);
}
public string CompressAndEncodeDirectory(string path, out List<string> containingFilenames)
{
var zip = new ZipFile();
zip.AddDirectory(path, "");
var stream = new MemoryStream();
zip.Save(stream);
containingFilenames = zip.Entries.Select(x => x.FileName.Replace(path, "")).ToList();
return base64_encode(stream.ToArray());
}
/// <summary>
/// Compresses the entire specified directory (preserving its relative structure) and returns the data as Base64-encoded string.
/// </summary>
public string CompressAndEncodeEntireDirectory(string path)
{
using (var stream = new MemoryStream())
using (var zip = new ZipFile())
{
var data = default(string);
var directory = new DirectoryInfo(path);
zip.AddDirectory(path, directory.Name);
zip.Save(stream);
data = base64_encode(stream.ToArray());
return data;
}
}
/// <summary>
/// Decodes the given Base64-encoded archive into the specified target directory, overwrites existing files if the overwrite flag
/// is set and returns the absolute paths of all extracted elements.
/// </summary>
public IEnumerable<string> DecodeAndDecompressDirectory(string base64, string targetDirectory, bool overwrite = true)
{
var data = base64_decode(base64);
var paths = new List<string>();
var policy = overwrite ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite;
using (var zipStream = new MemoryStream(data))
using (var zip = ZipFile.Read(zipStream))
{
foreach (var entry in zip.Entries)
{
var path = Path.Combine(targetDirectory, entry.FileName.Replace('/', '\\'));
entry.ExtractExistingFile = policy;
entry.Extract(targetDirectory);
paths.Add(path);
}
}
return paths;
}
/// <summary>
/// Saves the file to a temporary directory and returns the path to the file (without filename)
/// </summary>
/// <param name="base64">the encoded and compressed file content</param>
/// <param name="filename">the filename of the file to save</param>
/// <param name="directoryName">the subdirectory of the tempdir (usually the id of the additional resource</param>
/// <returns></returns>
public string DecompressDecodeAndSaveFile(string base64, string filename, string directoryName)
{
string tempPath = TempDirectory + directoryName + "\\";
if (Directory.Exists(tempPath))
{
return tempPath;
}
Directory.CreateDirectory(tempPath);
var data = base64_decode(base64);
var stream = new MemoryStream(data);
var zip = ZipFile.Read(stream);
zip.ExtractAll(tempPath);
return tempPath;
}
public MemoryStream DeCompressAndDecode(string base64)
{
var data = base64_decode(base64);
var zipStream = new MemoryStream(data);
var zip = ZipFile.Read(zipStream);
var stream = new MemoryStream();
zip.Entries.First().Extract(stream);
return stream;
}
public IEnumerable<string> GetFileList(string base64)
{
var data = base64_decode(base64);
var zipStream = new MemoryStream(data);
var zip = ZipFile.Read(zipStream);
return zip.EntryFileNames;
}
private string base64_encode(byte[] data)
{
if (data == null)
throw new ArgumentNullException("data");
return Convert.ToBase64String(data);
}
private byte[] base64_decode(string encodedData)
{
byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
return encodedDataAsBytes;
}
}
}

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
namespace SebWindowsConfig.Utilities
{
public interface IFileCompressor
{
string CompressAndEncodeFile(string filename);
string CompressAndEncodeIcon(Icon icon);
string CompressAndEncodeFavicon(Uri uri);
string CompressAndEncodeDirectory(string path, out List<string> containingFileNames);
string DecompressDecodeAndSaveFile(string base64, string filename, string subdirectory);
MemoryStream DeCompressAndDecode(string base64);
}
}

View file

@ -0,0 +1,118 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Ionic.Zip;
namespace SebWindowsConfig.Utilities
{
internal class LogCollector
{
private readonly IWin32Window owner;
internal LogCollector(IWin32Window owner)
{
this.owner = owner;
}
internal void Run()
{
var description = "Please select the location where you would like to save the collected log files:";
var password = default(string);
var path = default(string);
using (var dialog = new FolderBrowserDialog { Description = description })
{
if (dialog.ShowDialog(owner) == DialogResult.OK)
{
path = dialog.SelectedPath;
}
}
if (path != default(string))
{
var encrypt = AskUserForDataEncrpytion();
if (!encrypt || (encrypt && TryAskForPassword(out password)))
{
CollectLogFiles(path, password);
}
}
}
private bool AskUserForDataEncrpytion()
{
var message = "Log files can contain sensitive information about you and your computer. Would you like to protect the data with a password?";
var result = MessageBox.Show(owner, message, "Data Protection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return result == DialogResult.Yes;
}
private bool TryAskForPassword(out string password)
{
password = default(string);
using (var dialog = new SebPasswordDialogForm())
{
dialog.Text = "Data Protection";
dialog.LabelText = "Please enter the password to be used to encrypt the data:";
if (dialog.ShowDialog(owner) == DialogResult.OK)
{
password = dialog.txtSEBPassword.Text;
}
}
return password != default(string);
}
private void CollectLogFiles(string outputPath, string password = null)
{
try
{
var zipPath = Path.Combine(outputPath, $"SEB_Logs_{DateTime.Today.ToString("yyyy-MM-dd")}.zip");
var logFiles = new[]
{
SEBClientInfo.SebClientLogFile,
Path.Combine(SEBClientInfo.SebClientSettingsAppDataDirectory, SebWindowsConfigForm.SEB_CONFIG_LOG),
Path.Combine(SEBClientInfo.SebClientSettingsAppDataDirectory, "seb.log"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"SafeExamBrowser\SebWindowsServiceWCF\sebwindowsservice.log")
};
var existingFiles = logFiles.Where(f => File.Exists(f));
var missingFiles = logFiles.Except(existingFiles);
using (var stream = new FileStream(zipPath, FileMode.Create))
using (var zip = new ZipFile())
{
if (password != default(string))
{
zip.Password = password;
}
foreach (var file in existingFiles)
{
zip.AddFile(file, string.Empty);
}
zip.Save(stream);
}
if (missingFiles.Any())
{
var count = $"{existingFiles.Count()} of {logFiles.Count()}";
var missing = $"The following file(s) could not be found:\n\n{String.Join("\n\n", missingFiles)}";
MessageBox.Show(owner, $"{count} log files were collected and saved as '{zipPath}'.\n\n{missing}", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show(owner, $"The log files were successfully collected and saved as '{zipPath}'.", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception e)
{
MessageBox.Show(owner, $"Failed to collect the log files. Reason: {e.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View file

@ -0,0 +1,113 @@
using System;
using System.IO;
using System.Reflection;
namespace SebWindowsConfig.Utilities
{
public class Logger
{
private static readonly object Lock = new object();
private static string LogFilePath { get; set; }
public static void AddError(string message, object eventSource, Exception exception, string details = null)
{
Log(Severity.Error, message, eventSource, exception, details);
}
public static void AddWarning(string message, object eventSource = null, Exception exception = null, string details = null)
{
Log(Severity.Warning, message, eventSource, exception, details);
}
public static void AddInformation(string message, object eventSource = null, Exception exception = null, string details = null)
{
Log(Severity.Information, message, eventSource, exception, details);
}
public static void InitLogger(string logFileDirectory = null, string logFilePath = null)
{
try
{
if (String.IsNullOrEmpty(logFileDirectory))
{
logFileDirectory = SEBClientInfo.SebClientLogFileDirectory;
if (String.IsNullOrEmpty(logFileDirectory))
{
throw new DirectoryNotFoundException();
}
}
if (!Directory.Exists(logFileDirectory))
{
Directory.CreateDirectory(logFileDirectory);
}
if (String.IsNullOrEmpty(logFilePath))
{
logFilePath = SEBClientInfo.SebClientLogFile;
if (String.IsNullOrEmpty(logFilePath))
{
logFilePath = String.Format(@"{0}\{1}", logFileDirectory, SEBClientInfo.SEB_CLIENT_LOG);
}
}
LogFilePath = logFilePath;
}
catch (Exception)
{
LogFilePath = String.Format(@"{0}\{1}\{2}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), SEBClientInfo.MANUFACTURER_LOCAL, SEBClientInfo.SEB_CLIENT_LOG);
}
HandleFileSize();
AddInformation(String.Format("SEB version: {0}", Assembly.GetExecutingAssembly().GetName().Version));
}
private static void Log(Severity severity, string message, object eventSource, Exception exception, string details = null)
{
try
{
lock (Lock)
{
using (var file = new StreamWriter(LogFilePath, true))
{
string eventSourceString = eventSource == null ? "" : string.Format(" ({0})", eventSource);
string exceptionString = exception == null ? "" : string.Format("\n\n Exception: {0} - {1}\n{2}", exception, exception.Message, exception.StackTrace);
string detailsString = details == null || (exception != null && details == exception.Message) ? "" : string.Format("\n\n{0}", details);
file.WriteLine("{0} [{1}]: {2}{3}{4}{5}\n", DateTime.Now.ToLocalTime(), severity, message, eventSourceString, exceptionString, detailsString);
#if DEBUG
Console.WriteLine("{0} [{1}]: {2}{3}{4}{5}\n", DateTime.Now.ToLocalTime(), severity, message, eventSourceString, exceptionString, detailsString);
#endif
}
}
}
catch
{
}
}
private static void HandleFileSize()
{
const int TEN_MB = 10000000;
var logFile = new FileInfo(LogFilePath);
var timestamp = DateTime.Now.Ticks;
var fileName = Path.GetFileNameWithoutExtension(logFile.Name);
var backupFilePath = Path.Combine(logFile.DirectoryName, String.Format("{0}_Backup_{1}.log", fileName, timestamp));
if (logFile.Exists && logFile.Length > TEN_MB)
{
File.Move(LogFilePath, backupFilePath);
}
}
enum Severity
{
Error,
Warning,
Information
}
}
}

View file

@ -0,0 +1,965 @@
//
// PlistCS Property List (plist) serialization and parsing library.
//
// https://github.com/animetrics/PlistCS
//
// Copyright (c) 2011 Animetrics Inc. (marc@animetrics.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
namespace SebWindowsConfig.Utilities
{
public static class Plist
{
private static List<int> offsetTable = new List<int>();
private static List<byte> objectTable = new List<byte>();
private static int refCount;
private static int objRefSize;
private static int offsetByteSize;
private static long offsetTableOffset;
#region Public Functions
public static object readPlist(string path)
{
using (FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return readPlist(f, plistType.Auto);
}
}
public static object readPlistSource(string source)
{
return readPlist(System.Text.Encoding.UTF8.GetBytes(source));
}
public static object readPlist(byte[] data)
{
return readPlist(new MemoryStream(data), plistType.Auto);
}
public static plistType getPlistType(Stream stream)
{
byte[] magicHeader = new byte[8];
stream.Read(magicHeader, 0, 8);
if (BitConverter.ToInt64(magicHeader, 0) == 3472403351741427810)
{
return plistType.Binary;
}
else
{
return plistType.Xml;
}
}
public static object readPlist(Stream stream, plistType type)
{
if (type == plistType.Auto)
{
type = getPlistType(stream);
stream.Seek(0, SeekOrigin.Begin);
}
if (type == plistType.Binary)
{
using (BinaryReader reader = new BinaryReader(stream))
{
byte[] data = reader.ReadBytes((int) reader.BaseStream.Length);
return readBinary(data);
}
}
else
{
XmlDocument xml = new XmlDocument();
xml.XmlResolver = null;
xml.Load(stream);
return readXml(xml);
}
}
public static void writeXml(object value, string path)
{
using (StreamWriter writer = new StreamWriter(path))
{
writer.Write(writeXml(value));
}
}
public static void writeXml(object value, Stream stream)
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(writeXml(value));
}
}
public static string writeXml(object value)
{
using (MemoryStream ms = new MemoryStream())
{
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.Encoding = new System.Text.UTF8Encoding(false);
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Document;
xmlWriterSettings.Indent = true;
using (XmlWriter xmlWriter = XmlWriter.Create(ms, xmlWriterSettings))
{
xmlWriter.WriteStartDocument();
//xmlWriter.WriteComment("DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
xmlWriter.WriteStartElement("plist");
xmlWriter.WriteAttributeString("version", "1.0");
compose(value, xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
return System.Text.Encoding.UTF8.GetString(ms.ToArray());
}
}
}
public static void writeBinary(object value, string path)
{
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create)))
{
writer.Write(writeBinary(value));
}
}
public static void writeBinary(object value, Stream stream)
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(writeBinary(value));
}
}
public static byte[] writeBinary(object value)
{
offsetTable.Clear();
objectTable.Clear();
refCount = 0;
objRefSize = 0;
offsetByteSize = 0;
offsetTableOffset = 0;
//Do not count the root node, subtract by 1
int totalRefs = countObject(value) - 1;
refCount = totalRefs;
objRefSize = RegulateNullBytes(BitConverter.GetBytes(refCount)).Length;
composeBinary(value);
writeBinaryString("bplist00", false);
offsetTableOffset = (long)objectTable.Count;
offsetTable.Add(objectTable.Count - 8);
offsetByteSize = RegulateNullBytes(BitConverter.GetBytes(offsetTable[offsetTable.Count-1])).Length;
List<byte> offsetBytes = new List<byte>();
offsetTable.Reverse();
for (int i = 0; i < offsetTable.Count; i++)
{
offsetTable[i] = objectTable.Count - offsetTable[i];
byte[] buffer = RegulateNullBytes(BitConverter.GetBytes(offsetTable[i]), offsetByteSize);
Array.Reverse(buffer);
offsetBytes.AddRange(buffer);
}
objectTable.AddRange(offsetBytes);
objectTable.AddRange(new byte[6]);
objectTable.Add(Convert.ToByte(offsetByteSize));
objectTable.Add(Convert.ToByte(objRefSize));
var a = BitConverter.GetBytes((long) totalRefs + 1);
Array.Reverse(a);
objectTable.AddRange(a);
objectTable.AddRange(BitConverter.GetBytes((long)0));
a = BitConverter.GetBytes(offsetTableOffset);
Array.Reverse(a);
objectTable.AddRange(a);
return objectTable.ToArray();
}
#endregion
#region Private Functions
private static object readXml(XmlDocument xml)
{
XmlNode rootNode = xml.DocumentElement.ChildNodes[0];
return (Dictionary<string, object>)parse(rootNode);
}
private static object readBinary(byte[] data)
{
offsetTable.Clear();
List<byte> offsetTableBytes = new List<byte>();
objectTable.Clear();
refCount = 0;
objRefSize = 0;
offsetByteSize = 0;
offsetTableOffset = 0;
List<byte> bList = new List<byte>(data);
List<byte> trailer = bList.GetRange(bList.Count - 32, 32);
parseTrailer(trailer);
objectTable = bList.GetRange(0, (int)offsetTableOffset);
offsetTableBytes = bList.GetRange((int)offsetTableOffset, bList.Count - (int)offsetTableOffset - 32);
parseOffsetTable(offsetTableBytes);
return parseBinary(0);
}
private static Dictionary<string, object> parseDictionary(XmlNode node)
{
XmlNodeList children = node.ChildNodes;
if (children.Count % 2 != 0)
{
throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
}
Dictionary<string, object> dict = new Dictionary<string, object>();
for (int i = 0; i < children.Count; i += 2)
{
XmlNode keynode = children[i];
XmlNode valnode = children[i + 1];
if (keynode.Name != "key")
{
throw new ApplicationException("expected a key node");
}
object result = parse(valnode);
if (result != null)
{
dict.Add(keynode.InnerText, result);
}
}
return dict;
}
private static List<object> parseArray(XmlNode node)
{
List<object> array = new List<object>();
foreach (XmlNode child in node.ChildNodes)
{
object result = parse(child);
if (result != null)
{
array.Add(result);
}
}
return array;
}
private static void composeArray(List<object> value, XmlWriter writer)
{
writer.WriteStartElement("array");
foreach (object obj in value)
{
compose(obj, writer);
}
writer.WriteEndElement();
}
private static object parse(XmlNode node)
{
switch (node.Name)
{
case "dict":
return parseDictionary(node);
case "array":
return parseArray(node);
case "string":
return node.InnerText;
case "integer":
// int result;
//int.TryParse(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo, out result);
return Convert.ToInt32(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
case "real":
return Convert.ToDouble(node.InnerText,System.Globalization.NumberFormatInfo.InvariantInfo);
case "false":
return false;
case "true":
return true;
case "null":
return null;
case "date":
return XmlConvert.ToDateTime(node.InnerText, XmlDateTimeSerializationMode.Utc);
case "data":
return Convert.FromBase64String(node.InnerText);
}
throw new ApplicationException(String.Format("Plist Node `{0}' is not supported", node.Name));
}
private static void compose(object value, XmlWriter writer)
{
if (value == null || value is string)
{
writer.WriteElementString("string", value as string);
}
else if (value is int || value is long)
{
writer.WriteElementString("integer", ((int)value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
else if (value is System.Collections.Generic.Dictionary<string, object> ||
value.GetType().ToString().StartsWith("System.Collections.Generic.Dictionary`2[System.String"))
{
//Convert to Dictionary<string, object>
Dictionary<string, object> dic = value as Dictionary<string, object>;
if (dic == null)
{
dic = new Dictionary<string, object>();
IDictionary idic = (IDictionary)value;
foreach (var key in idic.Keys)
{
dic.Add(key.ToString(), idic[key]);
}
}
writeDictionaryValues(dic, writer);
}
else if (value is List<object>)
{
composeArray((List<object>)value, writer);
}
else if (value is byte[])
{
writer.WriteElementString("data", Convert.ToBase64String((Byte[])value));
}
else if (value is float || value is double)
{
writer.WriteElementString("real", ((double)value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
else if (value is DateTime)
{
DateTime time = (DateTime)value;
string theString = XmlConvert.ToString(time, XmlDateTimeSerializationMode.Utc);
writer.WriteElementString("date", theString);//, "yyyy-MM-ddTHH:mm:ssZ"));
}
else if (value is bool)
{
writer.WriteElementString(value.ToString().ToLower(), "");
}
else
{
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
}
}
private static void writeDictionaryValues(Dictionary<string, object> dictionary, XmlWriter writer)
{
writer.WriteStartElement("dict");
foreach (string key in dictionary.Keys)
{
object value = dictionary[key];
writer.WriteElementString("key", key);
compose(value, writer);
}
writer.WriteEndElement();
}
private static int countObject(object value)
{
int count = 0;
switch (value.GetType().ToString())
{
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
Dictionary<string, object> dict = (Dictionary<string, object>)value;
foreach (string key in dict.Keys)
{
count += countObject(dict[key]);
}
count += dict.Keys.Count;
count++;
break;
case "System.Collections.Generic.List`1[System.Object]":
List<object> list = (List<object>)value;
foreach (object obj in list)
{
count += countObject(obj);
}
count++;
break;
default:
count++;
break;
}
return count;
}
private static byte[] writeBinaryDictionary(Dictionary<string, object> dictionary)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
List<int> refs = new List<int>();
for (int i = dictionary.Count - 1; i >= 0; i--)
{
var o = new object[dictionary.Count];
dictionary.Values.CopyTo(o, 0);
composeBinary(o[i]);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
for (int i = dictionary.Count - 1; i >= 0; i--)
{
var o = new string[dictionary.Count];
dictionary.Keys.CopyTo(o, 0);
composeBinary(o[i]);//);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
if (dictionary.Count < 15)
{
header.Add(Convert.ToByte(0xD0 | Convert.ToByte(dictionary.Count)));
}
else
{
header.Add(0xD0 | 0xf);
header.AddRange(writeBinaryInteger(dictionary.Count, false));
}
foreach (int val in refs)
{
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
Array.Reverse(refBuffer);
buffer.InsertRange(0, refBuffer);
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] composeBinaryArray(List<object> objects)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
List<int> refs = new List<int>();
for (int i = objects.Count - 1; i >= 0; i--)
{
composeBinary(objects[i]);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
if (objects.Count < 15)
{
header.Add(Convert.ToByte(0xA0 | Convert.ToByte(objects.Count)));
}
else
{
header.Add(0xA0 | 0xf);
header.AddRange(writeBinaryInteger(objects.Count, false));
}
foreach (int val in refs)
{
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
Array.Reverse(refBuffer);
buffer.InsertRange(0, refBuffer);
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] composeBinary(object obj)
{
byte[] value;
switch (obj.GetType().ToString())
{
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
value = writeBinaryDictionary((Dictionary<string, object>)obj);
return value;
case "System.Collections.Generic.List`1[System.Object]":
value = composeBinaryArray((List<object>)obj);
return value;
case "System.Byte[]":
value = writeBinaryByteArray((byte[])obj);
return value;
case "System.Double":
value = writeBinaryDouble((double)obj);
return value;
case "System.Int32":
value = writeBinaryInteger((int)obj, true);
return value;
case "System.String":
value = writeBinaryString((string)obj, true);
return value;
case "System.DateTime":
value = writeBinaryDate((DateTime)obj);
return value;
case "System.Boolean":
value = writeBinaryBool((bool)obj);
return value;
default:
return new byte[0];
}
}
public static byte[] writeBinaryDate(DateTime obj)
{
List<byte> buffer =new List<byte>(RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)), 8));
buffer.Reverse();
buffer.Insert(0, 0x33);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
public static byte[] writeBinaryBool(bool obj)
{
List<byte> buffer = new List<byte>(new byte[1] { (bool)obj ? (byte)9 : (byte)8 });
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryInteger(int value, bool write)
{
List<byte> buffer = new List<byte>(BitConverter.GetBytes((long) value));
buffer =new List<byte>(RegulateNullBytes(buffer.ToArray()));
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
buffer.Add(0);
int header = 0x10 | (int)(Math.Log(buffer.Count) / Math.Log(2));
buffer.Reverse();
buffer.Insert(0, Convert.ToByte(header));
if (write)
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryDouble(double value)
{
List<byte> buffer =new List<byte>(RegulateNullBytes(BitConverter.GetBytes(value), 4));
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
buffer.Add(0);
int header = 0x20 | (int)(Math.Log(buffer.Count) / Math.Log(2));
buffer.Reverse();
buffer.Insert(0, Convert.ToByte(header));
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryByteArray(byte[] value)
{
List<byte> buffer = new List<byte>(value);
List<byte> header = new List<byte>();
if (value.Length < 15)
{
header.Add(Convert.ToByte(0x40 | Convert.ToByte(value.Length)));
}
else
{
header.Add(0x40 | 0xf);
header.AddRange(writeBinaryInteger(buffer.Count, false));
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryString(string value, bool head)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
foreach (char chr in value.ToCharArray())
buffer.Add(Convert.ToByte(chr));
if (head)
{
if (value.Length < 15)
{
header.Add(Convert.ToByte(0x50 | Convert.ToByte(value.Length)));
}
else
{
header.Add(0x50 | 0xf);
header.AddRange(writeBinaryInteger(buffer.Count, false));
}
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] RegulateNullBytes(byte[] value)
{
return RegulateNullBytes(value, 1);
}
private static byte[] RegulateNullBytes(byte[] value, int minBytes)
{
Array.Reverse(value);
List<byte> bytes = new List<byte>(value);
for (int i = 0; i < bytes.Count; i++)
{
if (bytes[i] == 0 && bytes.Count > minBytes)
{
bytes.Remove(bytes[i]);
i--;
}
else
break;
}
if (bytes.Count < minBytes)
{
int dist = minBytes - bytes.Count;
for (int i = 0; i < dist; i++)
bytes.Insert(0, 0);
}
value = bytes.ToArray();
Array.Reverse(value);
return value;
}
private static void parseTrailer(List<byte> trailer)
{
offsetByteSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(6, 1).ToArray(), 4), 0);
objRefSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(7, 1).ToArray(), 4), 0);
byte[] refCountBytes = trailer.GetRange(12, 4).ToArray();
Array.Reverse(refCountBytes);
refCount = BitConverter.ToInt32(refCountBytes, 0);
byte[] offsetTableOffsetBytes = trailer.GetRange(24, 8).ToArray();
Array.Reverse(offsetTableOffsetBytes);
offsetTableOffset = BitConverter.ToInt64(offsetTableOffsetBytes, 0);
}
private static void parseOffsetTable(List<byte> offsetTableBytes)
{
for (int i = 0; i < offsetTableBytes.Count; i += offsetByteSize)
{
byte[] buffer = offsetTableBytes.GetRange(i, offsetByteSize).ToArray();
Array.Reverse(buffer);
offsetTable.Add(BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0));
}
}
private static object parseBinaryDictionary(int objRef)
{
Dictionary<string, object> buffer = new Dictionary<string, object>();
List<int> refs = new List<int>();
int refCount = 0;
byte dictByte = objectTable[offsetTable[objRef]];
int refStartPosition;
refCount = getCount(offsetTable[objRef], out refStartPosition);
if (refCount < 15)
refStartPosition = offsetTable[objRef] + 1;
else
refStartPosition = offsetTable[objRef] + 2 + RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
for (int i = refStartPosition; i < refStartPosition + refCount * 2 * objRefSize; i += objRefSize)
{
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
Array.Reverse(refBuffer);
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
}
for (int i = 0; i < refCount; i++)
{
buffer.Add((string)parseBinary(refs[i]), parseBinary(refs[i + refCount]));
}
return buffer;
}
private static object parseBinaryArray(int objRef)
{
List<object> buffer = new List<object>();
List<int> refs = new List<int>();
int refCount = 0;
byte arrayByte = objectTable[offsetTable[objRef]];
int refStartPosition;
refCount = getCount(offsetTable[objRef], out refStartPosition);
if (refCount < 15)
refStartPosition = offsetTable[objRef] + 1;
else
//The following integer has a header aswell so we increase the refStartPosition by two to account for that.
refStartPosition = offsetTable[objRef] + 2 + RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
for (int i = refStartPosition; i < refStartPosition + refCount * objRefSize; i += objRefSize)
{
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
Array.Reverse(refBuffer);
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
}
for (int i = 0; i < refCount; i++)
{
buffer.Add(parseBinary(refs[i]));
}
return buffer;
}
private static int getCount(int bytePosition, out int newBytePosition)
{
byte headerByte = objectTable[bytePosition];
byte headerByteTrail = Convert.ToByte(headerByte & 0xf);
int count;
if (headerByteTrail < 15)
{
count = headerByteTrail;
newBytePosition = bytePosition + 1;
}
else
count = (int)parseBinaryInt(bytePosition + 1, out newBytePosition);
return count;
}
private static object parseBinary(int objRef)
{
byte header = objectTable[offsetTable[objRef]];
switch (header & 0xF0)
{
case 0:
{
//If the byte is
//0 return null
//9 return true
//8 return false
return (objectTable[offsetTable[objRef]] == 0) ? (object)null : ((objectTable[offsetTable[objRef]] == 9) ? true : false);
}
case 0x10:
{
return parseBinaryInt(offsetTable[objRef]);
}
case 0x20:
{
return parseBinaryReal(offsetTable[objRef]);
}
case 0x30:
{
return parseBinaryDate(offsetTable[objRef]);
}
case 0x40:
{
return parseBinaryByteArray(offsetTable[objRef]);
}
case 0x50://String ASCII
{
return parseBinaryAsciiString(offsetTable[objRef]);
}
case 0x60://String Unicode
{
return parseBinaryUnicodeString(offsetTable[objRef]);
}
case 0xD0:
{
return parseBinaryDictionary(objRef);
}
case 0xA0:
{
return parseBinaryArray(objRef);
}
}
throw new Exception("This type is not supported");
}
public static object parseBinaryDate(int headerPosition)
{
byte[] buffer = objectTable.GetRange(headerPosition + 1, 8).ToArray();
Array.Reverse(buffer);
double appleTime = BitConverter.ToDouble(buffer, 0);
DateTime result = PlistDateConverter.ConvertFromAppleTimeStamp(appleTime);
return result;
}
private static object parseBinaryInt(int headerPosition)
{
int output;
return parseBinaryInt(headerPosition, out output);
}
private static object parseBinaryInt(int headerPosition, out int newHeaderPosition)
{
byte header = objectTable[headerPosition];
int byteCount = (int)Math.Pow(2, header & 0xf);
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
Array.Reverse(buffer);
//Add one to account for the header byte
newHeaderPosition = headerPosition + byteCount + 1;
return BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0);
}
private static object parseBinaryReal(int headerPosition)
{
byte header = objectTable[headerPosition];
int byteCount = (int)Math.Pow(2, header & 0xf);
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
Array.Reverse(buffer);
return BitConverter.ToDouble(RegulateNullBytes(buffer, 8), 0);
}
private static object parseBinaryAsciiString(int headerPosition)
{
int charStartPosition;
int charCount = getCount(headerPosition, out charStartPosition);
var buffer = objectTable.GetRange(charStartPosition, charCount);
return buffer.Count > 0 ? Encoding.ASCII.GetString(buffer.ToArray()) : string.Empty;
}
private static object parseBinaryUnicodeString(int headerPosition)
{
int charStartPosition;
int charCount = getCount(headerPosition, out charStartPosition);
charCount = charCount * 2;
byte[] buffer = new byte[charCount];
byte one, two;
for (int i = 0; i < charCount; i+=2)
{
one = objectTable.GetRange(charStartPosition+i,1)[0];
two = objectTable.GetRange(charStartPosition + i+1, 1)[0];
if (BitConverter.IsLittleEndian)
{
buffer[i] = two;
buffer[i + 1] = one;
}
else
{
buffer[i] = one;
buffer[i + 1] = two;
}
}
return Encoding.Unicode.GetString(buffer);
}
private static object parseBinaryByteArray(int headerPosition)
{
int byteStartPosition;
int byteCount = getCount(headerPosition, out byteStartPosition);
return objectTable.GetRange(byteStartPosition, byteCount).ToArray();
}
#endregion
}
public enum plistType
{
Auto, Binary, Xml
}
public static class PlistDateConverter
{
public static long timeDifference = 978307200;
public static long GetAppleTime(long unixTime)
{
return unixTime - timeDifference;
}
public static long GetUnixTime(long appleTime)
{
return appleTime + timeDifference;
}
public static DateTime ConvertFromAppleTimeStamp(double timestamp)
{
DateTime origin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
public static double ConvertToAppleTimeStamp(DateTime date)
{
DateTime begin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
TimeSpan diff = date - begin;
return Math.Floor(diff.TotalSeconds);
}
}
}

View file

@ -0,0 +1,461 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
//
// SEBClientInfo.cs
// SafeExamBrowser
//
// Copyright (c) 2010-2019 Viktor Tomas, Dirk Bauer, Daniel R. Schneider, Pascal Wyss,
// ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen
// Project concept: Thomas Piendl, Daniel R. Schneider,
// Dirk Bauer, Kai Reuter, Tobias Halbherr, Karsten Burger, Marco Lehre,
// Brigitte Schmucki, Oliver Rahs. French localization: Nicolas Dunand
//
// ``The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is Safe Exam Browser for Windows.
//
// The Initial Developers of the Original Code are Viktor Tomas,
// Dirk Bauer, Daniel R. Schneider, Pascal Wyss.
// Portions created by Viktor Tomas, Dirk Bauer, Daniel R. Schneider, Pascal Wyss
// are Copyright (c) 2010-2019 Viktor Tomas, Dirk Bauer, Daniel R. Schneider,
// Pascal Wyss, ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen. All Rights Reserved.
//
// Contributor(s): ______________________________________.
//
namespace SebWindowsConfig.Utilities
{
public enum chooseFileToUploadPolicies
{
manuallyWithFileRequester = 0,
attemptUploadSameFileDownloadedBefore = 1,
onlyAllowUploadSameFileDownloadedBefore = 2
};
public enum newBrowserWindowPolicies
{
getGenerallyBlocked = 0,
openInSameWindow = 1,
openInNewWindow = 2
};
public enum sebServicePolicies
{
ignoreService = 0,
indicateMissingService = 1,
forceSebService = 2
};
public enum browserViewModes
{
browserViewModeWindow = 0,
browserViewModeFullscreen = 1
};
// MAC
public enum sebPurposePolicies
{
sebPurposePolicyStartingExam = 0,
sebPurposePolicyConfiguringClient = 1
};
public enum URLFilterRuleActions
{
block = 0,
allow = 1,
ignore = 2,
unknown = 3
};
public enum SEBMinMacOSVersion
{
SEBMinOSX10_7 = 0,
SEBMinOSX10_8 = 1,
SEBMinOSX10_9 = 2,
SEBMinOSX10_10 = 3,
SEBMinOSX10_11 = 4,
SEBMinMacOS10_12 = 5,
SEBMinMacOS10_13 = 6,
SEBMinMacOS10_14 = 7
};
public class SEBClientInfo
{
#region Imports
[DllImport("kernel32.Dll")]
public static extern short GetVersionEx(ref OSVERSIONINFO o);
#endregion
// Socket protocol
//static int ai_family = AF_INET;
//static int ai_socktype = SOCK_STREAM;
//static int ai_protocol = IPPROTO_TCP;
#region Constants
// Name and location of SEB configuration files and logfiles
public const string SEB_CLIENT_CONFIG = "SebClientSettings.seb";
public const string SEB_CLIENT_LOG = "SebClient.log";
private const string XUL_RUNNER_CONFIG = "config.json";
public const string SEB_SHORTNAME = "SEB";
public const string XUL_RUNNER = "firefox.exe";
private const string XUL_RUNNER_INI = "seb.ini";
// Application path contains [MANUFACTURER]\[PRODUCT_NAME]
// (see also "SebWindowsPackageSetup" Project in MS Visual Studio 10)
public const string MANUFACTURER_LOCAL = "SafeExamBrowser";
//private const string MANUFACTURER = "ETH Zuerich";
public const string PRODUCT_NAME = "SafeExamBrowser";
public const string SEB_SERVICE_DIRECTORY = "SebWindowsServiceWCF";
public const string SEB_BROWSER_DIRECTORY = "SebWindowsBrowser";
private const string XUL_RUNNER_DIRECTORY = "xulrunner";
private const string XUL_SEB_DIRECTORY = "xul_seb";
public const string FILENAME_SEB = "SafeExamBrowser.exe";
public const string FILENAME_SEBCONFIGTOOL = "SEBConfigTool.exe";
public const string FILENAME_SEBSERVICE = "SebWindowsServiceWCF.exe";
public const string FILENAME_DLL_FLECK = "Fleck.dll";
public const string FILENAME_DLL_ICONLIB = "IconLib.dll";
public const string FILENAME_DLL_IONICZIP = "Ionic.Zip.dll";
public const string FILENAME_DLL_METRO = "MetroFramework.dll";
public const string FILENAME_DLL_NAUDIO = "NAudio.dll";
public const string FILENAME_DLL_NEWTONSOFTJSON = "Newtonsoft.Json.dll";
public const string FILENAME_DLL_SERVICECONTRACTS = "SEBWindowsServiceContracts.dll";
public const string BROWSER_USERAGENT_DESKTOP = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0";
public const string BROWSER_USERAGENT_TOUCH = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0; Touch) Gecko/20100101 Firefox/52.0";
public const string BROWSER_USERAGENT_TOUCH_IPAD = "Mozilla/5.0 (iPad; CPU OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.3 Mobile/15E216 Safari/605.1.15";
public const string BROWSER_USERAGENT_SEB = "SEB";
public const string END_OF_STRING_KEYWORD = "---SEB---";
private const string DEFAULT_USERNAME = "";
private const string DEFAULT_HOSTNAME = "localhost";
private const string DEFAULT_HOST_IP_ADDRESS = "127.0.0.1";
private const int DEFAULT_PORTNUMBER = 57016;
public const string DEFAULT_KEY = "Di𝈭l𝈖Ch𝈒ah𝉇t𝈁a𝉈Hai1972";
private const int DEFAULT_SEND_INTERVAL = 100;
private const int DEFAULT_RECV_TIMEOUT = 100;
private const int DEFAULT_NUM_MESSAGES = 3;
public const string SEB_NEW_DESKTOP_NAME = "SEBDesktop";
public const string SEB_WINDOWS_SERVICE_NAME = "SebWindowsService";
#endregion
#region Public Properties
public static bool ExplorerShellWasKilled { get; set; }
public static bool IsNewOS { get; set; }
public static bool examMode = false;
// SEB Client Socket properties
public static char[] UserNameRegistryFlags { get; set; }
public static char[] RegistryFlags { get; set; }
public static string HostName { get; set; }
public static string HostIpAddress { get; set; }
public static string UserName { get; set; }
public static char[] UserSid { get; set; }
public static int PortNumber { get; set; }
public static int SendInterval { get; set; }
public static int RecvTimeout { get; set; }
public static int NumMessages { get; set; }
public static int MessageNr { get; set; }
public static string DesktopName { get; set; }
// SEB Client Directories properties
public static string ApplicationExecutableDirectory { get; set; }
public static string ProgramFilesX86Directory { get; set; }
public static bool LogFileDesiredMsgHook { get; set; }
public static bool LogFileDesiredSebClient { get; set; }
public static string SebClientLogFileDirectory { get; set; }
public static string SebClientDirectory { get; set; }
public static string SebClientLogFile { get; set; }
public static string SebClientSettingsProgramDataDirectory { get; set; }
public static string SebClientSettingsAppDataDirectory { get; set; }
public static string XulRunnerAdditionalDictionariesDirectory { get; set; }
public static string XulRunnerDirectory { get; set; }
public static string XulSebDirectory { get; set; }
public static string SebClientSettingsProgramDataFile;
public static string SebClientSettingsAppDataFile;
public static string XulRunnerConfigFileDirectory { get; set; }
public static string XulRunnerConfigFile;
public static string XulRunnerExePath;
public static string XulRunnerSebIniPath;
public static string XulRunnerParameter;
//public static string XulRunnerFlashContainerState { get; set; }
public static string ExamUrl { get; set; }
public static string QuitPassword { get; set; }
public static string QuitHashcode { get; set; }
//public static Dictionary<string, object> sebSettings = new Dictionary<string, object>();
public static string LoadingSettingsFileName = "";
public static float scaleFactor = 1;
public static int appChooserHeight = 132;
#endregion
#region Structures
/// <summary>
/// Stores windows version info.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct OSVERSIONINFO
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szCSDVersion;
}
#endregion
//public static SEBClientConfig sebClientConfig;
public static Dictionary<string, object> getSebSetting(string key)
{
object sebSetting = null;
try
{
sebSetting = SEBSettings.settingsCurrent[key];
}
catch
{
sebSetting = null;
}
if (sebSetting != null)
return SEBSettings.settingsCurrent;
else
return SEBSettings.settingsDefault;
}
/// <summary>
/// Sets user, host info, send-recv interval, recv timeout, Logger and read SebClient configuration.
/// </summary>
/// <returns></returns>
public static bool SetSebClientConfiguration()
{
bool setSebClientConfiguration = false;
// Initialise socket properties
IsNewOS = false;
ExplorerShellWasKilled = false;
UserNameRegistryFlags = new char[100];
RegistryFlags = new char[50];
UserSid = new char[512];
UserName = DEFAULT_USERNAME;
HostName = DEFAULT_HOSTNAME;
HostIpAddress = DEFAULT_HOST_IP_ADDRESS;
PortNumber = DEFAULT_PORTNUMBER;
SendInterval = DEFAULT_SEND_INTERVAL;
RecvTimeout = DEFAULT_RECV_TIMEOUT;
NumMessages = DEFAULT_NUM_MESSAGES;
//Sets paths to files SEB has to save or read from the file system
SetSebPaths();
byte[] sebClientSettings = null;
// Create a string builder for a temporary log (until we can write it with the Logger)
StringBuilder tempLogStringBuilder = new StringBuilder();
// Try to read the SebClientSettigs.seb file from the program data directory
try
{
sebClientSettings = File.ReadAllBytes(SebClientSettingsProgramDataFile);
}
catch (Exception streamReadException)
{
// Write error into string with temporary log string builder
tempLogStringBuilder.Append("Could not load SebClientSettigs.seb from the Program Data directory").Append(streamReadException == null ? null : streamReadException.GetType().ToString()).Append(streamReadException.Message);
}
if (sebClientSettings == null)
{
// Try to read the SebClientSettigs.seb file from the local application data directory
try
{
sebClientSettings = File.ReadAllBytes(SebClientSettingsAppDataFile);
}
catch (Exception streamReadException)
{
// Write error into string with temporary log string builder
tempLogStringBuilder.Append("Could not load SebClientSettigs.seb from the Roaming Application Data directory. ").Append(streamReadException == null ? null : streamReadException.GetType().ToString()).Append(streamReadException.Message);
}
}
// Store the decrypted configuration settings.
if (!SEBSettings.StoreDecryptedSebClientSettings(sebClientSettings))
return false;
// Initialise Logger, if enabled
InitializeLogger();
// Save the temporary log string into the log
Logger.AddError(tempLogStringBuilder.ToString(), null, null);
// Set username
UserName = Environment.UserName;
setSebClientConfiguration = true;
// Write settings into log
StringBuilder userInfo =
new StringBuilder ("User Name: " ).Append(UserName)
.Append(" Host Name: " ).Append(HostName)
.Append(" Port Number: " ).Append(PortNumber)
.Append(" Send Interval: " ).Append(SendInterval)
.Append(" Recv Timeout: " ).Append(RecvTimeout)
.Append(" Num Messages: " ).Append(NumMessages)
.Append(" SebClientConfigFileDirectory: ").Append(SebClientSettingsAppDataDirectory)
.Append(" SebClientConfigFile: " ).Append(SebClientSettingsAppDataFile);
Logger.AddInformation(userInfo.ToString(), null, null);
return setSebClientConfiguration;
}
/// <summary>
/// Initialise Logger if it's enabled.
/// </summary>
public static void InitializeLogger()
{
if ((Boolean)getSebSetting(SEBSettings.KeyEnableLogging)[SEBSettings.KeyEnableLogging])
{
string logDirectory = (string)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyLogDirectoryWin);
if (!String.IsNullOrEmpty(logDirectory))
{
// Expand environment variables in log file path
SebClientLogFileDirectory = Environment.ExpandEnvironmentVariables(logDirectory);
SebClientLogFile = String.Format(@"{0}\{1}", SebClientLogFileDirectory, SEB_CLIENT_LOG);
}
else
{
SEBClientInfo.SetDefaultClientLogFile();
}
Logger.InitLogger(SEBClientInfo.SebClientLogFileDirectory, null);
}
}
/// <summary>
/// Sets paths to files SEB has to save or read from the file system.
/// </summary>
public static void SetSebPaths()
{
// Get the path of the directory the application executable lies in
ApplicationExecutableDirectory = Path.GetDirectoryName(Application.ExecutablePath);
// Get the path of the "Program Files X86" directory.
ProgramFilesX86Directory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
// Get the path of the "Program Data" and "Local Application Data" directory.
string programDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); //GetEnvironmentVariable("PROGRAMMDATA");
string appDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
/// Get paths for the two possible locations of the SebClientSettings.seb file
///
// In the program data directory (for managed systems, only an administrator can write in this directory):
// If there is a SebClientSettigs.seb file, then this has priority and is used by the SEB client, another
// SebClientSettigs.seb file in the local app data folder is ignored then and the SEB client cannot be
// reconfigured by opening a .seb file saved for configuring a client
StringBuilder sebClientSettingsProgramDataDirectoryBuilder = new StringBuilder(programDataDirectory).Append("\\").Append(MANUFACTURER_LOCAL).Append("\\"); //.Append(PRODUCT_NAME).Append("\\");
SebClientSettingsProgramDataDirectory = sebClientSettingsProgramDataDirectoryBuilder.ToString();
// In the local application data directory (for unmanaged systems like student computers, user can write in this directory):
// A SebClientSettigs.seb file in this directory can be created or replaced by opening a .seb file saved for configuring a client
StringBuilder sebClientSettingsAppDataDirectoryBuilder = new StringBuilder(appDataDirectory).Append("\\").Append(MANUFACTURER_LOCAL).Append("\\"); //.Append(PRODUCT_NAME).Append("\\");
SebClientSettingsAppDataDirectory = sebClientSettingsAppDataDirectoryBuilder.ToString();
// Set the location of the SebWindowsClientDirectory
StringBuilder sebClientDirectoryBuilder = new StringBuilder(ProgramFilesX86Directory).Append("\\").Append(PRODUCT_NAME).Append("\\");
SebClientDirectory = sebClientDirectoryBuilder.ToString();
// The directory into which additional dictionaries are extracted.
XulRunnerAdditionalDictionariesDirectory = Path.Combine(SebClientSettingsAppDataDirectory, "Dictionaries");
// Set the location of the XulRunnerDirectory
//StringBuilder xulRunnerDirectoryBuilder = new StringBuilder(SebClientDirectory).Append(XUL_RUNNER_DIRECTORY).Append("\\");
//XulRunnerDirectory = xulRunnerDirectoryBuilder.ToString();
StringBuilder xulRunnerDirectoryBuilder = new StringBuilder(SEB_BROWSER_DIRECTORY).Append("\\").Append(XUL_RUNNER_DIRECTORY).Append("\\");
XulRunnerDirectory = xulRunnerDirectoryBuilder.ToString();
// Set the location of the XulSebDirectory
//StringBuilder xulSebDirectoryBuilder = new StringBuilder(SebClientDirectory).Append(XUL_SEB_DIRECTORY).Append("\\");
//XulSebDirectory = xulSebDirectoryBuilder.ToString();
StringBuilder xulSebDirectoryBuilder = new StringBuilder(SEB_BROWSER_DIRECTORY).Append("\\").Append(XUL_SEB_DIRECTORY).Append("\\");
XulSebDirectory = xulSebDirectoryBuilder.ToString();
// Set the location of the XulRunnerExePath
//StringBuilder xulRunnerExePathBuilder = new StringBuilder("\"").Append(XulRunnerDirectory).Append(XUL_RUNNER).Append("\"");
//XulRunnerExePath = xulRunnerExePathBuilder.ToString();
StringBuilder xulRunnerExePathBuilder = new StringBuilder(XulRunnerDirectory).Append(XUL_RUNNER); //.Append("\"");
XulRunnerExePath = xulRunnerExePathBuilder.ToString();
// Set the location of the seb.ini
StringBuilder xulRunnerSebIniPathBuilder = new StringBuilder(XulSebDirectory).Append(XUL_RUNNER_INI); //.Append("\"");
XulRunnerSebIniPath = xulRunnerSebIniPathBuilder.ToString();
// Get the two possible paths of the SebClientSettings.seb file
StringBuilder sebClientSettingsProgramDataBuilder = new StringBuilder(SebClientSettingsProgramDataDirectory).Append(SEB_CLIENT_CONFIG);
SebClientSettingsProgramDataFile = sebClientSettingsProgramDataBuilder.ToString();
StringBuilder sebClientSettingsAppDataBuilder = new StringBuilder(SebClientSettingsAppDataDirectory).Append(SEB_CLIENT_CONFIG);
SebClientSettingsAppDataFile = sebClientSettingsAppDataBuilder.ToString();
// Set the default location of the SebClientLogFileDirectory
SetDefaultClientLogFile();
}
/// <summary>
/// Set the default location of the SebClientLogFileDirectory.
/// </summary>
public static void SetDefaultClientLogFile()
{
StringBuilder SebClientLogFileDirectoryBuilder = new StringBuilder(SebClientSettingsAppDataDirectory); //.Append("\\").Append(MANUFACTURER_LOCAL).Append("\\");
SebClientLogFileDirectory = SebClientLogFileDirectoryBuilder.ToString();
// Set the path of the SebClient.log file
StringBuilder sebClientLogFileBuilder = new StringBuilder(SebClientLogFileDirectory).Append(SEB_CLIENT_LOG);
SebClientLogFile = sebClientLogFileBuilder.ToString();
}
public static bool CreateNewDesktopOldValue { get; set; }
public static string ContractEnvironmentVariables(string path)
{
path = Path.GetFullPath(path);
DictionaryEntry currentEntry = new DictionaryEntry("", "");
foreach (object key in Environment.GetEnvironmentVariables().Keys)
{
string value = (string)Environment.GetEnvironmentVariables()[key];
if (path.ToUpperInvariant().Contains(value.ToUpperInvariant()) && value.Length > ((string)currentEntry.Value).Length)
{
currentEntry.Key = (string)key;
currentEntry.Value = value;
}
}
return path.Replace((string)currentEntry.Value, "%" + (string)currentEntry.Key + "%");
}
}
}

View file

@ -0,0 +1,897 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows.Forms;
using DictObj = System.Collections.Generic.Dictionary<string, object>;
//
// SEBConfigFileManager.cs
// SafeExamBrowser
//
// Copyright (c) 2010-2019 Daniel R. Schneider,
// ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen
// Project concept: Thomas Piendl, Daniel R. Schneider,
// Dirk Bauer, Kai Reuter, Tobias Halbherr, Karsten Burger, Marco Lehre,
// Brigitte Schmucki, Oliver Rahs. French localization: Nicolas Dunand
//
// ``The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is Safe Exam Browser for Windows.
//
// The Initial Developer of the Original Code is Daniel R. Schneider.
// Portions created by Daniel R. Schneider
// are Copyright (c) 2010-2019 Daniel R. Schneider,
// ETH Zurich, Educational Development and Technology (LET),
// based on the original idea of Safe Exam Browser
// by Stefan Schneider, University of Giessen. All Rights Reserved.
//
// Contributor(s): ______________________________________.
//
namespace SebWindowsConfig.Utilities
{
public class SEBConfigFileManager
{
public static SebPasswordDialogForm sebPasswordDialogForm;
// Prefixes
private const int PREFIX_LENGTH = 4;
private const int MULTIPART_LENGTH = 8;
private const int CUSTOMHEADER_LENGTH = 4;
private const string PUBLIC_KEY_HASH_MODE = "pkhs";
private const string PUBLIC_SYMMETRIC_KEY_MODE = "phsk";
private const string PASSWORD_MODE = "pswd";
private const string PLAIN_DATA_MODE = "plnd";
private const string PASSWORD_CONFIGURING_CLIENT_MODE = "pwcc";
private const string UNENCRYPTED_MODE = "<?xm";
private const string MULTIPART_MODE = "mphd";
private const string CUSTOM_HEADER_MODE = "cmhd";
// Public key hash identifier length
private const int PUBLIC_KEY_HASH_LENGTH = 20;
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Decrypt and deserialize SEB settings
/// When forEditing = true, then the decrypting password the user entered and/or
/// certificate reference found in the .seb file is returned
/// </summary>
/// ----------------------------------------------------------------------------------------
public static DictObj DecryptSEBSettings(byte[] sebData, bool forEditing, ref string sebFilePassword, ref bool passwordIsHash, ref X509Certificate2 sebFileCertificateRef, bool suppressFileFormatError = false)
{
// Ungzip the .seb (according to specification >= v14) source data
byte[] unzippedSebData = GZipByte.Decompress(sebData);
// if unzipped data is not null, then unzipping worked, we use unzipped data
// if unzipped data is null, then the source data may be an uncompressed .seb file, we proceed with it
if (unzippedSebData != null) sebData = unzippedSebData;
string prefixString;
// save the data including the first 4 bytes for the case that it's acutally an unencrypted XML plist
byte[] sebDataUnencrypted = sebData.Clone() as byte[];
// Get 4-char prefix
prefixString = GetPrefixStringFromData(ref sebData);
//// Check prefix identifying encryption modes
/// Check for new Multipart and Custom headers
// Multipart Config File: The first part containts the regular SEB key/value settings
// following parts can contain additional resources. An updated SEB version will be
// able to read and process those parts sequentially as a stream.
// Therefore potentially large additional resources won't have to be loaded into memory at once
if (prefixString.CompareTo(MULTIPART_MODE) == 0)
{
// Skip the Multipart Config File header
byte[] multipartConfigLengthData = GetPrefixDataFromData(ref sebData, MULTIPART_LENGTH);
long multipartConfigLength = BitConverter.ToInt64(multipartConfigLengthData, 0);
Logger.AddInformation("Multipart Config File, first part (settings) length: " + multipartConfigLength);
try
{
Logger.AddInformation("Cropping config file, as this SEB version cannot process additional parts of multipart config files.");
byte[] dataFirstPart = new byte[sebData.Length - multipartConfigLength];
Buffer.BlockCopy(sebData, 0, dataFirstPart, 0, dataFirstPart.Length);
sebData = dataFirstPart;
}
catch (Exception ex)
{
Logger.AddError("Error while cropping config file", null, ex, ex.Message);
}
}
// Custom Header: Containts a 32 bit value for the length of the header
// followed by the custom header information. After the header, regular
// SEB config file data follows
if (prefixString.CompareTo(CUSTOM_HEADER_MODE) == 0)
{
// Skip the Custom Header
byte[] customHeaderLengthData = GetPrefixDataFromData(ref sebData, CUSTOMHEADER_LENGTH);
int customHeaderLength = BitConverter.ToInt32(customHeaderLengthData, 0);
Logger.AddInformation("Custom Config File Header length: " + customHeaderLength);
try
{
Logger.AddInformation("Removing custom header from config file data. This SEB version cannot process this header type and will ignore it.");
byte[] customHeaderData = GetPrefixDataFromData(ref sebData, customHeaderLength);
Logger.AddInformation("Custom header data: " + customHeaderData);
}
catch (Exception ex)
{
Logger.AddError("Error while removing custom header from config file data", null, ex, ex.Message);
}
}
// Prefix = pksh ("Public-Symmetric Key Hash") ?
if (prefixString.CompareTo(PUBLIC_SYMMETRIC_KEY_MODE) == 0)
{
// Decrypt with cryptographic identity/private and symmetric key
sebData = DecryptDataWithPublicKeyHashPrefix(sebData, true, forEditing, ref sebFileCertificateRef);
if (sebData == null)
{
return null;
}
// Get 4-char prefix again
// and remaining data without prefix, which is either plain or still encoded with password
prefixString = GetPrefixStringFromData(ref sebData);
}
// Prefix = pkhs ("Public Key Hash") ?
if (prefixString.CompareTo(PUBLIC_KEY_HASH_MODE) == 0)
{
// Decrypt with cryptographic identity/private key
sebData = DecryptDataWithPublicKeyHashPrefix(sebData, false, forEditing, ref sebFileCertificateRef);
if (sebData == null)
{
return null;
}
// Get 4-char prefix again
// and remaining data without prefix, which is either plain or still encoded with password
prefixString = GetPrefixStringFromData(ref sebData);
}
// Prefix = pswd ("Password") ?
if (prefixString.CompareTo(PASSWORD_MODE) == 0)
{
// Decrypt with password
// if the user enters the right one
byte[] sebDataDecrypted = null;
string password;
// Allow up to 5 attempts for entering decoding password
string enterPasswordString = SEBUIStrings.enterPassword;
int i = 5;
do
{
i--;
// Prompt for password
password = SebPasswordDialogForm.ShowPasswordDialogForm(SEBUIStrings.loadingSettings, enterPasswordString);
if (password == null) return null;
//error = nil;
sebDataDecrypted = SEBProtectionController.DecryptDataWithPassword(sebData, password);
enterPasswordString = SEBUIStrings.enterPasswordAgain;
// in case we get an error we allow the user to try it again
} while ((sebDataDecrypted == null) && i > 0);
if (sebDataDecrypted == null)
{
//wrong password entered in 5th try: stop reading .seb file
MessageBox.Show(SEBUIStrings.decryptingSettingsFailed, SEBUIStrings.decryptingSettingsFailedReason, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
sebData = sebDataDecrypted;
// If these settings are being decrypted for editing, we return the decryption password
if (forEditing) sebFilePassword = password;
}
else
{
// Prefix = pwcc ("Password Configuring Client") ?
if (prefixString.CompareTo(PASSWORD_CONFIGURING_CLIENT_MODE) == 0)
{
// Decrypt with password and configure local client settings
// and quit afterwards, returning if reading the .seb file was successfull
DictObj sebSettings = DecryptDataWithPasswordForConfiguringClient(sebData, forEditing, ref sebFilePassword, ref passwordIsHash);
return sebSettings;
}
else
{
// Prefix = plnd ("Plain Data") ?
if (prefixString.CompareTo(PLAIN_DATA_MODE) != 0)
{
// No valid 4-char prefix was found in the .seb file
// Check if .seb file is unencrypted
if (prefixString.CompareTo(UNENCRYPTED_MODE) == 0)
{
// .seb file seems to be an unencrypted XML plist
// get the original data including the first 4 bytes
sebData = sebDataUnencrypted;
}
else
{
// No valid prefix and no unencrypted file with valid header
// cancel reading .seb file
if (!suppressFileFormatError)
{
MessageBox.Show(SEBUIStrings.settingsNotUsable, SEBUIStrings.settingsNotUsableReason, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return null;
}
}
}
}
// If we don't deal with an unencrypted seb file
// ungzip the .seb (according to specification >= v14) decrypted serialized XML plist data
if (prefixString.CompareTo(UNENCRYPTED_MODE) != 0)
{
sebData = GZipByte.Decompress(sebData);
}
// Get preferences dictionary from decrypted data
DictObj sebPreferencesDict = GetPreferencesDictFromConfigData(sebData, forEditing);
// If we didn't get a preferences dict back, we abort reading settings
if (sebPreferencesDict == null) return null;
// We need to set the right value for the key sebConfigPurpose to know later where to store the new settings
sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam;
// Reading preferences was successful!
return sebPreferencesDict;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Helper method which decrypts the byte array using an empty password,
/// or the administrator password currently set in SEB
/// or asks for the password used for encrypting this SEB file
/// for configuring the client
/// </summary>
/// ----------------------------------------------------------------------------------------
private static DictObj DecryptDataWithPasswordForConfiguringClient(byte[] sebData, bool forEditing, ref string sebFilePassword, ref bool passwordIsHash)
{
passwordIsHash = false;
string password;
// First try to decrypt with the current admin password
// get admin password hash
string hashedAdminPassword = (string)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyHashedAdminPassword);
if (hashedAdminPassword == null)
{
hashedAdminPassword = "";
}
// We use always uppercase letters in the base16 hashed admin password used for encrypting
hashedAdminPassword = hashedAdminPassword.ToUpper();
DictObj sebPreferencesDict = null;
byte[] decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, hashedAdminPassword);
if (decryptedSebData == null)
{
// If decryption with admin password didn't work, try it with an empty password
decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, "");
if (decryptedSebData == null)
{
// If decryption with empty and admin password didn't work, ask for the password the .seb file was encrypted with
// Allow up to 5 attempts for entering decoding password
int i = 5;
password = null;
string enterPasswordString = SEBUIStrings.enterEncryptionPassword;
do
{
i--;
// Prompt for password
password = SebPasswordDialogForm.ShowPasswordDialogForm(SEBUIStrings.reconfiguringLocalSettings, enterPasswordString);
// If cancel was pressed, abort
if (password == null) return null;
string hashedPassword = SEBProtectionController.ComputePasswordHash(password);
// we try to decrypt with the hashed password
decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, hashedPassword);
// in case we get an error we allow the user to try it again
enterPasswordString = SEBUIStrings.enterEncryptionPasswordAgain;
} while (decryptedSebData == null && i > 0);
if (decryptedSebData == null)
{
//wrong password entered in 5th try: stop reading .seb file
MessageBox.Show(SEBUIStrings.reconfiguringLocalSettingsFailed, SEBUIStrings.reconfiguringLocalSettingsFailedWrongPassword, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
else
{
// Decrypting with entered password worked: We save it for returning it later
if (forEditing) sebFilePassword = password;
}
}
}
else
{
//decrypting with hashedAdminPassword worked: we save it for returning as decryption password
sebFilePassword = hashedAdminPassword;
// identify that password as hash
passwordIsHash = true;
}
/// Decryption worked
// Ungzip the .seb (according to specification >= v14) decrypted serialized XML plist data
decryptedSebData = GZipByte.Decompress(decryptedSebData);
// Check if the openend reconfiguring seb file has the same admin password inside like the current one
try
{
sebPreferencesDict = (DictObj)Plist.readPlist(decryptedSebData);
}
catch (Exception readPlistException)
{
// Error when deserializing the decrypted configuration data
// We abort reading the new settings here
MessageBox.Show(SEBUIStrings.loadingSettingsFailed, SEBUIStrings.loadingSettingsFailedReason, MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(readPlistException.Message);
return null;
}
// Get the admin password set in these settings
string sebFileHashedAdminPassword = (string)SEBSettings.valueForDictionaryKey(sebPreferencesDict, SEBSettings.KeyHashedAdminPassword);
if (sebFileHashedAdminPassword == null)
{
sebFileHashedAdminPassword = "";
}
// Has the SEB config file the same admin password inside as the current settings have?
if (String.Compare(hashedAdminPassword, sebFileHashedAdminPassword, StringComparison.OrdinalIgnoreCase) != 0)
{
//No: The admin password inside the .seb file wasn't the same as the current one
if (forEditing)
{
// If the file is openend for editing (and not to reconfigure SEB)
// we have to ask the user for the admin password inside the file
if (!askForPasswordAndCompareToHashedPassword(sebFileHashedAdminPassword, forEditing))
{
// If the user didn't enter the right password we abort
return null;
}
}
else
{
// The file was actually opened for reconfiguring the SEB client:
// we have to ask for the current admin password and
// allow reconfiguring only if the user enters the right one
// We don't check this for the case the current admin password was used to encrypt the new settings
// In this case there can be a new admin pw defined in the new settings and users don't need to enter the old one
if (passwordIsHash == false && hashedAdminPassword.Length > 0)
{
// Allow up to 5 attempts for entering current admin password
int i = 5;
password = null;
string hashedPassword;
string enterPasswordString = SEBUIStrings.enterCurrentAdminPwdForReconfiguring;
bool passwordsMatch;
do
{
i--;
// Prompt for password
password = SebPasswordDialogForm.ShowPasswordDialogForm(SEBUIStrings.reconfiguringLocalSettings, enterPasswordString);
// If cancel was pressed, abort
if (password == null) return null;
if (password.Length == 0)
{
hashedPassword = "";
}
else
{
hashedPassword = SEBProtectionController.ComputePasswordHash(password);
}
passwordsMatch = (String.Compare(hashedPassword, hashedAdminPassword, StringComparison.OrdinalIgnoreCase) == 0);
// in case we get an error we allow the user to try it again
enterPasswordString = SEBUIStrings.enterCurrentAdminPwdForReconfiguringAgain;
} while (!passwordsMatch && i > 0);
if (!passwordsMatch)
{
//wrong password entered in 5th try: stop reading .seb file
MessageBox.Show(SEBUIStrings.reconfiguringLocalSettingsFailed, SEBUIStrings.reconfiguringLocalSettingsFailedWrongCurrentAdminPwd, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
}
}
// We need to set the right value for the key sebConfigPurpose to know later where to store the new settings
sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient;
// Reading preferences was successful!
return sebPreferencesDict;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Helper method: Get preferences dictionary from decrypted data.
/// In editing mode, users have to enter the right SEB administrator password
/// before they can access the settings contents
/// and returns the decrypted bytes
/// </summary>
/// ----------------------------------------------------------------------------------------
private static DictObj GetPreferencesDictFromConfigData(byte[] sebData, bool forEditing)
{
DictObj sebPreferencesDict = null;
try
{
// Get preferences dictionary from decrypted data
sebPreferencesDict = (DictObj)Plist.readPlist(sebData);
}
catch (Exception readPlistException)
{
MessageBox.Show(SEBUIStrings.loadingSettingsFailed, SEBUIStrings.loadingSettingsFailedReason, MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(readPlistException.Message);
return null;
}
// In editing mode, the user has to enter the right SEB administrator password used in those settings before he can access their contents
if (forEditing)
{
// Get the admin password set in these settings
string sebFileHashedAdminPassword = (string)SEBSettings.valueForDictionaryKey(sebPreferencesDict, SEBSettings.KeyHashedAdminPassword);
// If there was no or empty admin password set in these settings, the user can access them anyways
if (!String.IsNullOrEmpty(sebFileHashedAdminPassword))
{
// Get the current hashed admin password
string hashedAdminPassword = (string)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyHashedAdminPassword);
if (hashedAdminPassword == null)
{
hashedAdminPassword = "";
}
// If the current hashed admin password is same as the hashed admin password from the settings file
// then the user is allowed to access the settings
if (String.Compare(hashedAdminPassword, sebFileHashedAdminPassword, StringComparison.OrdinalIgnoreCase) != 0)
{
// otherwise we have to ask for the SEB administrator password used in those settings and
// allow opening settings only if the user enters the right one
if (!askForPasswordAndCompareToHashedPassword(sebFileHashedAdminPassword, forEditing))
{
return null;
}
}
}
}
// Reading preferences was successful!
return sebPreferencesDict;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Ask user to enter password and compare it to the passed (hashed) password string
/// Returns true if correct password was entered
/// </summary>
/// ----------------------------------------------------------------------------------------
private static bool askForPasswordAndCompareToHashedPassword(string sebFileHashedAdminPassword, bool forEditing)
{
// Check if there wasn't a hashed password (= empty password)
if (sebFileHashedAdminPassword.Length == 0) return true;
// We have to ask for the SEB administrator password used in the settings
// and allow opening settings only if the user enters the right one
// Allow up to 5 attempts for entering admin password
int i = 5;
string password = null;
string hashedPassword;
string enterPasswordString = SEBUIStrings.enterAdminPasswordRequired;
bool passwordsMatch;
do
{
i--;
// Prompt for password
password = SebPasswordDialogForm.ShowPasswordDialogForm(SEBUIStrings.loadingSettings + (String.IsNullOrEmpty(SEBClientInfo.LoadingSettingsFileName) ? "" : ": " + SEBClientInfo.LoadingSettingsFileName), enterPasswordString);
// If cancel was pressed, abort
if (password == null) return false;
if (password.Length == 0)
{
hashedPassword = "";
}
else
{
hashedPassword = SEBProtectionController.ComputePasswordHash(password);
}
passwordsMatch = (String.Compare(hashedPassword, sebFileHashedAdminPassword, StringComparison.OrdinalIgnoreCase) == 0);
// in case we get an error we allow the user to try it again
enterPasswordString = SEBUIStrings.enterAdminPasswordRequiredAgain;
} while ((password == null || !passwordsMatch) && i > 0);
if (!passwordsMatch)
{
//wrong password entered in 5th try: stop reading .seb file
MessageBox.Show(SEBUIStrings.loadingSettingsFailed, SEBUIStrings.loadingSettingsFailedWrongAdminPwd, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
// Right password entered
return passwordsMatch;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Helper method which fetches the public key hash from a byte array,
/// retrieves the according cryptographic identity from the certificate store
/// and returns the decrypted bytes
/// </summary>
/// ----------------------------------------------------------------------------------------
private static byte[] DecryptDataWithPublicKeyHashPrefix(byte[] sebData, bool usingSymmetricKey, bool forEditing, ref X509Certificate2 sebFileCertificateRef)
{
// Get 20 bytes public key hash prefix
// and remaining data with the prefix stripped
byte[] publicKeyHash = GetPrefixDataFromData(ref sebData, PUBLIC_KEY_HASH_LENGTH);
X509Certificate2 certificateRef = SEBProtectionController.GetCertificateFromStore(publicKeyHash);
if (certificateRef == null)
{
MessageBox.Show(SEBUIStrings.errorDecryptingSettings, SEBUIStrings.certificateNotFoundInStore, MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
// If these settings are being decrypted for editing, we will return the decryption certificate reference
// in the variable which was passed as reference when calling this method
if (forEditing) sebFileCertificateRef = certificateRef;
// Are we using the new identity certificate decryption with a symmetric key?
if (usingSymmetricKey)
{
// Get length of the encrypted symmetric key
Int32 encryptedSymmetricKeyLength = BitConverter.ToInt32(GetPrefixDataFromData(ref sebData, sizeof(Int32)), 0);
// Get encrypted symmetric key
byte[] encryptedSymmetricKey = GetPrefixDataFromData(ref sebData, encryptedSymmetricKeyLength);
// Decrypt symmetric key
byte[] symmetricKey = SEBProtectionController.DecryptDataWithCertificate(encryptedSymmetricKey, certificateRef);
if (symmetricKey == null)
{
return null;
}
string symmetricKeyString = Convert.ToBase64String(symmetricKey);
// Decrypt config file data using the symmetric key as password
sebData = SEBProtectionController.DecryptDataWithPassword(sebData, symmetricKeyString);
}
else
{
sebData = SEBProtectionController.DecryptDataWithCertificate(sebData, certificateRef);
}
return sebData;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Helper method for returning a prefix string (of PREFIX_LENGTH, currently 4 chars)
/// from a data byte array which is returned without the stripped prefix
/// </summary>
/// ----------------------------------------------------------------------------------------
public static string GetPrefixStringFromData(ref byte[] data)
{
string decryptedDataString = Encoding.UTF8.GetString(GetPrefixDataFromData(ref data, PREFIX_LENGTH));
return decryptedDataString;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Helper method for stripping (and returning) a prefix byte array of prefixLength
/// from a data byte array which is returned without the stripped prefix
/// </summary>
/// ----------------------------------------------------------------------------------------
public static byte[] GetPrefixDataFromData(ref byte[] data, int prefixLength)
{
// Get prefix with indicated length
byte[] prefixData = new byte[prefixLength];
Buffer.BlockCopy(data, 0, prefixData, 0, prefixLength);
// Get data without the stripped prefix
byte[] dataStrippedKey = new byte[data.Length - prefixLength];
Buffer.BlockCopy(data, prefixLength, dataStrippedKey, 0, data.Length - prefixLength);
data = dataStrippedKey;
return prefixData;
}
///// ----------------------------------------------------------------------------------------
///// <summary>
///// Show SEB Password Dialog Form.
///// </summary>
///// ----------------------------------------------------------------------------------------
//public static string ShowPasswordDialogForm(string title, string passwordRequestText)
//{
// // Set the title of the dialog window
// sebPasswordDialogForm.Text = title;
// // Set the text of the dialog
// sebPasswordDialogForm.LabelText = passwordRequestText;
// sebPasswordDialogForm.txtSEBPassword.Focus();
// // If we are running in SebWindowsClient we need to activate it before showing the password dialog
// if (SEBClientInfo.SebWindowsClientForm != null) SebWindowsClientForm.SEBToForeground(); //SEBClientInfo.SebWindowsClientForm.Activate();
// // Show password dialog as a modal dialog and determine if DialogResult = OK.
// if (sebPasswordDialogForm.ShowDialog() == DialogResult.OK)
// {
// // Read the contents of testDialog's TextBox.
// string password = sebPasswordDialogForm.txtSEBPassword.Text;
// sebPasswordDialogForm.txtSEBPassword.Text = "";
// //sebPasswordDialogForm.txtSEBPassword.Focus();
// return password;
// }
// else
// {
// return null;
// }
//}
/// Generate Encrypted .seb Settings Data
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Read SEB settings from UserDefaults and encrypt them using provided security credentials
/// </summary>
/// ----------------------------------------------------------------------------------------
public static byte[] EncryptSEBSettingsWithCredentials(string settingsPassword, bool passwordIsHash, X509Certificate2 certificateRef, bool useAsymmetricOnlyEncryption, SEBSettings.sebConfigPurposes configPurpose, bool forEditing)
{
// Get current settings dictionary and clean it from empty arrays and dictionaries
//DictObj cleanedCurrentSettings = SEBSettings.CleanSettingsDictionary();
// Serialize preferences dictionary to an XML string
string sebXML = Plist.writeXml(SEBSettings.settingsCurrent);
string cleanedSebXML = sebXML.Replace("<array />", "<array></array>");
cleanedSebXML = cleanedSebXML.Replace("<dict />", "<dict></dict>");
cleanedSebXML = cleanedSebXML.Replace("<data />", "<data></data>");
byte[] encryptedSebData = Encoding.UTF8.GetBytes(cleanedSebXML);
string encryptingPassword = null;
// Check for special case: .seb configures client, empty password
if (String.IsNullOrEmpty(settingsPassword) && configPurpose == SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient)
{
encryptingPassword = "";
}
else
{
// in all other cases:
// Check if no password entered and no identity selected
if (String.IsNullOrEmpty(settingsPassword) && certificateRef == null)
{
if (MessageBox.Show(SEBUIStrings.noEncryptionChosen, SEBUIStrings.noEncryptionChosenSaveUnencrypted, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
// OK: save .seb config data unencrypted
return encryptedSebData;
}
else
{
return null;
}
}
}
// gzip the serialized XML data
encryptedSebData = GZipByte.Compress(encryptedSebData);
// Check if password for encryption is provided and use it then
if (!String.IsNullOrEmpty(settingsPassword))
{
encryptingPassword = settingsPassword;
}
// So if password is empty (special case) or provided
if (!(encryptingPassword == null))
{
// encrypt with password
encryptedSebData = EncryptDataUsingPassword(encryptedSebData, encryptingPassword, passwordIsHash, configPurpose);
}
else
{
// Create byte array large enough to hold prefix and data
byte[] encryptedData = new byte[encryptedSebData.Length + PREFIX_LENGTH];
// if no encryption with password: Add a 4-char prefix identifying plain data
string prefixString = PLAIN_DATA_MODE;
Buffer.BlockCopy(Encoding.UTF8.GetBytes(prefixString), 0, encryptedData, 0, PREFIX_LENGTH);
// append plain data
Buffer.BlockCopy(encryptedSebData, 0, encryptedData, PREFIX_LENGTH, encryptedSebData.Length);
encryptedSebData = (byte[])encryptedData.Clone();
}
// Check if cryptographic identity for encryption is selected
if (certificateRef != null)
{
// Encrypt preferences using a cryptographic identity
encryptedSebData = EncryptDataUsingIdentity(encryptedSebData, certificateRef, useAsymmetricOnlyEncryption);
}
// gzip the encrypted data
encryptedSebData = GZipByte.Compress(encryptedSebData);
return encryptedSebData;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Encrypt preferences using a certificate
/// </summary>
/// ----------------------------------------------------------------------------------------
public static byte[] EncryptDataUsingIdentity(byte[] data, X509Certificate2 certificateRef, bool useAsymmetricOnlyEncryption)
{
// Get public key hash from selected identity's certificate
string prefixString;
byte[] publicKeyHash = SEBProtectionController.GetPublicKeyHashFromCertificate(certificateRef);
byte[] encryptedData;
byte[] encryptedKeyLengthBytes = new byte[0];
byte[] encryptedKey = new byte[0];
byte[] encryptedSEBConfigData;
if (!useAsymmetricOnlyEncryption)
{
prefixString = PUBLIC_SYMMETRIC_KEY_MODE;
// For new asymmetric/symmetric encryption create a random symmetric key
byte[] symmetricKey = AESThenHMAC.NewKey();
string symmetricKeyString = Convert.ToBase64String(symmetricKey);
// Encrypt the symmetric key using the identity certificate
encryptedKey = SEBProtectionController.EncryptDataWithCertificate(symmetricKey, certificateRef);
// Get length of the encrypted key
encryptedKeyLengthBytes = BitConverter.GetBytes(encryptedKey.Length);
//encrypt data using symmetric key
encryptedData = SEBProtectionController.EncryptDataWithPassword(data, symmetricKeyString);
}
else
{
prefixString = PUBLIC_KEY_HASH_MODE;
//encrypt data using public key
encryptedData = SEBProtectionController.EncryptDataWithCertificate(data, certificateRef);
}
// Create byte array large enough to hold prefix, public key hash, length of and encrypted symmetric key plus encrypted data
encryptedSEBConfigData = new byte[PREFIX_LENGTH + publicKeyHash.Length + encryptedKeyLengthBytes.Length + encryptedKey.Length + encryptedData.Length];
int destinationOffset = 0;
// Copy prefix indicating data has been encrypted with a public key identified by hash into out data
Buffer.BlockCopy(Encoding.UTF8.GetBytes(prefixString), 0, encryptedSEBConfigData, destinationOffset, PREFIX_LENGTH);
destinationOffset += PREFIX_LENGTH;
// Copy public key hash to out data
Buffer.BlockCopy(publicKeyHash, 0, encryptedSEBConfigData, destinationOffset, publicKeyHash.Length);
destinationOffset += publicKeyHash.Length;
// Copy length of encrypted symmetric key to out data
Buffer.BlockCopy(encryptedKeyLengthBytes, 0, encryptedSEBConfigData, destinationOffset, encryptedKeyLengthBytes.Length);
destinationOffset += encryptedKeyLengthBytes.Length;
// Copy encrypted symmetric key to out data
Buffer.BlockCopy(encryptedKey, 0, encryptedSEBConfigData, destinationOffset, encryptedKey.Length);
destinationOffset += encryptedKey.Length;
// Copy encrypted data to out data
Buffer.BlockCopy(encryptedData, 0, encryptedSEBConfigData, destinationOffset, encryptedData.Length);
return encryptedSEBConfigData;
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Encrypt preferences using a password
/// </summary>
/// ----------------------------------------------------------------------------------------
// Encrypt preferences using a password
public static byte[] EncryptDataUsingPassword(byte[] data, string password, bool passwordIsHash, SEBSettings.sebConfigPurposes configPurpose)
{
string prefixString;
// Check if .seb file should start exam or configure client
if (configPurpose == SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam)
{
// prefix string for starting exam: normal password will be prompted
prefixString = PASSWORD_MODE;
}
else
{
// prefix string for configuring client: configuring password will either be hashed admin pw on client
// or if no admin pw on client set: empty pw
prefixString = PASSWORD_CONFIGURING_CLIENT_MODE;
if (!String.IsNullOrEmpty(password) && !passwordIsHash)
{
//empty password means no admin pw on clients and should not be hashed
//or we got already a hashed admin pw as settings pw, then we don't hash again
password = SEBProtectionController.ComputePasswordHash(password);
}
}
byte[] encryptedData = SEBProtectionController.EncryptDataWithPassword(data, password);
// Create byte array large enough to hold prefix and data
byte[] encryptedSebData = new byte[encryptedData.Length + PREFIX_LENGTH];
Buffer.BlockCopy(Encoding.UTF8.GetBytes(prefixString), 0, encryptedSebData, 0, PREFIX_LENGTH);
Buffer.BlockCopy(encryptedData, 0, encryptedSebData, PREFIX_LENGTH, encryptedData.Length);
return encryptedSebData;
}
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Compressing and decompressing byte arrays using gzip
/// </summary>
/// ----------------------------------------------------------------------------------------
public static class GZipByte
{
public static byte[] Compress(byte[] input)
{
using (MemoryStream output = new MemoryStream())
{
using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
{
zip.Write(input, 0, input.Length);
}
return output.ToArray();
}
}
public static byte[] Decompress(byte[] input)
{
try
{
using (GZipStream stream = new GZipStream(new MemoryStream(input),
CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream output = new MemoryStream())
{
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
output.Write(buffer, 0, count);
}
}
while (count > 0);
return output.ToArray();
}
}
}
catch (Exception)
{
return null;
}
}
/// ----------------------------------------------------------------------------------------
/// <summary>
/// Show SEB Password Dialog Form.
/// </summary>
/// ----------------------------------------------------------------------------------------
//public static string ShowPasswordDialogForm(string title, string passwordRequestText)
//{
// Thread sf= new Thread(new ThreadStart(SebPasswordDialogForm.ShowPasswordDialogForm);
// sf.Start();
//}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,345 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
using DictObj = System.Collections.Generic.Dictionary<string, object>;
using ListObj = System.Collections.Generic.List<object>;
namespace SebWindowsConfig.Utilities
{
public class SEBURLFilter
{
public bool enableURLFilter;
public bool enableContentFilter;
public ListObj permittedList = new ListObj();
public ListObj prohibitedList = new ListObj();
// Updates filter rule arrays with current settings
public void UpdateFilterRules()
{
if (prohibitedList.Count != 0)
{
prohibitedList.Clear();
}
if (permittedList.Count != 0)
{
permittedList.Clear();
}
enableURLFilter = (bool)SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterEnable];
enableContentFilter = (bool)SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterEnableContentFilter];
// Add global URLFilterRules
ListObj URLFilterRules = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterRules];
ReadURLFilterRules(URLFilterRules);
// Add URLFilterRules from additional resources
ListObj additionalResources = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyAdditionalResources];
ReadFilterRulesFromAdditionalResources(additionalResources);
// If URL filtering is enabled, then
// check if Start URL gets allowed by current filter rules and if not add a rule for the Start URL
string startURLString = (string)SEBSettings.settingsCurrent[SEBSettings.KeyStartURL];
if (enableURLFilter && Uri.TryCreate(startURLString, UriKind.Absolute, out Uri startURL))
{
if (TestURLAllowed(startURL) != URLFilterRuleActions.allow)
{
SEBURLFilterRegexExpression expression;
// If Start URL is not allowed: Create one using the full Start URL
try
{
expression = new SEBURLFilterRegexExpression(startURLString);
}
catch (Exception ex)
{
Logger.AddError("Could not create SEBURLFilterRegexExpression: ", this, ex, ex.Message);
prohibitedList.Clear();
permittedList.Clear();
// Convert these rules and add them to the XULRunner seb keys
CreateSebRuleLists();
return;
}
// Add this Start URL filter expression to the permitted filter list
permittedList.Add(expression);
}
}
// Convert these rules and add them to the XULRunner seb keys
CreateSebRuleLists();
}
public void ReadURLFilterRules(ListObj URLFilterRules)
{
foreach (DictObj URLFilterRule in URLFilterRules)
{
if (URLFilterRule.ContainsKey(SEBSettings.KeyURLFilterRuleRegex) && (bool)URLFilterRule[SEBSettings.KeyURLFilterRuleActive] == true)
{
string expressionString = (string)URLFilterRule[SEBSettings.KeyURLFilterRuleExpression];
if (!String.IsNullOrEmpty(expressionString))
{
Object expression;
bool regex = (bool)URLFilterRule[SEBSettings.KeyURLFilterRuleRegex];
try
{
if (regex)
{
expression = new Regex(expressionString, RegexOptions.IgnoreCase);
}
else
{
expression = new SEBURLFilterRegexExpression(expressionString);
}
}
catch (Exception ex)
{
Logger.AddError("Could not create SEBURLFilterRegexExpression: ", this, ex, ex.Message);
prohibitedList.Clear();
permittedList.Clear();
throw;
}
int action = (int)URLFilterRule[SEBSettings.KeyURLFilterRuleAction];
switch (action)
{
case (int)URLFilterRuleActions.block:
prohibitedList.Add(expression);
break;
case (int)URLFilterRuleActions.allow:
permittedList.Add(expression);
break;
}
}
}
}
}
// Read URLFilterRules from additionalResources
public void ReadFilterRulesFromAdditionalResources(ListObj additionalResources)
{
foreach (DictObj additionalResource in additionalResources)
{
if ((bool)additionalResource[SEBSettings.KeyAdditionalResourcesActive])
{
object URLFilterRules;
if (additionalResource.TryGetValue(SEBSettings.KeyURLFilterRules, out URLFilterRules))
{
ReadURLFilterRules((ListObj)URLFilterRules);
}
// Are there further additional resources in this additional resource?
if (additionalResource.TryGetValue(SEBSettings.KeyAdditionalResources, out object additionalSubResources))
{
if (((ListObj)additionalSubResources).Count != 0)
{
ReadFilterRulesFromAdditionalResources((ListObj)additionalSubResources);
}
}
}
}
}
// Convert these rules and add them to the XULRunner seb keys
public void CreateSebRuleLists()
{
// Set prohibited rules
SEBSettings.settingsCurrent[SEBSettings.KeyUrlFilterBlacklist] = SebRuleStringForSEBURLFilterRuleList(prohibitedList);
// Set permitted rules
SEBSettings.settingsCurrent[SEBSettings.KeyUrlFilterWhitelist] = SebRuleStringForSEBURLFilterRuleList(permittedList);
// All rules are regex
SEBSettings.settingsCurrent[SEBSettings.KeyUrlFilterRulesAsRegex] = true;
// Set if content filter is enabled
SEBSettings.settingsCurrent[SEBSettings.KeyUrlFilterTrustedContent] = !(bool)SEBSettings.settingsCurrent[SEBSettings.KeyURLFilterEnableContentFilter];
}
public string SebRuleStringForSEBURLFilterRuleList(ListObj filterRuleList)
{
if (filterRuleList.Count == 0)
{
// No rules defined
return "";
}
StringBuilder sebRuleString = new StringBuilder();
foreach (object expression in filterRuleList)
{
if (expression != null)
{
if (sebRuleString.Length == 0)
{
sebRuleString.Append(expression.ToString());
}
else
{
sebRuleString.AppendFormat(";{0}", expression.ToString());
}
}
}
return sebRuleString.ToString();
}
// Filter URL and return if it is allowed or blocked
public URLFilterRuleActions TestURLAllowed(Uri URLToFilter)
{
string URLToFilterString = URLToFilter.ToString();
// By default URLs are blocked
bool allowURL = false;
bool blockURL = false;
/// Apply current filter rules (expressions/actions) to URL
/// Apply prohibited filter expressions
foreach (object expression in prohibitedList)
{
if (expression.GetType().Equals(typeof(Regex)))
{
if (Regex.IsMatch(URLToFilterString, expression.ToString()))
{
blockURL = true;
break;
}
}
if (expression.GetType().Equals(typeof(SEBURLFilterRegexExpression)))
{
if (URLMatchesFilterExpression(URLToFilter, (SEBURLFilterRegexExpression)expression))
{
blockURL = true;
break;
}
}
}
if (blockURL == true)
{
return URLFilterRuleActions.block;
}
/// Apply permitted filter expressions
foreach (object expression in permittedList)
{
if (expression.GetType().Equals(typeof(Regex)))
{
if (Regex.IsMatch(URLToFilterString, expression.ToString()))
{
allowURL = true;
break;
}
}
if (expression.GetType().Equals(typeof(SEBURLFilterRegexExpression)))
{
if (URLMatchesFilterExpression(URLToFilter, (SEBURLFilterRegexExpression)expression))
{
allowURL = true;
break;
}
}
}
// Return URLFilterActionAllow if URL is allowed or
// URLFilterActionUnknown if it's unknown (= it will anyways be blocked)
return allowURL ? URLFilterRuleActions.allow : URLFilterRuleActions.unknown;
}
// Method comparing all components of a passed URL with the filter expression
// and returning YES (= allow or block) if it matches
public bool URLMatchesFilterExpression(Uri URLToFilter, SEBURLFilterRegexExpression filterExpression)
{
Regex filterComponent;
// If a scheme is indicated in the filter expression, it has to match
filterComponent = filterExpression.scheme;
UriBuilder urlToFilterParts = new UriBuilder(URLToFilter);
if (filterComponent != null &&
!Regex.IsMatch(URLToFilter.Scheme, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
// Scheme of the URL to filter doesn't match the one from the filter expression: Exit with matching = NO
return false;
}
string userInfo = URLToFilter.UserInfo;
filterComponent = filterExpression.user;
if (filterComponent != null &&
!Regex.IsMatch(urlToFilterParts.UserName, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
filterComponent = filterExpression.password;
if (filterComponent != null &&
!Regex.IsMatch(urlToFilterParts.Password, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
filterComponent = filterExpression.host;
if (filterComponent != null &&
!Regex.IsMatch(URLToFilter.Host, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
if (filterExpression.port != null && URLToFilter.Port != -1 &&
URLToFilter.Port != filterExpression.port)
{
return false;
}
filterComponent = filterExpression.path;
if (filterComponent != null &&
!Regex.IsMatch(URLToFilter.AbsolutePath.Trim(new char[] { '/' }), filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
string urlQuery = URLToFilter.GetComponents(UriComponents.Query, UriFormat.Unescaped);
filterComponent = filterExpression.query;
if (filterComponent != null)
{
// If there's a query filter component, then we need to even filter empty URL query strings
// as the filter might either allow some specific queries or no query at all ("?." query filter)
if (urlQuery == null)
{
urlQuery = "";
}
if (!Regex.IsMatch(urlQuery, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
}
string urlFragment = URLToFilter.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
filterComponent = filterExpression.fragment;
if (filterComponent != null &&
!Regex.IsMatch(urlFragment, filterComponent.ToString(), RegexOptions.IgnoreCase))
{
return false;
}
// URL matches the filter expression
return true;
}
}
}

View file

@ -0,0 +1,169 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace SebWindowsConfig.Utilities
{
public class SEBURLFilterExpression
{
public string scheme;
public string user;
public string password;
public string host;
public int? port;
public string path;
public string query;
public string fragment;
public SEBURLFilterExpression(string filterExpressionString)
{
if (!string.IsNullOrEmpty(filterExpressionString))
{
/// Convert Uri to a SEBURLFilterExpression
string splitURLRegexPattern = @"(?:([^\:]*)\:\/\/)?(?:([^\:\@]*)(?:\:([^\@]*))?\@)?(?:([^\/\:]*))?(?:\:([0-9\*]*))?([^\?#]*)?(?:\?([^#]*))?(?:#(.*))?";
Regex splitURLRegex = new Regex(splitURLRegexPattern);
Match regexMatch = splitURLRegex.Match(filterExpressionString);
if (regexMatch.Success == false)
{
return;
}
this.scheme = regexMatch.Groups[1].Value;
this.user = regexMatch.Groups[2].Value;
this.password = regexMatch.Groups[3].Value;
this.host = regexMatch.Groups[4].Value;
// Treat a special case when a query is interpreted as part of the host address
if (this.host.Contains("?"))
{
string splitURLRegexPattern2 = @"([^\?#]*)?(?:\?([^#]*))?(?:#(.*))?";
Regex splitURLRegex2 = new Regex(splitURLRegexPattern2);
Match regexMatch2 = splitURLRegex2.Match(this.host);
if (regexMatch.Success == false)
{
return;
}
this.host = regexMatch2.Groups[1].Value;
this.port = null;
this.path = "";
this.query = regexMatch2.Groups[2].Value;
this.fragment = regexMatch2.Groups[3].Value;
}
else
{
string portNumber = regexMatch.Groups[5].Value;
// We only want a port if the filter expression string explicitely defines one!
if (portNumber.Length == 0 || portNumber == "*")
{
this.port = null;
}
else
{
this.port = UInt16.Parse(portNumber);
}
this.path = regexMatch.Groups[6].Value.Trim(new char[] { '/' });
this.query = regexMatch.Groups[7].Value;
this.fragment = regexMatch.Groups[8].Value;
}
}
}
public static string User(string userInfo)
{
string user = "";
if (!string.IsNullOrEmpty(userInfo))
{
int userPasswordSeparator = userInfo.IndexOf(":");
if (userPasswordSeparator == -1)
{
user = userInfo;
}
else
{
if (userPasswordSeparator != 0)
{
user = userInfo.Substring(0, userPasswordSeparator);
}
}
}
return user;
}
public static string Password(string userInfo)
{
string password = "";
if (!string.IsNullOrEmpty(userInfo))
{
int userPasswordSeparator = userInfo.IndexOf(":");
if (userPasswordSeparator != -1)
{
if (userPasswordSeparator < userInfo.Length - 1)
{
password = userInfo.Substring(userPasswordSeparator + 1, userInfo.Length - 1 - userPasswordSeparator);
}
}
}
return password;
}
public SEBURLFilterExpression(string scheme, string user, string password, string host, int port, string path, string query, string fragment)
{
this.scheme = scheme;
this.user = user;
this.password = password;
this.host = host;
this.port = port;
this.path = path;
this.query = query;
this.fragment = fragment;
}
public override string ToString()
{
StringBuilder expressionString = new StringBuilder();
if (!string.IsNullOrEmpty(this.scheme)) {
if (!string.IsNullOrEmpty(this.host)) {
expressionString.AppendFormat("{0}://", this.scheme);
} else {
expressionString.AppendFormat("{0}:", this.scheme);
}
}
if (!string.IsNullOrEmpty(this.user)) {
expressionString.Append(this.user);
if (!string.IsNullOrEmpty(this.password)) {
expressionString.AppendFormat(":{0}@", this.password);
} else {
expressionString.Append("@");
}
}
if (!string.IsNullOrEmpty(this.host)) {
expressionString.Append(this.host);
}
if (this.port != null && this.port > 0 && this.port <= 65535) {
expressionString.AppendFormat(":{0}", this.port);
}
if (!string.IsNullOrEmpty(this.path)) {
if (this.path.StartsWith("/")) {
expressionString.Append(this.path);
} else {
expressionString.AppendFormat("/{0}", this.path);
}
}
if (!string.IsNullOrEmpty(this.query)) {
expressionString.AppendFormat("?{0}", this.query);
}
if (!string.IsNullOrEmpty(this.fragment)) {
expressionString.AppendFormat("#{0}", this.fragment);
}
return expressionString.ToString();
}
}
}

View file

@ -0,0 +1,298 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace SebWindowsConfig.Utilities
{
public class SEBURLFilterRegexExpression
{
public Regex scheme;
public Regex user;
public Regex password;
public Regex host;
public int? port;
public Regex path;
public Regex query;
public Regex fragment;
public SEBURLFilterRegexExpression(string filterExpressionString)
{
SEBURLFilterExpression URLFromString = new SEBURLFilterExpression(filterExpressionString);
try
{
this.scheme = RegexForFilterString(URLFromString.scheme);
this.user = RegexForFilterString(URLFromString.user);
this.password = RegexForFilterString(URLFromString.password);
this.host = RegexForHostFilterString(URLFromString.host);
this.port = URLFromString.port;
this.path = RegexForPathFilterString(URLFromString.path);
this.query = RegexForQueryFilterString(URLFromString.query);
this.fragment = RegexForFilterString(URLFromString.fragment);
}
catch (Exception)
{
throw;
}
}
public static Regex RegexForFilterString(string filterString)
{
if (string.IsNullOrEmpty(filterString))
{
return null;
}
else
{
string regexString = Regex.Escape(filterString);
regexString = regexString.Replace("\\*", ".*?");
// Add regex command characters for matching at start and end of a line (part)
regexString = string.Format("^{0}$", regexString);
try
{
Regex regex = new Regex(regexString, RegexOptions.IgnoreCase);
return regex;
}
catch (Exception)
{
throw;
}
}
}
public static Regex RegexForHostFilterString(string filterString)
{
if (string.IsNullOrEmpty(filterString))
{
return null;
}
else
{
try
{
// Check if host string has a dot "." prefix to disable subdomain matching
if (filterString.Length > 1 && filterString.StartsWith("."))
{
// Get host string without the "." prefix
filterString = filterString.Substring(1, filterString.Length);
// Get regex for host <*://example.com> (without possible subdomains)
return RegexForFilterString(filterString);
}
// Allow subdomain matching: Create combined regex for <example.com> and <*.example.com>
string regexString = Regex.Escape(filterString);
regexString = regexString.Replace("\\*", ".*?");
// Add regex command characters for matching at start and end of a line (part)
regexString = string.Format("^(({0})|(.*?\\.{0}))$", regexString);
Regex regex = new Regex(regexString, RegexOptions.IgnoreCase);
return regex;
}
catch (Exception)
{
throw;
}
}
}
public static Regex RegexForPathFilterString(string filterString)
{
// Trim a possible trailing slash "/", we will instead add a rule to also match paths to directories without trailing slash
filterString = filterString.TrimEnd(new char[] { '/' });
;
if (string.IsNullOrEmpty(filterString))
{
return null;
}
else
{
try
{
// Check if path string ends with a "/*" for matching contents of a directory
if (filterString.EndsWith("/*"))
{
// As the path filter string matches for a directory, we need to add a string to match directories without trailing slash
// Get path string without the "/*" suffix
string filterStringDirectory = filterString.Substring(0, filterString.Length - 2);
string regexString = Regex.Escape(filterString);
regexString = regexString.Replace("\\*", ".*?");
string regexStringDir = Regex.Escape(filterString);
regexStringDir = regexStringDir.Replace("\\*", ".*?");
// Add regex command characters for matching at start and end of a line (part)
regexString = string.Format("^(({0})|({1}))$", regexString, regexStringDir);
Regex regex = new Regex(regexString, RegexOptions.IgnoreCase);
return regex;
}
else
{
return RegexForFilterString(filterString);
}
}
catch (Exception)
{
throw;
}
}
}
public static Regex RegexForQueryFilterString(string filterString)
{
if (string.IsNullOrEmpty(filterString))
{
return null;
}
else
{
if (filterString.Equals("."))
{
// Add regex command characters for matching at start and end of a line (part)
// and regex for no string allowed
string regexString = @"^$";
try
{
Regex regex = new Regex(regexString, RegexOptions.IgnoreCase);
return regex;
}
catch (Exception)
{
throw;
}
}
else
{
return RegexForFilterString(filterString);
}
}
}
public override string ToString()
{
StringBuilder expressionString = new StringBuilder();
string part;
expressionString.Append("^");
/// Scheme
if (this.scheme != null)
{
// If there is a regex filter for scheme
// get stripped regex pattern
part = StringForRegexFilter(this.scheme);
}
else
{
// otherwise use the regex wildcard pattern for scheme
part = @".*?";
}
expressionString.AppendFormat("{0}:\\/\\/", part);
/// User/Password
if (this.user != null)
{
part = StringForRegexFilter(this.user);
expressionString.Append(part);
if (this.password != null)
{
expressionString.AppendFormat(":{0}@", StringForRegexFilter(this.password));
}
else
{
expressionString.Append("@");
}
}
/// Host
string hostPort = "";
if (this.host != null)
{
hostPort = StringForRegexFilter(this.host);
} else
{
hostPort = ".*?";
}
/// Port
if (this.port != null && this.port > 0 && this.port <= 65535)
{
hostPort = string.Format("{0}:{1}", hostPort, this.port);
}
// When there is a host, but no path
if (this.host != null && this.path == null)
{
hostPort = string.Format("(({0})|({0}\\/.*?))", hostPort);
}
expressionString.Append(hostPort);
/// Path
if (this.path != null)
{
string path = StringForRegexFilter(this.path);
if (path.StartsWith("\\/"))
{
expressionString.Append(path);
}
else
{
expressionString.AppendFormat("\\/{0}", path);
}
}
/// Query
if (this.query != null)
{
// Check for special case Query = "?." which means no query string is allowed
if (StringForRegexFilter(this.query).Equals("."))
{
expressionString.AppendFormat("[^\\?]");
} else
{
expressionString.AppendFormat("\\?{0}", StringForRegexFilter(this.query));
}
} else
{
expressionString.AppendFormat("(()|(\\?.*?))");
}
/// Fragment
if (this.fragment != null)
{
expressionString.AppendFormat("#{0}", StringForRegexFilter(this.fragment));
}
expressionString.Append("$");
return expressionString.ToString();
}
public string StringForRegexFilter(Regex regexFilter)
{
// Get pattern string from regular expression
string regexPattern = regexFilter.ToString();
if (regexPattern.Length <= 2)
{
return "";
}
// Remove the regex command characters for matching at start and end of a line
regexPattern = regexPattern.Substring(1, regexPattern.Length - 2);
return regexPattern;
}
}
}

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.13.3" targetFramework="net45" />
</packages>