Skip to content

Commit

Permalink
$ Renamed key identifier header.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonsmits committed Oct 19, 2015
1 parent 92cb908 commit abf7005
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Expand Up @@ -78,7 +78,7 @@ class RemoveKeyIdentifierHeaderMutator : IMutateIncomingTransportMessages, INeed
{
public void MutateIncoming(TransportMessage transportMessage)
{
transportMessage.Headers.Remove(Headers.KeyIdentifier);
transportMessage.Headers.Remove(Headers.RijndaelKeyIdentifier);
}

public void Customize(BusConfiguration configuration)
Expand Down
9 changes: 4 additions & 5 deletions src/NServiceBus.Core/Encryption/RijndaelEncryptionService.cs
Expand Up @@ -36,7 +36,6 @@ class RijndaelEncryptionService : IEncryptionService
{
static readonly ILog Log = LogManager.GetLogger<RijndaelEncryptionService>();
readonly IBus bus;
readonly string HeaderKey = Headers.KeyIdentifier;
readonly string encryptionKeyIdentifier;
byte[] encryptionKey;
IDictionary<string, byte[]> keys;
Expand Down Expand Up @@ -80,7 +79,7 @@ public string Decrypt(EncryptedValue encryptedValue)
}
else
{
Log.WarnFormat("Encrypted message has no '" + HeaderKey + "' header. Possibility of data corruption. Please upgrade endpoints that send message with encrypted properties.");
Log.WarnFormat("Encrypted message has no '" + Headers.RijndaelKeyIdentifier + "' header. Possibility of data corruption. Please upgrade endpoints that send message with encrypted properties.");
return DecryptUsingAllKeys(encryptedValue);
}
}
Expand Down Expand Up @@ -205,15 +204,15 @@ protected virtual void AddKeyIdentifierHeader()
{
var outgoingHeaders = bus.OutgoingHeaders;

if (!outgoingHeaders.ContainsKey(HeaderKey))
if (!outgoingHeaders.ContainsKey(Headers.RijndaelKeyIdentifier))
{
outgoingHeaders.Add(HeaderKey, encryptionKeyIdentifier);
outgoingHeaders.Add(Headers.RijndaelKeyIdentifier, encryptionKeyIdentifier);
}
}

protected virtual bool TryGetKeyIdentifierHeader(out string keyIdentifier)
{
return bus.CurrentMessageContext.Headers.TryGetValue(HeaderKey, out keyIdentifier);
return bus.CurrentMessageContext.Headers.TryGetValue(Headers.RijndaelKeyIdentifier, out keyIdentifier);
}
}
}
2 changes: 1 addition & 1 deletion src/NServiceBus.Core/Headers.cs
Expand Up @@ -217,7 +217,7 @@ public static class Headers
/// <summary>
/// The identifier to lookup the key to decrypt the encrypted data.
/// </summary>
public const string KeyIdentifier = "NServiceBus.KeyIdentifier";
public const string RijndaelKeyIdentifier = "NServiceBus.RijndaelKeyIdentifier";

/// <summary>
/// Get the header with the given key. Cannot be used to change its value.
Expand Down

0 comments on commit abf7005

Please sign in to comment.