/// <summary>
        /// Initializes a new instance of the <see cref="KeyRotationConfig" /> class.
        /// </summary>
        /// <param name="keyVault">The config to represent a Azure Key Vault secret.</param>
        /// <param name="servicePrincipal">The config to authenticate to Azure resources.</param>
        /// <param name="serviceBusNamespace">The config to represent a Azure Service Bus namespace.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when the <paramref name="keyVault"/>, <paramref name="servicePrincipal"/>, or <paramref name="serviceBusNamespace"/> is <c>null</c>.
        /// </exception>
        public KeyRotationConfig(KeyVaultConfig keyVault, ServicePrincipal servicePrincipal, ServiceBusNamespace serviceBusNamespace)
        {
            Guard.NotNull(keyVault, nameof(keyVault));
            Guard.NotNull(servicePrincipal, nameof(servicePrincipal));
            Guard.NotNull(serviceBusNamespace, nameof(serviceBusNamespace));

            KeyVault            = keyVault;
            ServicePrincipal    = servicePrincipal;
            ServiceBusNamespace = serviceBusNamespace;
        }
示例#2
0
        /// <summary>
        /// Gets all the configuration to run a complete key rotation integration test.
        /// </summary>
        public KeyRotationConfig GetKeyRotationConfig()
        {
            var azureEnv = new ServiceBusNamespace(
                tenantId: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:TenantId"),
                azureSubscriptionId: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:SubscriptionId"),
                resourceGroup: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:ResourceGroupName"),
                @namespace: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:Namespace"),
                queueName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:QueueName"),
                topicName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:TopicName"),
                authorizationRuleName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:AuthorizationRuleName"));

            var servicePrincipal = new ServicePrincipal(
                clientId: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientId"),
                clientSecret: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientSecret"),
                clientSecretKey: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientSecretKey"));

            var secret = new KeyVaultConfig(
                vaultUri: _config.GetValue <string>("Arcus:KeyRotation:KeyVault:VaultUri"),
                secretName: _config.GetValue <string>("Arcus:KeyRotation:KeyVault:ConnectionStringSecretName"),
                secretNewVersionCreated: new KeyVaultEventEndpoint(
                    _config.GetValue <string>("Arcus:KeyRotation:KeyVault:SecretNewVersionCreated:ServiceBusConnectionStringWithTopicEndpoint")));

            return(new KeyRotationConfig(secret, servicePrincipal, azureEnv));
        }