DocSpace-client/common/ASC.Data.Storage/Encryption/EncryptionOperation.cs

383 lines
13 KiB
C#
Raw Normal View History

2022-03-15 18:00:53 +00:00
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using Tenant = ASC.Core.Tenants.Tenant;
2020-09-18 17:57:51 +00:00
2022-02-10 11:24:16 +00:00
namespace ASC.Data.Storage.Encryption;
[Transient(Additional = typeof(EncryptionOperationExtension))]
public class EncryptionOperation : DistributedTaskProgress
{
2022-03-25 16:26:06 +00:00
private const string ConfigPath = "";
private const string ProgressFileName = "EncryptionProgress.tmp";
2022-02-10 11:24:16 +00:00
private readonly IServiceScopeFactory _serviceScopeFactory;
2022-03-17 14:33:16 +00:00
private bool _hasErrors;
2022-02-10 11:24:16 +00:00
private EncryptionSettings _encryptionSettings;
private bool _isEncryption;
private bool _useProgressFile;
private IEnumerable<string> _modules;
private IEnumerable<Tenant> _tenants;
private string _serverRootPath;
public EncryptionOperation(IServiceScopeFactory serviceScopeFactory)
{
_serviceScopeFactory = serviceScopeFactory;
}
public void Init(EncryptionSettingsProto encryptionSettingsProto, string id)
{
Id = id;
_encryptionSettings = new EncryptionSettings(encryptionSettingsProto);
_isEncryption = _encryptionSettings.Status == EncryprtionStatus.EncryptionStarted;
_serverRootPath = encryptionSettingsProto.ServerRootPath;
}
protected override void DoJob()
{
using var scope = _serviceScopeFactory.CreateScope();
var scopeClass = scope.ServiceProvider.GetService<EncryptionOperationScope>();
var (log, encryptionSettingsHelper, tenantManager, notifyHelper, coreBaseSettings, storageFactoryConfig, storageFactory, configuration) = scopeClass;
notifyHelper.Init(_serverRootPath);
_tenants = tenantManager.GetTenants(false);
2022-03-25 16:26:06 +00:00
_modules = storageFactoryConfig.GetModuleList(ConfigPath, true);
2022-02-10 11:24:16 +00:00
_useProgressFile = Convert.ToBoolean(configuration["storage:encryption:progressfile"] ?? "true");
Percentage = 10;
PublishChanges();
try
2020-09-30 12:23:35 +00:00
{
2022-02-10 11:24:16 +00:00
if (!coreBaseSettings.Standalone)
{
throw new NotSupportedException();
}
if (_encryptionSettings.Status == EncryprtionStatus.Encrypted || _encryptionSettings.Status == EncryprtionStatus.Decrypted)
{
2022-05-20 15:24:41 +00:00
log.DebugStorageAlready(_encryptionSettings.Status);
2022-02-10 11:24:16 +00:00
return;
}
Percentage = 30;
2020-09-30 12:23:35 +00:00
PublishChanges();
2022-02-10 11:24:16 +00:00
foreach (var tenant in _tenants)
{
var dictionary = new Dictionary<string, DiscDataStore>();
2020-09-30 12:23:35 +00:00
2022-02-10 11:24:16 +00:00
foreach (var module in _modules)
{
2022-03-25 16:26:06 +00:00
dictionary.Add(module, (DiscDataStore)storageFactory.GetStorage(ConfigPath, tenant.Id.ToString(), module));
2020-09-30 12:23:35 +00:00
}
2022-02-10 11:24:16 +00:00
Parallel.ForEach(dictionary, (elem) =>
{
2022-04-14 19:42:15 +00:00
EncryptStoreAsync(tenant, elem.Key, elem.Value, storageFactoryConfig, log).Wait();
2022-02-10 11:24:16 +00:00
});
}
Percentage = 70;
PublishChanges();
if (!_hasErrors)
{
2022-04-14 19:42:15 +00:00
DeleteProgressFilesAsync(storageFactory).Wait();
2022-02-10 11:24:16 +00:00
SaveNewSettings(encryptionSettingsHelper, log);
}
Percentage = 90;
PublishChanges();
ActivateTenants(tenantManager, log, notifyHelper);
Percentage = 100;
PublishChanges();
}
catch (Exception e)
{
Exception = e;
2022-05-20 15:24:41 +00:00
log.ErrorEncryptionOperation(e);
2022-02-10 11:24:16 +00:00
}
}
private async Task EncryptStoreAsync(Tenant tenant, string module, DiscDataStore store, StorageFactoryConfig storageFactoryConfig, ILogger log)
2022-02-10 11:24:16 +00:00
{
2022-03-25 16:26:06 +00:00
var domains = storageFactoryConfig.GetDomainList(ConfigPath, module).ToList();
2022-02-10 11:24:16 +00:00
domains.Add(string.Empty);
2022-04-14 19:42:15 +00:00
var progress = await ReadProgressAsync(store);
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
foreach (var domain in domains)
{
var logParent = $"Tenant: {tenant.Alias}, Module: {module}, Domain: {domain}";
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
var files = await GetFilesAsync(domains, progress, store, domain);
2022-02-10 11:24:16 +00:00
EncryptFiles(store, domain, files, logParent, log);
}
StepDone();
2022-05-20 15:24:41 +00:00
log.DebugPercentage(Percentage);
2022-02-10 11:24:16 +00:00
}
2022-04-14 19:42:15 +00:00
private Task<List<string>> ReadProgressAsync(DiscDataStore store)
2022-02-10 11:24:16 +00:00
{
if (!_useProgressFile)
{
2022-04-14 19:42:15 +00:00
return Task.FromResult(new List<string>());
2022-02-10 11:24:16 +00:00
}
Merge branch 'develop' into feature/backend-refactor # Conflicts: # common/ASC.Common/Caching/ICacheNotify.cs # common/ASC.Common/Caching/KafkaCache.cs # common/ASC.Common/Caching/MemoryCacheNotify.cs # common/ASC.Common/Threading/DistributedTaskProgress.cs # common/ASC.Common/Threading/DistributedTaskQueue.cs # common/ASC.Core.Common/Notify/Signalr/SignalrServiceClient.cs # common/ASC.Data.Backup.Core/Core/FileBackupProvider.cs # common/ASC.Data.Backup.Core/Storage/BackupRepository.cs # common/ASC.Data.Backup.Core/Storage/ConsumerBackupStorage.cs # common/ASC.Data.Backup.Core/Storage/DataStoreBackupStorage.cs # common/ASC.Data.Backup.Core/Storage/DocumentsBackupStorage.cs # common/ASC.Data.Backup.Core/Tasks/BackupPortalTask.cs # common/ASC.Data.Backup.Core/Tasks/DeletePortalTask.cs # common/ASC.Data.Backup.Core/Tasks/PortalTaskBase.cs # common/ASC.Data.Backup.Core/Tasks/RestorePortalTask.cs # common/ASC.Data.Backup.Core/Tasks/TransferPortalTask.cs # common/ASC.Data.Reassigns/RemoveProgressItem.cs # common/ASC.Data.Storage/BaseStorage.cs # common/ASC.Data.Storage/ChunkedUploader/CommonChunkedUploadSessionHolder.cs # common/ASC.Data.Storage/CrossModuleTransferUtility.cs # common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs # common/ASC.Data.Storage/Encryption/EncryptionOperation.cs # common/ASC.Data.Storage/Extensions.cs # common/ASC.Data.Storage/GoogleCloud/GoogleCloudStorage.cs # common/ASC.Data.Storage/IDataStore.cs # common/ASC.Data.Storage/RackspaceCloud/RackspaceCloudStorage.cs # common/ASC.Data.Storage/S3/S3Storage.cs # common/ASC.Data.Storage/S3/S3UploadGuard.cs # common/ASC.Data.Storage/StaticUploader.cs # common/ASC.Data.Storage/StorageHandler.cs # common/ASC.Data.Storage/StorageUploader.cs # common/ASC.Data.Storage/WebPath.cs # common/services/ASC.ApiSystem/Controllers/PortalController.cs # common/services/ASC.AuditTrail/AuditEventsRepository.cs # common/services/ASC.AuditTrail/AuditReportCreator.cs # common/services/ASC.AuditTrail/LoginEventsRepository.cs # products/ASC.Files/Core/Configuration/FilesSpaceUsageStatManager.cs # products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs # products/ASC.Files/Core/Core/Dao/Interfaces/ILinkDao.cs # products/ASC.Files/Core/Core/Dao/Interfaces/IProviderDao.cs # products/ASC.Files/Core/Core/Dao/Interfaces/IProviderInfo.cs # products/ASC.Files/Core/Core/Dao/Interfaces/ITagDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/LinkDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs # products/ASC.Files/Core/Core/Entries/ChunkedUploadSession.cs # products/ASC.Files/Core/Core/Entries/EncryptionKeyPair.cs # products/ASC.Files/Core/Core/FileStorageService.cs # products/ASC.Files/Core/Core/FilesIntegration.cs # products/ASC.Files/Core/Core/Security/FileSecurity.cs # products/ASC.Files/Core/Core/Security/IFileSecurity.cs # products/ASC.Files/Core/Core/Security/ISecurityDao.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxProviderInfo.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxStorage.cs # products/ASC.Files/Core/Core/Thirdparty/CrossDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxProviderInfo.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxStorage.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveProviderInfo.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveStorage.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveProviderInfo.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveStorage.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderAccountDao.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderSecutiryDao.cs # products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderTagDao.cs # products/ASC.Files/Core/Core/Thirdparty/RegexDaoSelectorBase.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointProviderInfo.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxDaoBase.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxProviderInfo.cs # products/ASC.Files/Core/Helpers/DocuSignHelper.cs # products/ASC.Files/Core/Helpers/Global.cs # products/ASC.Files/Core/Helpers/PathProvider.cs # products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs # products/ASC.Files/Core/HttpHandlers/SearchHandler.cs # products/ASC.Files/Core/Model/FileEntryWrapper.cs # products/ASC.Files/Core/Model/FileOperationWraper.cs # products/ASC.Files/Core/Model/FileWrapper.cs # products/ASC.Files/Core/Model/FolderContentWrapper.cs # products/ASC.Files/Core/Model/FolderWrapper.cs # products/ASC.Files/Core/Services/DocumentService/Configuration.cs # products/ASC.Files/Core/Services/DocumentService/DocumentServiceConnector.cs # products/ASC.Files/Core/Services/DocumentService/DocumentServiceHelper.cs # products/ASC.Files/Core/Services/DocumentService/DocumentServiceTracker.cs # products/ASC.Files/Core/Services/NotifyService/NotifyClient.cs # products/ASC.Files/Core/Services/WCFService/FileOperations/FileDeleteOperation.cs # products/ASC.Files/Core/Services/WCFService/FileOperations/FileDownloadOperation.cs # products/ASC.Files/Core/Services/WCFService/FileOperations/FileMarkAsReadOperation.cs # products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs # products/ASC.Files/Core/Services/WCFService/FileOperations/FileOperationsManager.cs # products/ASC.Files/Core/ThirdPartyApp/BoxApp.cs # products/ASC.Files/Core/ThirdPartyApp/GoogleDriveApp.cs # products/ASC.Files/Core/ThirdPartyApp/IThirdPartyApp.cs # products/ASC.Files/Core/Utils/ChunkedUploadSessionHolder.cs # products/ASC.Files/Core/Utils/EntryManager.cs # products/ASC.Files/Core/Utils/FileConverter.cs # products/ASC.Files/Core/Utils/FileMarker.cs # products/ASC.Files/Core/Utils/FileShareLink.cs # products/ASC.Files/Core/Utils/FileSharing.cs # products/ASC.Files/Core/Utils/FileUploader.cs # products/ASC.Files/Core/Utils/MailMergeTask.cs # products/ASC.Files/Core/Utils/SocketManager.cs # products/ASC.Files/Server/Controllers/FilesController.cs # products/ASC.Files/Server/Controllers/PrivacyRoomController.cs # products/ASC.Files/Server/Helpers/FilesControllerHelper.cs # products/ASC.People/Server/Controllers/PeopleController.cs # web/ASC.Web.Api/Controllers/AuthenticationController.cs # web/ASC.Web.Api/Controllers/PortalController.cs # web/ASC.Web.Api/Controllers/SettingsController.cs # web/ASC.Web.Api/Models/BuildVersion.cs # web/ASC.Web.Core/Files/DocumentService.cs # web/ASC.Web.Core/Files/DocumentServiceLicense.cs # web/ASC.Web.Core/Helpers/ApiSystemHelper.cs # web/ASC.Web.Core/Notify/StudioNotifyServiceSender.cs # web/ASC.Web.Core/Notify/StudioPeriodicNotify.cs # web/ASC.Web.Core/Recaptcha.cs # web/ASC.Web.Core/Sms/SmsManager.cs # web/ASC.Web.Core/Sms/SmsProvider.cs # web/ASC.Web.Core/Sms/SmsSender.cs # web/ASC.Web.Core/SpaceUsageStatManager.cs # web/ASC.Web.Core/Utility/UrlShortener.cs
2022-02-23 19:42:34 +00:00
2022-04-14 19:42:15 +00:00
return InternalReadProgressAsync(store);
}
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
private async Task<List<string>> InternalReadProgressAsync(DiscDataStore store)
{
var encryptedFiles = new List<string>();
if (await store.IsFileAsync(string.Empty, ProgressFileName))
2022-02-10 11:24:16 +00:00
{
2022-04-14 19:42:15 +00:00
using var stream = await store.GetReadStreamAsync(string.Empty, ProgressFileName);
2022-02-10 11:24:16 +00:00
using var reader = new StreamReader(stream);
2022-04-14 19:42:15 +00:00
string line;
while ((line = reader.ReadLine()) != null)
{
encryptedFiles.Add(line);
}
}
2022-02-10 11:24:16 +00:00
else
{
2022-03-25 16:26:06 +00:00
store.GetWriteStream(string.Empty, ProgressFileName).Close();
2022-02-10 11:24:16 +00:00
}
return encryptedFiles;
}
2022-04-14 19:42:15 +00:00
private async Task<IEnumerable<string>> GetFilesAsync(List<string> domains, List<string> progress, DiscDataStore targetStore, string targetDomain)
2022-02-10 11:24:16 +00:00
{
2022-04-14 19:42:15 +00:00
IEnumerable<string> files = await targetStore.ListFilesRelativeAsync(targetDomain, "\\", "*.*", true).ToListAsync();
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
if (progress.Count > 0)
2022-02-10 11:24:16 +00:00
{
files = files.Where(path => !progress.Contains(path));
}
if (!string.IsNullOrEmpty(targetDomain))
{
return files;
}
var notEmptyDomains = domains.Where(domain => !string.IsNullOrEmpty(domain));
if (notEmptyDomains.Any())
{
files = files.Where(path => notEmptyDomains.All(domain => !path.Contains(domain + Path.DirectorySeparatorChar)));
}
2022-03-25 16:26:06 +00:00
files = files.Where(path => !path.EndsWith(ProgressFileName));
2022-02-10 11:24:16 +00:00
return files;
}
private void EncryptFiles(DiscDataStore store, string domain, IEnumerable<string> files, string logParent, ILogger log)
2022-02-10 11:24:16 +00:00
{
foreach (var file in files)
{
2022-04-14 19:42:15 +00:00
var logItem = $"{logParent}, File: {file}";
2022-02-10 11:24:16 +00:00
2022-05-20 15:24:41 +00:00
log.Debug(logItem);
2022-02-10 11:24:16 +00:00
try
{
if (_isEncryption)
{
store.Encrypt(domain, file);
2020-09-30 12:23:35 +00:00
}
2022-02-10 11:24:16 +00:00
else
{
store.Decrypt(domain, file);
2020-09-30 12:23:35 +00:00
}
2022-02-10 11:24:16 +00:00
WriteProgress(store, file, _useProgressFile);
}
catch (Exception e)
{
_hasErrors = true;
2022-05-20 15:24:41 +00:00
log.ErrorLogItem(logItem, e);
2022-02-10 11:24:16 +00:00
// ERROR_DISK_FULL: There is not enough space on the disk.
// if (e is IOException && e.HResult == unchecked((int)0x80070070)) break;
}
}
}
private void WriteProgress(DiscDataStore store, string file, bool useProgressFile)
{
if (!useProgressFile)
{
return;
}
2022-03-25 16:26:06 +00:00
using var stream = store.GetWriteStream(string.Empty, ProgressFileName, FileMode.Append);
2022-02-10 11:24:16 +00:00
using var writer = new StreamWriter(stream);
2022-04-14 19:42:15 +00:00
writer.WriteLine(file);
}
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
private async Task DeleteProgressFilesAsync(StorageFactory storageFactory)
2022-02-10 11:24:16 +00:00
{
foreach (var tenant in _tenants)
{
foreach (var module in _modules)
{
2022-03-25 16:26:06 +00:00
var store = (DiscDataStore)storageFactory.GetStorage(ConfigPath, tenant.Id.ToString(), module);
2022-02-10 11:24:16 +00:00
2022-04-14 19:42:15 +00:00
if (await store.IsFileAsync(string.Empty, ProgressFileName))
2022-02-10 11:06:37 +00:00
{
2022-04-14 19:42:15 +00:00
await store.DeleteAsync(string.Empty, ProgressFileName);
2022-02-10 11:06:37 +00:00
}
2022-02-10 11:24:16 +00:00
}
}
}
private void SaveNewSettings(EncryptionSettingsHelper encryptionSettingsHelper, ILogger log)
2022-02-10 11:24:16 +00:00
{
if (_isEncryption)
{
_encryptionSettings.Status = EncryprtionStatus.Encrypted;
}
else
{
_encryptionSettings.Status = EncryprtionStatus.Decrypted;
_encryptionSettings.Password = string.Empty;
}
encryptionSettingsHelper.Save(_encryptionSettings);
2022-05-20 15:24:41 +00:00
log.DebugSaveNewEncryptionSettings();
2022-02-10 11:24:16 +00:00
}
private void ActivateTenants(TenantManager tenantManager, ILogger log, NotifyHelper notifyHelper)
2022-02-10 11:24:16 +00:00
{
foreach (var tenant in _tenants)
{
if (tenant.Status == TenantStatus.Encryption)
{
tenantManager.SetCurrentTenant(tenant);
tenant.SetStatus(TenantStatus.Active);
tenantManager.SaveTenant(tenant);
2022-05-20 15:24:41 +00:00
log.DebugTenantSetStatusActive(tenant.Alias);
2022-02-10 11:24:16 +00:00
if (!_hasErrors)
{
if (_encryptionSettings.NotifyUsers)
2020-09-18 17:57:51 +00:00
{
2022-02-10 11:24:16 +00:00
if (_isEncryption)
{
notifyHelper.SendStorageEncryptionSuccess(tenant.Id);
}
2022-02-10 11:24:16 +00:00
else
{
notifyHelper.SendStorageDecryptionSuccess(tenant.Id);
2022-02-10 11:24:16 +00:00
}
2022-05-20 15:24:41 +00:00
log.DebugTenantSendStorageEncryptionSuccess(tenant.Alias);
2022-02-10 11:24:16 +00:00
}
}
else
{
if (_isEncryption)
{
notifyHelper.SendStorageEncryptionError(tenant.Id);
2022-02-10 11:24:16 +00:00
}
else
{
notifyHelper.SendStorageDecryptionError(tenant.Id);
2022-02-10 11:24:16 +00:00
}
2022-05-20 15:24:41 +00:00
log.DebugTenantSendStorageEncryptionError(tenant.Alias);
2022-02-10 11:24:16 +00:00
}
}
}
}
}
[Scope]
public class EncryptionOperationScope
{
private readonly ILogger _logger;
2022-02-10 11:24:16 +00:00
private readonly EncryptionSettingsHelper _encryptionSettingsHelper;
private readonly TenantManager _tenantManager;
private readonly NotifyHelper _notifyHelper;
private readonly CoreBaseSettings _coreBaseSettings;
private readonly StorageFactoryConfig _storageFactoryConfig;
private readonly StorageFactory _storageFactory;
private readonly IConfiguration _configuration;
public EncryptionOperationScope(
ILogger<EncryptionOperationScope> logger,
2022-02-10 11:24:16 +00:00
StorageFactoryConfig storageFactoryConfig,
StorageFactory storageFactory,
TenantManager tenantManager,
CoreBaseSettings coreBaseSettings,
NotifyHelper notifyHelper,
EncryptionSettingsHelper encryptionSettingsHelper,
IConfiguration configuration)
{
2022-03-17 10:13:52 +00:00
_logger = logger;
2022-02-10 11:24:16 +00:00
_storageFactoryConfig = storageFactoryConfig;
_storageFactory = storageFactory;
_tenantManager = tenantManager;
_coreBaseSettings = coreBaseSettings;
_notifyHelper = notifyHelper;
_encryptionSettingsHelper = encryptionSettingsHelper;
_configuration = configuration;
}
public void Deconstruct(out ILogger log, out EncryptionSettingsHelper encryptionSettingsHelper, out TenantManager tenantManager, out NotifyHelper notifyHelper, out CoreBaseSettings coreBaseSettings, out StorageFactoryConfig storageFactoryConfig, out StorageFactory storageFactory, out IConfiguration configuration)
2022-02-10 11:24:16 +00:00
{
log = _logger;
encryptionSettingsHelper = _encryptionSettingsHelper;
tenantManager = _tenantManager;
notifyHelper = _notifyHelper;
coreBaseSettings = _coreBaseSettings;
storageFactoryConfig = _storageFactoryConfig;
storageFactory = _storageFactory;
configuration = _configuration;
}
}
public static class EncryptionOperationExtension
{
2022-02-10 11:24:16 +00:00
public static void Register(DIHelper services)
{
services.TryAdd<EncryptionOperationScope>();
}
2020-09-02 10:54:50 +00:00
}