using EnvelopeGenerator.Application.Common.Enums; using System.ComponentModel.DataAnnotations; namespace EnvelopeGenerator.Application.Common.Configurations; /// /// Represents PKCS#11 signing configuration for PDF signing workflows. /// This options model maps to the Crypt:Pkcs11 configuration section. /// public sealed class Pkcs11Options { /// /// Configuration section path used for binding PKCS#11 options. /// public const string SectionName = "Crypt:Pkcs11"; /// /// Optional base directory that contains the pkcs11 folder. /// If null/empty, runtime uses the application base directory. /// public string? AssetsRootPath { get; set; } /// /// Optional numeric slot identifier used to directly select the target token slot. /// public ulong? SlotId { get; set; } /// /// Optional token label used as a fallback token selector when is not provided. /// public string? TokenLabel { get; set; } /// /// Optional PKCS#11 proxy endpoint (for example tcp://host:port). /// public string? ProxySocket { get; set; } /// /// Resolved absolute PKCS#11 proxy module path used at runtime. /// Computed from and runtime defaults. /// public string ResolvedLibraryPath { get; private set; } = string.Empty; /// /// Resolved absolute pkcs11-tool path used at runtime. /// Computed from and runtime defaults. /// Can be null when tool fallback is not available. /// public string? ResolvedToolPath { get; private set; } public void SetResolvedPaths(string resolvedLibraryPath, string? resolvedToolPath) { ResolvedLibraryPath = resolvedLibraryPath; ResolvedToolPath = resolvedToolPath; } /// /// User PIN used to authenticate to the PKCS#11 token session. /// [Required] [MinLength(1)] public required string UserPin { get; set; } /// /// Label of the private key object used to create digital signatures. /// [Required] [MinLength(1)] public required string PrivateKeyLabel { get; set; } /// /// Label of the certificate object returned/embedded with the signature. /// [Required] [MinLength(1)] public required string CertificateLabel { get; set; } /// /// Optional global default signing reason used when request-level options do not specify a value. /// public string? DefaultReason { get; set; } /// /// Optional global default application name used when request-level options do not specify a value. /// public string? DefaultApplicationName { get; set; } /// /// Controls how fallback signing time is created when request-level options do not specify a value. /// true uses , false uses . /// public bool UseUtcSigningTime { get; set; } = true; /// /// Optional global default certification level used when request-level options do not specify a value. /// public PdfSignatureCertificationLevel? DefaultCertificationLevel { get; set; } }