private static void ValidateConfiguration()

in src/identity/Common/Configuration/IdentityConfigurationUtils.cs [96:163]


    private static void ValidateConfiguration(IdentityConfiguration config)
    {
        if (config == null)
        {
            throw IdentityException.InvalidConfiguration(
                $"{nameof(IdentityConfiguration)} is null.");
        }

        foreach (var managedIdentity in config.Identities.ManagedIdentities)
        {
            if (string.IsNullOrEmpty(managedIdentity.ClientId))
            {
                throw IdentityException.InvalidConfiguration(
                    $"Managed Identity has an empty client ID.");
            }
        }

        foreach (var applicationIdentity in config.Identities.ApplicationIdentities)
        {
            if (string.IsNullOrEmpty(applicationIdentity.ClientId))
            {
                throw IdentityException.InvalidConfiguration(
                    $"Application Identity has an empty client ID.");
            }

            if (applicationIdentity.Credential == null)
            {
                throw IdentityException.InvalidConfiguration(
                    $"Application Identity must have credential details specified, client ID: " +
                    $"{applicationIdentity.ClientId}.");
            }

            if (applicationIdentity.Credential.CredentialType == CredentialType.FederatedCredential)
            {
                if (applicationIdentity.Credential.SecretConfiguration != null)
                {
                    throw IdentityException.InvalidConfiguration(
                        $"{nameof(SecretConfiguration)} must not be specified for a Federated " +
                        $"credential, client ID: {applicationIdentity.ClientId}.");
                }

                if (applicationIdentity.Credential.FederationConfiguration == null)
                {
                    throw IdentityException.InvalidConfiguration(
                        $"A federated credential must have an associated configuration, " +
                        $"client ID: {applicationIdentity.ClientId}.");
                }
            }

            if (applicationIdentity.Credential.CredentialType !=
                CredentialType.FederatedCredential)
            {
                if (applicationIdentity.Credential.SecretConfiguration == null)
                {
                    throw IdentityException.InvalidConfiguration(
                        $"Application Identity must have a {nameof(SecretConfiguration)} " +
                        $"specified, client ID: {applicationIdentity.ClientId}.");
                }

                if (applicationIdentity.Credential.SecretConfiguration.SecretStore == null)
                {
                    throw IdentityException.InvalidConfiguration(
                        $"Application Identity is missing a {nameof(SecretStore)}" +
                        $", client ID: {applicationIdentity.ClientId}.");
                }
            }
        }
    }