<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<!--
    This is the configuration file for internal APIs
-->
<internalApis>
    <apis>
        {% for api in internal_api %}
        <api name="{{api.api_name}}" protocol="{{api.protocols}}" class="{{api.class}}"/>
        {% endfor %}
        <api name="{{management_api.name}}" protocol="{{management_api.protocols}}" class="{{management_api.class}}">
            <handlers>
                {% if management_api_token_handler.enable == true %}
                <handler name="{{management_api.handler.name}}" class="{{management_api.handler.class}}">
                    <TokenStoreConfig>
                        <MaxSize>{{management_api.handler.token_store_config.max_size}}</MaxSize>
                        <TokenCleanupTaskInterval>{{management_api.handler.token_store_config.clean_up_interval}}</TokenCleanupTaskInterval><!--Seconds /-->
                        <RemoveOldestTokenOnOverflow>{{management_api.handler.token_store_config.remove_oldest_token_on_overflow}}</RemoveOldestTokenOnOverflow>
                    </TokenStoreConfig>
                    <TokenConfig>
                        <expiry>{{management_api.handler.token_config.expiry}}</expiry><!--Seconds /-->
                        <size>{{management_api.handler.token_config.size}}</size>
                    </TokenConfig>
                    <UserStore>
                        <users>
                            {% for user in management_api.handler.user_store.users %}
                            <user>
                                <username>{{user.user.name}}</username>
                                <password>{{user.user.password}}</password>
                            </user>
                            {% endfor %}
                        </users>
                    </UserStore>
                </handler>
                {% endif %}
                {% if management_api_basic_security_handler.enable == true %}
                <handler name="{{management_api.security_handler.name}}"
                         class="{{management_api.security_handler.class}}">
                    <UserStore>
                        <users>
                            {% for user in management_api.handler.user_store.users %}
                            <user>
                                <username>{{user.user.name}}</username>
                                <password>{{user.user.password}}</password>
                            </user>
                            {% endfor %}
                        </users>
                    </UserStore>
                </handler>
                {% endif %}
            </handlers>
            <cors>
                <enabled>{{management_api.cors.enabled}}</enabled>
                <allowedOrigins>{{management_api.cors.allowed_origins}}</allowedOrigins>
                <allowedHeaders>{{management_api.cors.allowed_headers}}</allowedHeaders>
            </cors>
        </api>
    </apis>
    <sslConfig>
        {% for parameter_key,parameter_value in internal_api_ssl_config.parameter.items() %}
        <parameter name="{{parameter_key}}">{{parameter_value}}</parameter>
        {% endfor %}
        <parameter name="keystore">
            <KeyStore>
                <Location>{{internal_api_ssl_config.key_store.location}}</Location>
                <Type>{{internal_api_ssl_config.key_store.type}}</Type>
                <Password>{{internal_api_ssl_config.key_store.password}}</Password>
                <KeyPassword>{{internal_api_ssl_config.key_store.key_password}}</KeyPassword>
            </KeyStore>
        </parameter>
        <parameter name="truststore">
            <TrustStore>
                <Location>{{internal_api_ssl_config.trust_store.location}}</Location>
                <Type>{{internal_api_ssl_config.trust_store.type}}</Type>
                <Password>{{internal_api_ssl_config.trust_store.password}}</Password>
            </TrustStore>
        </parameter>
        <parameter name="certificateRevocationVerifier">
            <CertificateRevocationVerifier enable="{{internal_api_ssl_config.certificate_revocation_verifier_enabled}}">
                <CacheSize>{{internal_api_ssl_config.certificate_revocation_verifier.cache_size}}</CacheSize>
                <CacheDelay>{{internal_api_ssl_config.certificate_revocation_verifier.cache_delay}}</CacheDelay>
            </CertificateRevocationVerifier>
        </parameter>
    </sslConfig>
</internalApis>
