-
Notifications
You must be signed in to change notification settings - Fork 36
/
SymmetricDecryptionSettings.cs
31 lines (26 loc) · 1.1 KB
/
SymmetricDecryptionSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2020 Sergio Aquilini
// This code is licensed under MIT license (see LICENSE file for details)
using System;
namespace Silverback.Messaging.Encryption
{
/// <summary>
/// The decryption settings used to decrypt the messages.
/// </summary>
public class SymmetricDecryptionSettings : SymmetricEncryptionSettingsBase
{
/// <summary>
/// Gets or sets the function to be used to retrieve the decryption key.
/// </summary>
public Func<string?, byte[]>? KeyProvider { get; set; }
/// <inheritdoc cref="EncryptionSettings.Validate" />
public override void Validate()
{
if (string.IsNullOrEmpty(AlgorithmName))
throw new EndpointConfigurationException("AlgorithmName cannot be empty.");
if (KeyProvider == null && Key == null)
throw new EndpointConfigurationException("Key or DecryptionKey are required.");
if (KeyProvider != null && Key != null)
throw new EndpointConfigurationException("Cannot set both Key or DecryptionKey.");
}
}
}