diff --git a/src/OpenIddict.Client/OpenIddictClientBuilder.cs b/src/OpenIddict.Client/OpenIddictClientBuilder.cs index 51e96c95..b46a4468 100644 --- a/src/OpenIddict.Client/OpenIddictClientBuilder.cs +++ b/src/OpenIddict.Client/OpenIddictClientBuilder.cs @@ -180,6 +180,21 @@ public sealed class OpenIddictClientBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0056)); } + + /// + /// Registers multiple encryption keys. + /// + /// The security keys. + /// The instance. + public OpenIddictClientBuilder AddEncryptionKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddEncryptionKey(key)); + } /// /// Registers (and generates if necessary) a user-specific development encryption certificate. @@ -495,6 +510,21 @@ public sealed class OpenIddictClientBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple encryption certificates. + /// + /// The encryption certificates. + /// The instance. + public OpenIddictClientBuilder AddEncryptionCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddEncryptionCertificate(certificate)); + } /// /// Registers signing credentials. @@ -567,6 +597,21 @@ public sealed class OpenIddictClientBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); } + + /// + /// Registers multiple signing keys. + /// + /// The signing keys. + /// The instance. + public OpenIddictClientBuilder AddSigningKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddSigningKey(key)); + } /// /// Registers (and generates if necessary) a user-specific development signing certificate. @@ -910,6 +955,21 @@ public sealed class OpenIddictClientBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple signing certificates. + /// + /// The signing certificates. + /// The instance. + public OpenIddictClientBuilder AddSigningCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddSigningCertificate(certificate)); + } /// /// Adds a new client registration. diff --git a/src/OpenIddict.Server/OpenIddictServerBuilder.cs b/src/OpenIddict.Server/OpenIddictServerBuilder.cs index ab6c73c8..85b1ca2d 100644 --- a/src/OpenIddict.Server/OpenIddictServerBuilder.cs +++ b/src/OpenIddict.Server/OpenIddictServerBuilder.cs @@ -189,6 +189,21 @@ public sealed class OpenIddictServerBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0056)); } + + /// + /// Registers multiple encryption keys. + /// + /// The security keys. + /// The instance. + public OpenIddictServerBuilder AddEncryptionKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddEncryptionKey(key)); + } /// /// Registers (and generates if necessary) a user-specific development encryption certificate. @@ -504,6 +519,21 @@ public sealed class OpenIddictServerBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple encryption certificates. + /// + /// The encryption certificates. + /// The instance. + public OpenIddictServerBuilder AddEncryptionCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddEncryptionCertificate(certificate)); + } /// /// Registers signing credentials. @@ -576,6 +606,21 @@ public sealed class OpenIddictServerBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); } + + /// + /// Registers multiple signing keys. + /// + /// The signing keys. + /// The instance. + public OpenIddictServerBuilder AddSigningKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddSigningKey(key)); + } /// /// Registers (and generates if necessary) a user-specific development signing certificate. @@ -920,6 +965,21 @@ public sealed class OpenIddictServerBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple signing certificates. + /// + /// The signing certificates. + /// The instance. + public OpenIddictServerBuilder AddSigningCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddSigningCertificate(certificate)); + } /// /// Enables authorization code flow support. For more information diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs index 638600e1..7a657fc5 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs @@ -174,6 +174,21 @@ public sealed class OpenIddictValidationBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0056)); } + + /// + /// Registers multiple encryption keys. + /// + /// The security keys. + /// The instance. + public OpenIddictValidationBuilder AddEncryptionKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddEncryptionKey(key)); + } /// /// Registers an encryption certificate. @@ -351,6 +366,21 @@ public sealed class OpenIddictValidationBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple encryption certificates. + /// + /// The encryption certificates. + /// The instance. + public OpenIddictValidationBuilder AddEncryptionCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddEncryptionCertificate(certificate)); + } /// /// Registers signing credentials. @@ -423,6 +453,21 @@ public sealed class OpenIddictValidationBuilder throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); } + + /// + /// Registers multiple signing keys. + /// + /// The signing keys. + /// The instance. + public OpenIddictValidationBuilder AddSigningKeys(IEnumerable keys) + { + if (keys is null) + { + throw new ArgumentNullException(nameof(keys)); + } + + return keys.Aggregate(this, static (builder, key) => builder.AddSigningKey(key)); + } /// /// Registers a signing certificate. @@ -597,6 +642,21 @@ public sealed class OpenIddictValidationBuilder .OfType() .SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066))); } + + /// + /// Registers multiple signing certificates. + /// + /// The signing certificates. + /// The instance. + public OpenIddictValidationBuilder AddSigningCertificates(IEnumerable certificates) + { + if (certificates is null) + { + throw new ArgumentNullException(nameof(certificates)); + } + + return certificates.Aggregate(this, static (builder, certificate) => builder.AddSigningCertificate(certificate)); + } /// /// Registers the specified values as valid audiences. Setting the audiences is recommended