public static IPassawordBuilder AddPassaword(this IServiceCollection services, Action <PassawordOptions> options = null) { var context = new PassawordContext(); var o = new PassawordOptions(); options?.Invoke(o); context.OnDecryptionFailed = o.OnDecryptionFailed; context.OnSecretDecrypted = o.OnSecretDecrypted; context.OnSecretEncrypted = o.OnSecretEncrypted; context.OnPreValidationFailed = o.OnPreValidationFailed; services.AddSingleton <PassawordContext>(context); services.AddTransient <ISecretValidator, DefaultSecretValidator>(); services.AddTransient <IKeyGenerator, DefaultKeyGenerator>(); services.AddTransient <ISymmetricEncryptor, Aes256Encryptor>(); services.AddTransient <Aes256Encryptor, Aes256Encryptor>(); services.AddTransient <SecretEncryptionContext, SecretEncryptionContext>(); services.AddTransient <SecretDecryptionContext, SecretDecryptionContext>(); services.AddTransient <EncryptionEventArgs, EncryptionEventArgs>(); services.AddTransient <DecryptionEventArgs, DecryptionEventArgs>(); services.AddTransient <DecryptionFailedEventArgs, DecryptionFailedEventArgs>(); services.AddTransient <ISecretContextService, DefaultSecretContextService>(); services.AddTransient <IMessageContentStore, DefaultMessageContentStore>(); return(new PassawordBuilder() { Services = services }); }
public DefaultSecretValidator(IServiceProvider serviceProvider, PassawordContext context) { _serviceProvider = serviceProvider; _context = context; }