/// <summary>
        /// Serialize messages using the raw JSON message serializer
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseRawJsonSerializer(this IEventHubFactoryConfigurator configurator)
        {
            configurator.SetMessageSerializer(() => new RawJsonMessageSerializer());

            // configurator.AddMessageDeserializer(RawJsonMessageSerializer.RawJsonContentType,
            //     () => new RawJsonMessageDeserializer(RawJsonMessageSerializer.Deserializer));
        }
        public static void UseEncryptedSerializer(this IEventHubFactoryConfigurator configurator, ICryptoStreamProvider streamProvider)
        {
            configurator.SetMessageSerializer(() => new EncryptedMessageSerializer(streamProvider));

            // configurator.AddMessageDeserializer(EncryptedMessageSerializer.EncryptedContentType,
            //     () => new EncryptedMessageDeserializer(BsonMessageSerializer.Deserializer, streamProvider));
        }
        /// <summary>
        /// Serialize messages using the BSON message serializer with AES Encryption
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="symmetricKey">
        /// Cryptographic key for both encryption of plaintext message and decryption of ciphertext message
        /// </param>
        public static void UseEncryption(this IEventHubFactoryConfigurator configurator, byte[] symmetricKey)
        {
            var keyProvider    = new ConstantSecureKeyProvider(symmetricKey);
            var streamProvider = new AesCryptoStreamProviderV2(keyProvider);

            configurator.UseEncryptedSerializerV2(streamProvider);
        }
Beispiel #4
0
        /// <summary>
        /// Subscribe to EventHub messages using default consumer group <see cref="EventHubConsumerClient.DefaultConsumerGroupName" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="eventHubName">Event Hub name</param>
        /// <param name="configure"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public static void ReceiveEndpoint(this IEventHubFactoryConfigurator configurator, string eventHubName,
                                           Action <IEventHubReceiveEndpointConfigurator> configure)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            configurator.ReceiveEndpoint(eventHubName, EventHubConsumerClient.DefaultConsumerGroupName, configure);
        }
 /// <summary>
 /// Serialize messages using the BSON message serializer
 /// </summary>
 /// <param name="configurator"></param>
 public static void UseBsonSerializer(this IEventHubFactoryConfigurator configurator)
 {
     configurator.SetMessageSerializer(() => new BsonMessageSerializer());
 }
 /// <summary>
 /// Configure the serialization settings used to create the BSON message deserializer
 /// </summary>
 /// <param name="configurator"></param>
 /// <param name="configure"></param>
 /// <remarks>
 /// These settings are applied globally to <see cref="JsonMessageSerializer.SerializerSettings"/>.
 /// </remarks>
 public static void ConfigureBsonDeserializer(this IEventHubFactoryConfigurator configurator,
                                              Func <JsonSerializerSettings, JsonSerializerSettings> configure)
 {
     BsonMessageSerializer.DeserializerSettings = configure(BsonMessageSerializer.DeserializerSettings);
 }
        /// <summary>
        /// Serialize messages using the BSON message serializer with AES Encryption
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="keyProvider">
        /// The custom key provider to provide the symmetric key for encryption of plaintext message and decryption of ciphertext message
        /// </param>
        public static void UseEncryption(this IEventHubFactoryConfigurator configurator, ISecureKeyProvider keyProvider)
        {
            var streamProvider = new AesCryptoStreamProviderV2(keyProvider);

            configurator.UseEncryptedSerializerV2(streamProvider);
        }