<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="urn:wildfly:credential-reference:1.0"
           xmlns="urn:wildfly:credential-reference:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="1.0">

    <!-- Shared Credential Reference Types
         See README.md for a description of what needs to be done if you are adding a new version of this schema. -->
    <xs:attributeGroup name="credentialReferenceStoreBased">
        <xs:annotation>
            <xs:documentation>
                Group of attributes used when referencing credential through credential store.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="store" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Credential store name used to fetch credential with given 'alias' from.
                    Credential store name has to be defined elsewhere.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="alias" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Alias of credential in the credential store.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="type" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Type of credential to be fetched from credential store.
                    It is usually fully qualified class name.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:complexType name="credentialReferenceType">
        <xs:annotation>
            <xs:documentation>
                Credential to be used by the configuration.
            </xs:documentation>
        </xs:annotation>
        <xs:attributeGroup ref="credentialReferenceStoreBased"/>
        <xs:attribute name="clear-text" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    Credential/password in clear text. Use just for testing purpose.
                    Otherwise use credential store to mask the actual credential from your configuration.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

</xs:schema>
