/// <summary> /// Encrypts (if needed), signs and converts the message to byte array /// </summary> /// <param name="data">The data to send on the queue</param> /// <param name="cryptoActions">The encryption manager</param> /// <param name="isEncrypted">A flag that indicates whether the message needs to be encrypted</param> /// <returns>A byte array representing the message</returns> protected byte[] CreateMessage(byte[] data, ICryptoActions cryptoActions, bool isEncrypted) { if (cryptoActions == null) { throw new ArgumentNullException(nameof(cryptoActions)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } // Sign the message var signature = cryptoActions.Sign(data); if (isEncrypted) { try { // Encrypt the message data = cryptoActions.Encrypt(data); } catch (CryptographicException ex) { throw new EncryptionException("Encryption failed", ex); } } else { Console.WriteLine("NOTICE: The enqueued message was NOT encrypted!"); } // Convert the message to byte array return(Utils.ToByteArray(new Message(isEncrypted, data, signature))); }
public AzureQueue(string queueName, ICloudQueueClientWrapper queueClient, ICryptoActions cryptoActions, bool isEncrypted) : base(cryptoActions) { m_queueClient = queueClient; m_isEncrypted = isEncrypted; m_isActive = false; m_queueName = queueName; m_isInitialized = false; }
public RabbitMQBus( string rabitMqUri, ICryptoActions cryptoActions, bool isEncrypted, string exchangeName, string queueName) : base(cryptoActions) { // Sanity if (string.IsNullOrEmpty(rabitMqUri) || string.IsNullOrEmpty(exchangeName) | string.IsNullOrEmpty(queueName)) { throw new ArgumentException("RabbitMQ uri, exchange name and queue name must be supplied"); } m_exchangeName = exchangeName; m_rabitMqUri = rabitMqUri; m_isEncrypted = isEncrypted; m_queueName = queueName; }
protected BaseQueue(ICryptoActions cryptoActions) { m_cryptoActions = cryptoActions ?? throw new ArgumentNullException(nameof(cryptoActions)); }