SEBWIN-510: Made lazy initialization of BEK thread-safe.
This commit is contained in:
parent
d82d62f35f
commit
20ff39493d
1 changed files with 33 additions and 23 deletions
|
@ -19,6 +19,8 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
{
|
{
|
||||||
public class KeyGenerator : IKeyGenerator
|
public class KeyGenerator : IKeyGenerator
|
||||||
{
|
{
|
||||||
|
private readonly object @lock = new object();
|
||||||
|
|
||||||
private readonly SHA256Managed algorithm;
|
private readonly SHA256Managed algorithm;
|
||||||
private readonly AppConfig appConfig;
|
private readonly AppConfig appConfig;
|
||||||
private readonly IIntegrityModule integrityModule;
|
private readonly IIntegrityModule integrityModule;
|
||||||
|
@ -59,6 +61,12 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
var configurationKey = settings.Browser.ConfigurationKey;
|
var configurationKey = settings.Browser.ConfigurationKey;
|
||||||
var salt = settings.Browser.BrowserExamKeySalt;
|
var salt = settings.Browser.BrowserExamKeySalt;
|
||||||
|
|
||||||
|
lock (@lock)
|
||||||
|
{
|
||||||
|
if (browserExamKey == default)
|
||||||
|
{
|
||||||
|
logger.Debug("Initializing browser exam key...");
|
||||||
|
|
||||||
if (configurationKey == default)
|
if (configurationKey == default)
|
||||||
{
|
{
|
||||||
configurationKey = "";
|
configurationKey = "";
|
||||||
|
@ -87,6 +95,8 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
browserExamKey = key;
|
browserExamKey = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return browserExamKey;
|
return browserExamKey;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue