stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using StellaOps.Cryptography;
|
||||
using StellaOps.Cryptography.DependencyInjection;
|
||||
using StellaOps.Cryptography.Plugin.Pkcs11Gost;
|
||||
using System;
|
||||
#if STELLAOPS_CRYPTO_PRO
|
||||
using StellaOps.Cryptography.Plugin.CryptoPro;
|
||||
#endif
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public static partial class StellaOpsCryptoServiceCollectionExtensions
|
||||
{
|
||||
private static void ApplyRegistry(
|
||||
CryptoProviderRegistryOptions target,
|
||||
CryptoProviderRegistryOptions source)
|
||||
{
|
||||
target.ActiveProfile = source.ActiveProfile;
|
||||
target.PreferredProviders.Clear();
|
||||
foreach (var provider in source.PreferredProviders)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(provider))
|
||||
{
|
||||
target.PreferredProviders.Add(provider.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
target.Profiles.Clear();
|
||||
foreach (var kvp in source.Profiles)
|
||||
{
|
||||
if (kvp.Value is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var profile = new CryptoProviderProfileOptions();
|
||||
foreach (var provider in kvp.Value.PreferredProviders)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(provider))
|
||||
{
|
||||
profile.PreferredProviders.Add(provider.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
target.Profiles[kvp.Key] = profile;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyPkcs11Options(Pkcs11GostProviderOptions target, Pkcs11GostProviderOptions source)
|
||||
{
|
||||
target.Keys.Clear();
|
||||
foreach (var key in source.Keys)
|
||||
{
|
||||
target.Keys.Add(key.Clone());
|
||||
}
|
||||
}
|
||||
|
||||
#if STELLAOPS_CRYPTO_PRO
|
||||
private static void CopyCryptoProOptions(CryptoProGostProviderOptions target, CryptoProGostProviderOptions source)
|
||||
{
|
||||
target.Keys.Clear();
|
||||
foreach (var key in source.Keys)
|
||||
{
|
||||
target.Keys.Add(key.Clone());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user