Class EncryptionConfigurationBuilder
- Namespace
- Excalibur.Compliance.Configuration
- Assembly
- Excalibur.Compliance.dll
Fluent builder for configuring encryption providers.
public sealed class EncryptionConfigurationBuilder
- Inheritance
-
EncryptionConfigurationBuilder
- Inherited Members
Remarks
Use this builder to register and configure encryption providers for the registry. All methods return the builder instance for fluent chaining.
Methods
AddLegacy(string)
Marks a registered provider as a legacy provider for decryption only.
public EncryptionConfigurationBuilder AddLegacy(string providerId)
Parameters
providerIdstringThe provider ID to mark as legacy.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.
Remarks
Legacy providers are used during migration to decrypt data encrypted with previous providers. They are not used for new encryption operations.
ConfigureOptions(Action<EncryptionOptions>)
Configures encryption options.
public EncryptionConfigurationBuilder ConfigureOptions(Action<EncryptionOptions> configure)
Parameters
configureAction<EncryptionOptions>Action to configure the options.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.
SetAsPrimary(string)
Sets a registered provider as the primary provider for new encryption operations.
public EncryptionConfigurationBuilder SetAsPrimary(string providerId)
Parameters
providerIdstringThe provider ID to set as primary.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.
Exceptions
- InvalidOperationException
Thrown if the provider ID was not registered in this builder.
UseInMemoryKeyManagement(string?, Action<InMemoryKeyManagementOptions>?)
Registers an AES-256-GCM encryption provider with in-memory key management.
public EncryptionConfigurationBuilder UseInMemoryKeyManagement(string? providerId = null, Action<InMemoryKeyManagementOptions>? configureKeyManagement = null)
Parameters
providerIdstringUnique identifier for this provider. Auto-generated if null.
configureKeyManagementAction<InMemoryKeyManagementOptions>Optional configuration for key management options.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.
Remarks
This provider is suitable for development and testing. For production, use UseKeyManagement<TProvider>(string?) with a cloud KMS provider.
UseKeyManagement<TProvider>(string?)
Registers a custom encryption provider type.
public EncryptionConfigurationBuilder UseKeyManagement<TProvider>(string? providerId = null) where TProvider : class, IEncryptionProvider
Parameters
providerIdstringUnique identifier for this provider. Auto-generated if null.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.
Type Parameters
TProviderThe encryption provider type to register.
Remarks
The provider type must implement IEncryptionProvider and have a constructor that can be resolved by the DI container.
UseProvider(string, IEncryptionProvider)
Registers a provider instance directly.
public EncryptionConfigurationBuilder UseProvider(string providerId, IEncryptionProvider provider)
Parameters
providerIdstringUnique identifier for this provider.
providerIEncryptionProviderThe provider instance.
Returns
- EncryptionConfigurationBuilder
The builder for chaining.