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

<!--
  ~ JBoss, Home of Professional Open Source
  ~ Copyright 2019, Red Hat, Inc., and individual contributors as indicated
  ~ by the @authors tag.
  ~
  ~ 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.
  -->

<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>
