NServiceBus.RijndaelEncryptionServiceConfigValidations.OneOrMoreExpiredKeysHaveNoKeyIdentifier C# (CSharp) Method

OneOrMoreExpiredKeysHaveNoKeyIdentifier() public static method

public static OneOrMoreExpiredKeysHaveNoKeyIdentifier ( RijndaelEncryptionServiceConfig section ) : bool
section RijndaelEncryptionServiceConfig
return bool
        public static bool OneOrMoreExpiredKeysHaveNoKeyIdentifier(RijndaelEncryptionServiceConfig section)
        {
            return section
                .ExpiredKeys
                .Cast<RijndaelExpiredKey>()
                .Any(x => string.IsNullOrEmpty(x.KeyIdentifier));
        }

Usage Example

Example #1
0
 internal static void ValidateConfigSection(RijndaelEncryptionServiceConfig section)
 {
     if (section == null)
     {
         throw new Exception("No RijndaelEncryptionServiceConfig defined. Specify a valid 'RijndaelEncryptionServiceConfig' in the application's configuration file.");
     }
     if (section.ExpiredKeys == null)
     {
         throw new Exception("RijndaelEncryptionServiceConfig.ExpiredKeys is null.");
     }
     if (string.IsNullOrWhiteSpace(section.Key))
     {
         throw new Exception("The RijndaelEncryptionServiceConfig has an empty 'Key' property.");
     }
     if (RijndaelEncryptionServiceConfigValidations.ExpiredKeysHaveWhiteSpace(section))
     {
         throw new Exception("The RijndaelEncryptionServiceConfig has a 'ExpiredKeys' property defined however some keys have no 'Key' property set.");
     }
     if (RijndaelEncryptionServiceConfigValidations.OneOrMoreExpiredKeysHaveNoKeyIdentifier(section))
     {
         Log.Warn("The RijndaelEncryptionServiceConfig has a 'ExpiredKeys' property defined however some keys have no 'KeyIdentifier' property value. Verify if this is intentional.");
     }
     if (RijndaelEncryptionServiceConfigValidations.EncryptionKeyListedInExpiredKeys(section))
     {
         throw new Exception("The RijndaelEncryptionServiceConfig has a 'Key' that is also defined inside the 'ExpiredKeys'.");
     }
     if (RijndaelEncryptionServiceConfigValidations.ExpiredKeysHaveDuplicateKeys(section))
     {
         throw new Exception("The RijndaelEncryptionServiceConfig has overlapping ExpiredKeys defined. Ensure that no keys overlap in the 'ExpiredKeys' property.");
     }
     if (RijndaelEncryptionServiceConfigValidations.ConfigurationHasDuplicateKeyIdentifiers(section))
     {
         throw new Exception("The RijndaelEncryptionServiceConfig has duplicate KeyIdentifiers defined with the same key identifier. Key identifiers must be unique in the complete configuration section.");
     }
 }