feat(eidas): Implement eIDAS Crypto Plugin with dependency injection and signing capabilities
- Added ServiceCollectionExtensions for eIDAS crypto providers. - Implemented EidasCryptoProvider for handling eIDAS-compliant signatures. - Created LocalEidasProvider for local signing using PKCS#12 keystores. - Defined SignatureLevel and SignatureFormat enums for eIDAS compliance. - Developed TrustServiceProviderClient for remote signing via TSP. - Added configuration support for eIDAS options in the project file. - Implemented unit tests for SM2 compliance and crypto operations. - Introduced dependency injection extensions for SM software and remote plugins.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
// Sprint: SPRINT_4100_0006_0002 - eIDAS Crypto Plugin
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StellaOps.Cryptography;
|
||||
using StellaOps.Cryptography.Plugin.EIDAS.Configuration;
|
||||
|
||||
namespace StellaOps.Cryptography.Plugin.EIDAS.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Dependency injection extensions for eIDAS crypto plugin.
|
||||
/// </summary>
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Add eIDAS crypto providers to the service collection.
|
||||
/// </summary>
|
||||
public static IServiceCollection AddEidasCryptoProviders(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// Bind eIDAS configuration
|
||||
services.Configure<EidasOptions>(configuration.GetSection("StellaOps:Crypto:Profiles:eidas"));
|
||||
|
||||
// Register eIDAS components
|
||||
services.AddSingleton<LocalEidasProvider>();
|
||||
services.AddHttpClient<TrustServiceProviderClient>();
|
||||
|
||||
// Register crypto provider
|
||||
services.AddSingleton<ICryptoProvider, EidasCryptoProvider>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add eIDAS crypto providers with explicit options.
|
||||
/// </summary>
|
||||
public static IServiceCollection AddEidasCryptoProviders(
|
||||
this IServiceCollection services,
|
||||
Action<EidasOptions> configureOptions)
|
||||
{
|
||||
services.Configure(configureOptions);
|
||||
|
||||
services.AddSingleton<LocalEidasProvider>();
|
||||
services.AddHttpClient<TrustServiceProviderClient>();
|
||||
services.AddSingleton<ICryptoProvider, EidasCryptoProvider>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user