public EncryptRegistration(EncryptionFactory encryptionFactory, EncryptStateBuilder stateBuilder) : base( stepId: "NServiceBusJsonEncryptionEncrypt", behavior: typeof(EncryptBehavior), description: "Invokes the encrypt logic", factoryMethod: _ => new EncryptBehavior(encryptionFactory, stateBuilder)) { InsertAfter("MutateOutgoingMessages"); }
/// <summary> /// Enable message property encryption. /// </summary> public static void EnableJsonEncryption(this EndpointConfiguration configuration, EncryptionFactory encryptionFactory, EncryptStateBuilder encryptStateBuilder, DecryptStateBuilder decryptStateBuilder) { Guard.AgainstNull(nameof(configuration), configuration); Guard.AgainstNull(nameof(encryptionFactory), encryptionFactory); Guard.AgainstNull(nameof(encryptStateBuilder), encryptStateBuilder); Guard.AgainstNull(nameof(decryptStateBuilder), decryptStateBuilder); var recoverability = configuration.Recoverability(); recoverability.AddUnrecoverableException <KeyIdAndIvHeaderMismatchException>(); var settings = configuration.GetSettings(); settings.Set(encryptStateBuilder); settings.Set(decryptStateBuilder); settings.Set(encryptionFactory); configuration.EnableFeature <EncryptionFeature>(); }
public EncryptBehavior(EncryptionFactory factory, EncryptStateBuilder stateBuilder) { this.factory = factory; this.stateBuilder = stateBuilder; }
/// <summary> /// Configures Rebus to encrypt messages. /// </summary> public static void EnableJsonEncryption(this RebusConfigurer configurer, EncryptionFactory encryptionFactory, EncryptStateBuilder encryptStateBuilder, DecryptStateBuilder decryptStateBuilder) { Guard.AgainstNull(nameof(configurer), configurer); Guard.AgainstNull(nameof(encryptionFactory), encryptionFactory); Guard.AgainstNull(nameof(encryptStateBuilder), encryptStateBuilder); Guard.AgainstNull(nameof(decryptStateBuilder), decryptStateBuilder); configurer.Options(options => { options.Decorate <IPipeline>( resolutionContext => { var pipeline = resolutionContext.Get <IPipeline>(); var injector = new PipelineStepInjector(pipeline); var decryptStep = new DecryptStep(encryptionFactory, decryptStateBuilder); injector.OnReceive(decryptStep, PipelineRelativePosition.Before, typeof(DeserializeIncomingMessageStep)); var encryptStep = new EncryptStep(encryptionFactory, encryptStateBuilder); injector.OnSend(encryptStep, PipelineRelativePosition.Before, typeof(SerializeOutgoingMessageStep)); return(injector); }); }); }