-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix-3.3.17' into support-3.3
- Loading branch information
Showing
12 changed files
with
707 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...tion/NServiceBus.Encryption.Rijndael.Config/RijndaelEncryptionServiceConfigValidations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace NServiceBus | ||
{ | ||
using System.Linq; | ||
using NServiceBus.Config; | ||
|
||
internal static class RijndaelEncryptionServiceConfigValidations | ||
{ | ||
public static bool ConfigurationHasDuplicateKeyIdentifiers(RijndaelEncryptionServiceConfig section) | ||
{ | ||
// Combine all key identifier values, filter the empty ones, split them | ||
return section | ||
.ExpiredKeys | ||
.Cast<RijndaelExpiredKey>() | ||
.Select(x => x.KeyIdentifier) | ||
.Union(new[] { section.KeyIdentifier }) | ||
.Where(x => !string.IsNullOrEmpty(x)) | ||
.Select(x => x.Split(';')) | ||
.SelectMany(x => x) | ||
.GroupBy(x => x) | ||
.Any(x => x.Count() > 1); | ||
} | ||
|
||
public static bool ExpiredKeysHaveDuplicateKeys(RijndaelEncryptionServiceConfig section) | ||
{ | ||
var items = section | ||
.ExpiredKeys | ||
.Cast<RijndaelExpiredKey>() | ||
.ToList(); | ||
|
||
return items.Count != items.Select(x => x.Key).Distinct().Count(); | ||
} | ||
|
||
public static bool EncryptionKeyListedInExpiredKeys(RijndaelEncryptionServiceConfig section) | ||
{ | ||
return section | ||
.ExpiredKeys | ||
.Cast<RijndaelExpiredKey>() | ||
.Any(x => x.Key == section.Key); | ||
} | ||
|
||
public static bool OneOrMoreExpiredKeysHaveNoKeyIdentifier(RijndaelEncryptionServiceConfig section) | ||
{ | ||
return section | ||
.ExpiredKeys | ||
.Cast<RijndaelExpiredKey>() | ||
.Any(x => string.IsNullOrEmpty(x.KeyIdentifier)); | ||
} | ||
|
||
public static bool ExpiredKeysHaveWhiteSpace(RijndaelEncryptionServiceConfig section) | ||
{ | ||
return section | ||
.ExpiredKeys | ||
.Cast<RijndaelExpiredKey>() | ||
.Any(x => string.IsNullOrWhiteSpace(x.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.