SEBWIN-640, #552: Only search for an LMS session identifier when a server session is active.

This commit is contained in:
Damian Büchel 2023-03-08 00:01:20 +01:00
parent 7967087ee6
commit 8c687e69a8
6 changed files with 30 additions and 8 deletions

View file

@ -48,7 +48,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers
settings = new BrowserSettings();
windowSettings = new WindowSettings();
text = new Mock<IText>();
resourceHandler = new ResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, settings, windowSettings, text.Object);
resourceHandler = new ResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, default, settings, windowSettings, text.Object);
sut = new TestableRequestHandler(appConfig, filter.Object, logger.Object, resourceHandler, settings, windowSettings);
}

View file

@ -18,6 +18,7 @@ using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Settings;
using SafeExamBrowser.Settings.Browser;
using SafeExamBrowser.Settings.Browser.Filter;
using BrowserSettings = SafeExamBrowser.Settings.Browser.BrowserSettings;
@ -49,7 +50,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers
windowSettings = new WindowSettings();
text = new Mock<IText>();
sut = new TestableResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, settings, windowSettings, text.Object);
sut = new TestableResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, SessionMode.Server, settings, windowSettings, text.Object);
}
[TestMethod]
@ -298,9 +299,10 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers
IRequestFilter filter,
IKeyGenerator keyGenerator,
ILogger logger,
SessionMode sessionMode,
BrowserSettings settings,
WindowSettings windowSettings,
IText text) : base(appConfig, filter, keyGenerator, logger, settings, windowSettings, text)
IText text) : base(appConfig, filter, keyGenerator, logger, sessionMode, settings, windowSettings, text)
{
}

View file

@ -24,6 +24,7 @@ using SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.Core.Contracts.Resources.Icons;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Settings;
using SafeExamBrowser.Settings.Browser.Proxy;
using SafeExamBrowser.Settings.Logging;
using SafeExamBrowser.UserInterface.Contracts;
@ -45,6 +46,7 @@ namespace SafeExamBrowser.Browser
private readonly IModuleLogger logger;
private readonly IMessageBox messageBox;
private readonly INativeMethods nativeMethods;
private readonly SessionMode sessionMode;
private readonly BrowserSettings settings;
private readonly IText text;
private readonly IUserInterfaceFactory uiFactory;
@ -68,9 +70,10 @@ namespace SafeExamBrowser.Browser
IFileSystemDialog fileSystemDialog,
IHashAlgorithm hashAlgorithm,
IKeyGenerator keyGenerator,
INativeMethods nativeMethods,
IMessageBox messageBox,
IModuleLogger logger,
INativeMethods nativeMethods,
SessionMode sessionMode,
IText text,
IUserInterfaceFactory uiFactory)
{
@ -81,6 +84,7 @@ namespace SafeExamBrowser.Browser
this.logger = logger;
this.messageBox = messageBox;
this.nativeMethods = nativeMethods;
this.sessionMode = sessionMode;
this.settings = settings;
this.text = text;
this.uiFactory = uiFactory;
@ -193,6 +197,7 @@ namespace SafeExamBrowser.Browser
keyGenerator,
windowLogger,
messageBox,
sessionMode,
settings,
startUrl,
text,

View file

@ -26,6 +26,7 @@ using SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.Core.Contracts.Resources.Icons;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Settings;
using SafeExamBrowser.Settings.Browser;
using SafeExamBrowser.Settings.Browser.Filter;
using SafeExamBrowser.UserInterface.Contracts;
@ -55,6 +56,7 @@ namespace SafeExamBrowser.Browser
private readonly IKeyGenerator keyGenerator;
private readonly IModuleLogger logger;
private readonly IMessageBox messageBox;
private readonly SessionMode sessionMode;
private readonly Dictionary<int, BrowserWindow> popups;
private readonly BrowserSettings settings;
private readonly string startUrl;
@ -97,6 +99,7 @@ namespace SafeExamBrowser.Browser
IKeyGenerator keyGenerator,
IModuleLogger logger,
IMessageBox messageBox,
SessionMode sessionMode,
BrowserSettings settings,
string startUrl,
IText text,
@ -112,6 +115,7 @@ namespace SafeExamBrowser.Browser
this.logger = logger;
this.messageBox = messageBox;
this.popups = new Dictionary<int, BrowserWindow>();
this.sessionMode = sessionMode;
this.settings = settings;
this.startUrl = startUrl;
this.text = text;
@ -153,7 +157,7 @@ namespace SafeExamBrowser.Browser
var renderHandler = new RenderProcessMessageHandler(appConfig, keyGenerator, settings, text);
var requestFilter = new RequestFilter();
var requestLogger = logger.CloneFor($"{nameof(RequestHandler)} #{Id}");
var resourceHandler = new ResourceHandler(appConfig, requestFilter, keyGenerator, logger, settings, WindowSettings, text);
var resourceHandler = new ResourceHandler(appConfig, requestFilter, keyGenerator, logger, sessionMode, settings, WindowSettings, text);
var requestHandler = new RequestHandler(appConfig, requestFilter, requestLogger, resourceHandler, settings, WindowSettings);
Icon = new BrowserIconResource();

View file

@ -23,6 +23,7 @@ using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Settings;
using SafeExamBrowser.Settings.Browser;
using SafeExamBrowser.Settings.Browser.Filter;
using BrowserSettings = SafeExamBrowser.Settings.Browser.BrowserSettings;
@ -37,6 +38,7 @@ namespace SafeExamBrowser.Browser.Handlers
private readonly IRequestFilter filter;
private readonly IKeyGenerator keyGenerator;
private readonly ILogger logger;
private readonly SessionMode sessionMode;
private readonly BrowserSettings settings;
private readonly WindowSettings windowSettings;
@ -51,6 +53,7 @@ namespace SafeExamBrowser.Browser.Handlers
IRequestFilter filter,
IKeyGenerator keyGenerator,
ILogger logger,
SessionMode sessionMode,
BrowserSettings settings,
WindowSettings windowSettings,
IText text)
@ -60,6 +63,7 @@ namespace SafeExamBrowser.Browser.Handlers
this.contentLoader = new ContentLoader(text);
this.keyGenerator = keyGenerator;
this.logger = logger;
this.sessionMode = sessionMode;
this.settings = settings;
this.windowSettings = windowSettings;
}
@ -94,7 +98,10 @@ namespace SafeExamBrowser.Browser.Handlers
protected override void OnResourceRedirect(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl)
{
SearchSessionIdentifiers(request, response);
if (sessionMode == SessionMode.Server)
{
SearchSessionIdentifiers(request, response);
}
base.OnResourceRedirect(chromiumWebBrowser, browser, frame, request, response, ref newUrl);
}
@ -108,7 +115,10 @@ namespace SafeExamBrowser.Browser.Handlers
return true;
}
SearchSessionIdentifiers(request, response);
if (sessionMode == SessionMode.Server)
{
SearchSessionIdentifiers(request, response);
}
return base.OnResourceResponse(webBrowser, browser, frame, request, response);
}

View file

@ -231,9 +231,10 @@ namespace SafeExamBrowser.Client
fileSystemDialog,
new HashAlgorithm(),
keyGenerator,
nativeMethods,
messageBox,
moduleLogger,
nativeMethods,
context.Settings.SessionMode,
text,
uiFactory);
var operation = new BrowserOperation(actionCenter, context, logger, taskbar, taskview, uiFactory);