SEBWIN-314: Started implementing request filter.
This commit is contained in:
parent
88afdb7d72
commit
c282623eb4
6 changed files with 145 additions and 6 deletions
|
@ -21,12 +21,12 @@ namespace SafeExamBrowser.Configuration.Contracts.Settings
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines whether all content requests for a web page should be filtered according to the defined <see cref="FilterRules"/>.
|
/// Defines whether all content requests for a web page should be filtered according to the defined <see cref="FilterRules"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableContentRequestFilter { get; set; }
|
public bool FilterContentRequests { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines whether the main request for a web page should be filtered according to the defined <see cref="FilterRules"/>.
|
/// Defines whether the main request for a web page should be filtered according to the defined <see cref="FilterRules"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableMainRequestFilter { get; set; }
|
public bool FilterMainRequests { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines all rules to be used to filter network requests.
|
/// Defines all rules to be used to filter network requests.
|
||||||
|
|
|
@ -16,17 +16,17 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
{
|
{
|
||||||
private void MapEnableContentRequestFilter(Settings settings, object value)
|
private void MapEnableContentRequestFilter(Settings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool enable)
|
if (value is bool filter)
|
||||||
{
|
{
|
||||||
settings.Network.EnableContentRequestFilter = enable;
|
settings.Network.FilterContentRequests = filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapEnableMainRequestFilter(Settings settings, object value)
|
private void MapEnableMainRequestFilter(Settings settings, object value)
|
||||||
{
|
{
|
||||||
if (value is bool enable)
|
if (value is bool filter)
|
||||||
{
|
{
|
||||||
settings.Network.EnableMainRequestFilter = enable;
|
settings.Network.FilterMainRequests = filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
SafeExamBrowser.Network/Filter/RequestFilter.cs
Normal file
29
SafeExamBrowser.Network/Filter/RequestFilter.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using SafeExamBrowser.Network.Contracts;
|
||||||
|
using SafeExamBrowser.Network.Contracts.Filter;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Network.Filter
|
||||||
|
{
|
||||||
|
public class RequestFilter : IRequestFilter
|
||||||
|
{
|
||||||
|
public FilterResult Default { private get; set; }
|
||||||
|
|
||||||
|
public void Load(FilterRule rule)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterResult Process(Request request)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
SafeExamBrowser.Network/Properties/AssemblyInfo.cs
Normal file
33
SafeExamBrowser.Network/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("SafeExamBrowser.Network")]
|
||||||
|
[assembly: AssemblyDescription("Safe Exam Browser")]
|
||||||
|
[assembly: AssemblyCompany("ETH Zürich")]
|
||||||
|
[assembly: AssemblyProduct("SafeExamBrowser.Network")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2019 ETH Zürich, Educational Development and Technology (LET)")]
|
||||||
|
|
||||||
|
// 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("2da8f505-51be-48c8-b32b-5e753e936dec")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyInformationalVersion("1.0.0.0")]
|
67
SafeExamBrowser.Network/SafeExamBrowser.Network.csproj
Normal file
67
SafeExamBrowser.Network/SafeExamBrowser.Network.csproj
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{2DA8F505-51BE-48C8-B32B-5E753E936DEC}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>SafeExamBrowser.Network</RootNamespace>
|
||||||
|
<AssemblyName>SafeExamBrowser.Network</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Filter\RequestFilter.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Network.Contracts\SafeExamBrowser.Network.Contracts.csproj">
|
||||||
|
<Project>{2947da3c-61f3-44be-81cf-d1d5c10aec95}</Project>
|
||||||
|
<Name>SafeExamBrowser.Network.Contracts</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterfa
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.WindowsApi.Contracts", "SafeExamBrowser.WindowsApi.Contracts\SafeExamBrowser.WindowsApi.Contracts.csproj", "{7016F080-9AA5-41B2-A225-385AD877C171}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.WindowsApi.Contracts", "SafeExamBrowser.WindowsApi.Contracts\SafeExamBrowser.WindowsApi.Contracts.csproj", "{7016F080-9AA5-41B2-A225-385AD877C171}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Network", "SafeExamBrowser.Network\SafeExamBrowser.Network.csproj", "{2DA8F505-51BE-48C8-B32B-5E753E936DEC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -466,6 +468,14 @@ Global
|
||||||
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|x86.ActiveCfg = Release|x86
|
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|x86.ActiveCfg = Release|x86
|
||||||
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|x86.Build.0 = Release|x86
|
{7016F080-9AA5-41B2-A225-385AD877C171}.Release|x86.Build.0 = Release|x86
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{2DA8F505-51BE-48C8-B32B-5E753E936DEC}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Add table
Reference in a new issue