#!/usr/bin/env bash

set -x

cat<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CoreConfiguration xmlns="http:/www.bos_bremen.de/2009/06/eID-Server-CoreConfig">
    <ServerUrl>https://${PUBLIC_HOSTNAME}/eidas-middleware</ServerUrl>
    <sessionManagerUsesDatabase>true</sessionManagerUsesDatabase>
    <sessionMaxPendingRequests>500</sessionMaxPendingRequests>
    <certificateWarningMargin>200</certificateWarningMargin>
    <TimerConfiguration>
        <certRenewal length="2" unit="11"/>
        <blacklistRenewal length="2" unit="11"/>
        <masterAndDefectListRenewal length="2" unit="11"/>
    </TimerConfiguration>
    <ServiceProvider entityID="qa-se-de-middleware" enabled="true">
        <EPAConnectorConfiguration updateCVC="true">
            <CVCRefID>qa-se-de-middleware</CVCRefID>
            <PkiConnectorConfiguration>
                <blackListTrustAnchor>MIIGqjCCBJKgAwIBAgIIas94+G4kaTEwDQYJKoZIhvcNAQENBQAwWDEgMB4GA1UEAwwXR292ZXJuaWt1cyBSb290IENBIDQ6UE4xFjAUBgNVBAoMDUdvdmVybmlrdXMgS0cxDzANBgNVBAcMBkJyZW1lbjELMAkGA1UEBhMCREUwHhcNMjAwMzIzMTAwMzI1WhcNMzUwMzIwMTAwMzI1WjBsMRwwGgYDVQQDDBNHb3Zlcm5pa3VzIENBIDEyOlBOMRYwFAYDVQQLDA1Hb3Zlcm5pa3VzIENBMRYwFAYDVQQKDA1Hb3Zlcm5pa3VzIEtHMQ8wDQYDVQQHDAZCcmVtZW4xCzAJBgNVBAYTAkRFMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwXI//LJjA/WpmpQXFfWVsHUwD2UeeUIZyZt5jLto/+CBBDdlz09LY/Qr82ccJ51wjDszE2ubylSH6V1zMxbOwV+rVH65l4e6YkXuS1h/mJVRMg1hu8/yvlt0qtdUIzso4kKXpY2zc/5rBg0l4rZCo48OddX4a9zdxfHcqwbhpqlDw2E13VTK+zd65Y9hYKscdPzK0ZwEgF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wQYMBaAFHD8PNdfzGkLdI7YpGbmsFvP3TmdMB0GA1UdDgQWBBSFeLqnCPkXciiQQOzwVzQDNiNWBDAOBgNVHQ8BAf8EBAMCB4AwKwYDVR0QBCQwIoAPMjAxNTA5MjMwODU1MjZagQ8yMDE4MDkyMzIzNTk1OVowFgYDVR0gBA8wDTALBgkEAH8ABwMBAQEwUQYDVR0RBEowSIEYY3NjYS1nZXJtYW55QGJzaS5idW5kLmRlhhxodHRwczovL3d3dy5ic2kuYnVuZC5kZS9jc2NhpA4wDDEKMAgGA1UEBwwBRDBRBgNVHRIESjBIgRhjc2NhLWdlcm1hbnlAYnNpLmJ1bmQuZGWGHGh0dHBzOi8vd3d3LmJzaS5idW5kLmRlL2NzY2GkDjAMMQowCAYDVQQHDAFEMBQGA1UdJQEB/wQKMAgGBmeBCAEBAzA1BgNVHR8ELjAsMCqgKKAmhiRodHRwOi8vd3d3LmJzaS5idW5kLmRlL3Rlc3RfY3NjYV9jcmwwCgYIKoZIzj0EAwMDZwAwZAIwPAvVTvhJuX0dIyd7Ouv0t03J2KA08JehN+RA6oVU7xvS7RbCLIcKNYqVRnC4eJrOAjB1X89X1lH/0Fq3HH1tKXw3ELw62dBrHeHGsn3kcWNXxYqr5iRobwJru3FPk5ka34s=</defectListTrustAnchor>
                <policyImplementationId>govDvca</policyImplementationId>
                <sslKeys id="default">
                    <serverCertificate><%= @demw_tls_server_cert %></serverCertificate>
                    <clientCertificate><%= @demw_tls_client_cert %></clientCertificate>
                    <clientKey><%= @demw_tls_client_key %></clientKey>
                </sslKeys>
                <terminalAuthService sslKeysId="default">
                    <url>https://dvca-r1.governikus-eid.de/gov_dvca/ta-service</url>
                </terminalAuthService>
                <restrictedIdService sslKeysId="default">
                    <url>https://dvca-r1.governikus-eid.de/gov_dvca/ri-service</url>
                </restrictedIdService>
                <passiveAuthService sslKeysId="default">
                    <url>https://dvca-r1.governikus-eid.de/gov_dvca/pa-service</url>
                </passiveAuthService>
                <dvcaCertDescriptionService sslKeysId="default">
                    <url>https://dvca-r1.governikus-eid.de/gov_dvca/certDesc-service</url>
                </dvcaCertDescriptionService>
            </PkiConnectorConfiguration>
            <PaosReceiverURL>https://${PUBLIC_HOSTNAME}/eidas-middleware/paosreceiver</PaosReceiverURL>
            <hoursRefreshCVCBeforeExpires>240</hoursRefreshCVCBeforeExpires>
        </EPAConnectorConfiguration>
    </ServiceProvider>
</CoreConfiguration>
EOF
