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
|
||||
{
|
||||
private readonly object @lock = new object();
|
||||
|
||||
private readonly SHA256Managed algorithm;
|
||||
private readonly AppConfig appConfig;
|
||||
private readonly IIntegrityModule integrityModule;
|
||||
|
@ -59,6 +61,12 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
|||
var configurationKey = settings.Browser.ConfigurationKey;
|
||||
var salt = settings.Browser.BrowserExamKeySalt;
|
||||
|
||||
lock (@lock)
|
||||
{
|
||||
if (browserExamKey == default)
|
||||
{
|
||||
logger.Debug("Initializing browser exam key...");
|
||||
|
||||
if (configurationKey == default)
|
||||
{
|
||||
configurationKey = "";
|
||||
|
@ -87,6 +95,8 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
|||
browserExamKey = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return browserExamKey;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue