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

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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:elytron:1.0"
            xmlns="urn:elytron:1.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <!-- File-backed realm elements -->

    <xsd:element name="identity" type="identity-type"/>

    <xsd:complexType name="identity-type">
        <xsd:all minOccurs="1" maxOccurs="1">
            <xsd:element name="credentials" type="credentials-type" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="attributes" type="attributes-type" minOccurs="0" maxOccurs="1"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="credentials-type">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="password" type="credential-type"/>
            <xsd:element name="otp" type="otp-credential-type"/>
            <xsd:element name="public-key" type="credential-type"/>
            <xsd:element name="certificate" type="credential-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="attributes-type">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="attribute" type="attribute-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="credential-type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="algorithm" type="xsd:string" use="optional"/>
                <xsd:attribute name="format" type="xsd:string" use="optional"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="otp-credential-type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="algorithm" type="xsd:string" use="optional"/>
                <xsd:attribute name="hash" type="xsd:string" use="optional"/>
                <xsd:attribute name="seed" type="xsd:string" use="optional"/>
                <xsd:attribute name="sequence" type="xsd:string" use="optional"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="attribute-type">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="value" type="xsd:string" use="required"/>
    </xsd:complexType>

    <!-- Authentication client elements -->

    <xsd:element name="authentication-client" type="authentication-client-type"/>

    <xsd:complexType name="authentication-client-type">
        <xsd:all>
            <xsd:element name="key-stores" type="key-stores-type" minOccurs="0"/>
            <xsd:element name="rules" type="authentication-client-rules-type" minOccurs="0"/>
            <xsd:element name="net-authenticator" type="empty-type" minOccurs="0"/>
            <xsd:element name="ssl-context-rules" type="ssl-context-rules-type" minOccurs="0"/>
            <xsd:element name="ssl-contexts" type="ssl-contexts-type" minOccurs="0"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="ssl-contexts-type">
        <xsd:all>
            <xsd:element name="key-store-ssl-certificate" type="key-store-ref-type" minOccurs="0"/>
            <xsd:element name="cipher-suite" type="ssl-cipher-selector-type" minOccurs="0"/>
            <xsd:element name="protocol" type="names-list-type" minOccurs="0"/>
            <xsd:element name="provider-name" type="name-type" minOccurs="0"/>
            <xsd:choice minOccurs="0">
                <xsd:element name="use-system-providers" type="empty-type"/>
                <xsd:element name="use-service-loader-providers" type="module-ref-type"/>
            </xsd:choice>
        </xsd:all>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="ssl-context-rules-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="rule" type="ssl-context-rule-type" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:group name="match-rule-group">
        <xsd:all>
            <xsd:element name="match-no-userinfo" type="empty-type" minOccurs="0"/>
            <xsd:element name="match-userinfo" type="name-type" minOccurs="0"/>
            <xsd:element name="match-protocol" type="name-type" minOccurs="0"/>
            <xsd:element name="match-host" type="name-type" minOccurs="0"/>
            <xsd:element name="match-path" type="name-type" minOccurs="0"/>
            <xsd:element name="match-port" type="port-number-type" minOccurs="0"/>
            <xsd:element name="match-urn" type="name-type" minOccurs="0"/>
            <xsd:element name="match-domain" type="name-type" minOccurs="0"/>
            <xsd:element name="match-abstract-type" type="abstract-type-type" minOccurs="0"/>
            <xsd:element name="match-purpose" type="names-list-type" minOccurs="0"/>
        </xsd:all>
    </xsd:group>

    <xsd:complexType name="ssl-context-rule-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <xsd:group ref="match-rule-group" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:choice>
                <xsd:element name="use-ssl-context" type="name-type"/>
                <xsd:element name="use-default-ssl-context" type="empty-type"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="authentication-client-rules-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="rule" type="authentication-client-rule-type" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="authentication-client-rule-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <xsd:group ref="match-rule-group" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:all>
                <xsd:element name="set-host" type="name-type" minOccurs="0"/>
                <xsd:element name="set-port" type="port-number-simple-type" minOccurs="0"/>
                <xsd:element name="set-protocol" type="name-type" minOccurs="0"/>
                <xsd:choice minOccurs="0">
                    <xsd:element name="set-user-name" type="name-type" minOccurs="0"/>
                    <xsd:element name="set-anonymous" type="empty-type" minOccurs="0"/>
                </xsd:choice>
                <xsd:element name="set-mechanism-realm" type="optional-name-type" minOccurs="0"/>
                <xsd:element name="rewrite-user-name-regex" type="regex-substitution-type" minOccurs="0"/>
                <xsd:element name="allow-all-sasl-mechanisms" type="empty-type" minOccurs="0"/>
                <xsd:element name="allow-sasl-mechanisms" type="names-list-type" minOccurs="0"/>
                <xsd:element name="forbid-sasl-mechanisms" type="names-list-type" minOccurs="0"/>
                <xsd:element name="set-mechanism-properties" type="properties-type" minOccurs="0"/>
                <xsd:element name="key-store-credential" type="key-store-ref-type" minOccurs="0"/>
                <xsd:element name="clear-password" type="clear-password-type" minOccurs="0"/>
                <xsd:element name="set-authorization-name" type="name-type" minOccurs="0"/>
                <xsd:choice minOccurs="0">
                    <xsd:element name="use-system-providers" type="empty-type"/>
                    <xsd:element name="use-service-loader-providers" type="module-ref-type"/>
                </xsd:choice>
                <xsd:choice minOccurs="0">
                    <xsd:element name="use-provider-sasl-factory" type="empty-type" />
                    <xsd:element name="use-service-loader-sasl-factory" type="module-ref-type" />
                </xsd:choice>
            </xsd:all>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="key-stores-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="key-store" type="key-store-type"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="key-store-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <!-- Access source type -->
            <xsd:choice minOccurs="1" maxOccurs="1">
                <xsd:element name="file" type="name-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="load-from" type="uri-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="resource" type="name-type" minOccurs="1" maxOccurs="1"/>
            </xsd:choice>
            <!-- Protection parameter -->
            <xsd:choice minOccurs="0" maxOccurs="1">
                <xsd:element name="key-store-credential" type="key-store-ref-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="key-store-clear-password" type="clear-password-type" minOccurs="1" maxOccurs="1"/>
            </xsd:choice>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
        <xsd:attribute name="provider" type="xsd:string" use="optional"/>
        <xsd:attribute name="wrap-passwords" type="xsd:boolean" use="optional" default="false"/>
    </xsd:complexType>

    <xsd:complexType name="key-store-ref-type">
        <!-- Protection parameter -->
        <xsd:choice minOccurs="0" maxOccurs="1"><commit_msg>[ELY-784] Part 1: Fix everything that can be fixed in the schema alone by changing choice-inside-all to substitution groups with abstract elements<commit_after><?xml version="1.0" encoding="UTF-8"?>

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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:elytron:1.0"
            xmlns="urn:elytron:1.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <!-- File-backed realm elements -->

    <xsd:element name="identity" type="identity-type"/>

    <xsd:complexType name="identity-type">
        <xsd:all minOccurs="1" maxOccurs="1">
            <xsd:element name="credentials" type="credentials-type" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="attributes" type="attributes-type" minOccurs="0" maxOccurs="1"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="credentials-type">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="password" type="credential-type"/>
            <xsd:element name="otp" type="otp-credential-type"/>
            <xsd:element name="public-key" type="credential-type"/>
            <xsd:element name="certificate" type="credential-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="attributes-type">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="attribute" type="attribute-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="credential-type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="algorithm" type="xsd:string" use="optional"/>
                <xsd:attribute name="format" type="xsd:string" use="optional"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="otp-credential-type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="algorithm" type="xsd:string" use="optional"/>
                <xsd:attribute name="hash" type="xsd:string" use="optional"/>
                <xsd:attribute name="seed" type="xsd:string" use="optional"/>
                <xsd:attribute name="sequence" type="xsd:string" use="optional"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="attribute-type">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="value" type="xsd:string" use="required"/>
    </xsd:complexType>

    <!-- Authentication client elements -->

    <xsd:element name="authentication-client" type="authentication-client-type"/>

    <xsd:complexType name="authentication-client-type">
        <xsd:all>
            <xsd:element name="key-stores" type="key-stores-type" minOccurs="0"/>
            <xsd:element name="rules" type="authentication-client-rules-type" minOccurs="0"/>
            <xsd:element name="net-authenticator" type="empty-type" minOccurs="0"/>
            <xsd:element name="ssl-context-rules" type="ssl-context-rules-type" minOccurs="0"/>
            <xsd:element name="ssl-contexts" type="ssl-contexts-type" minOccurs="0"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="ssl-contexts-type">
        <xsd:all>
            <xsd:element name="key-store-ssl-certificate" type="key-store-ref-type" minOccurs="0"/>
            <xsd:element name="cipher-suite" type="ssl-cipher-selector-type" minOccurs="0"/>
            <xsd:element name="protocol" type="names-list-type" minOccurs="0"/>
            <xsd:element name="provider-name" type="name-type" minOccurs="0"/>
            <xsd:element ref="abstract-providers" minOccurs="0"/>
        </xsd:all>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="ssl-context-rules-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="rule" type="ssl-context-rule-type" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:group name="match-rule-group">
        <xsd:all>
            <xsd:element name="match-no-userinfo" type="empty-type" minOccurs="0"/>
            <xsd:element name="match-userinfo" type="name-type" minOccurs="0"/>
            <xsd:element name="match-protocol" type="name-type" minOccurs="0"/>
            <xsd:element name="match-host" type="name-type" minOccurs="0"/>
            <xsd:element name="match-path" type="name-type" minOccurs="0"/>
            <xsd:element name="match-port" type="port-number-type" minOccurs="0"/>
            <xsd:element name="match-urn" type="name-type" minOccurs="0"/>
            <xsd:element name="match-domain" type="name-type" minOccurs="0"/>
            <xsd:element name="match-abstract-type" type="abstract-type-type" minOccurs="0"/>
            <xsd:element name="match-purpose" type="names-list-type" minOccurs="0"/>
        </xsd:all>
    </xsd:group>

    <xsd:complexType name="ssl-context-rule-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <xsd:group ref="match-rule-group" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:choice>
                <xsd:element name="use-ssl-context" type="name-type"/>
                <xsd:element name="use-default-ssl-context" type="empty-type"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="authentication-client-rules-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="rule" type="authentication-client-rule-type" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="authentication-client-rule-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <xsd:group ref="match-rule-group" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:all>
                <xsd:element name="set-host" type="name-type" minOccurs="0"/>
                <xsd:element name="set-port" type="port-number-simple-type" minOccurs="0"/>
                <xsd:element name="set-protocol" type="name-type" minOccurs="0"/>
                <xsd:element ref="abstract-user-spec"/>
                <xsd:element name="set-mechanism-realm" type="optional-name-type" minOccurs="0"/>
                <xsd:element name="rewrite-user-name-regex" type="regex-substitution-type" minOccurs="0"/>
                <xsd:element name="allow-all-sasl-mechanisms" type="empty-type" minOccurs="0"/>
                <xsd:element name="allow-sasl-mechanisms" type="names-list-type" minOccurs="0"/>
                <xsd:element name="forbid-sasl-mechanisms" type="names-list-type" minOccurs="0"/>
                <xsd:element name="set-mechanism-properties" type="properties-type" minOccurs="0"/>
                <xsd:element name="key-store-credential" type="key-store-ref-type" minOccurs="0"/>
                <xsd:element name="clear-password" type="clear-password-type" minOccurs="0"/>
                <xsd:element name="set-authorization-name" type="name-type" minOccurs="0"/>
                <xsd:element ref="abstract-providers" minOccurs="0"/>
                <xsd:element ref="abstract-sasl-factories" minOccurs="0"/>
            </xsd:all>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="abstract-user-spec" abstract="true"/>
    <xsd:element name="set-user-name" substitutionGroup="abstract-user-spec" type="name-type" />
    <xsd:element name="set-anonymous" substitutionGroup="abstract-user-spec" type="empty-type" />

    <xsd:element name="abstract-providers" abstract="true"/>
    <xsd:element name="use-system-providers" substitutionGroup="abstract-providers" type="empty-type"/>
    <xsd:element name="use-service-loader-providers" substitutionGroup="abstract-providers" type="module-ref-type"/>

    <xsd:element name="abstract-sasl-factories" abstract="true"/>
    <xsd:element name="use-provider-sasl-factory" substitutionGroup="abstract-sasl-factories" type="empty-type" />
    <xsd:element name="use-service-loader-sasl-factory" substitutionGroup="abstract-sasl-factories" type="module-ref-type" />

    <xsd:complexType name="key-stores-type">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="key-store" type="key-store-type"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="key-store-type">
        <xsd:sequence minOccurs="1" maxOccurs="1">
            <!-- Access source type -->
            <xsd:choice minOccurs="1" maxOccurs="1">
                <xsd:element name="file" type="name-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="load-from" type="uri-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="resource" type="name-type" minOccurs="1" maxOccurs="1"/>
            </xsd:choice>
            <!-- Protection parameter -->
            <xsd:choice minOccurs="0" maxOccurs="1">
                <xsd:element name="key-store-credential" type="key-store-ref-type" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="key-store-clear-password" type="clear-password-type" minOccurs="1" maxOccurs="1"/>
            </xsd:choice>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
        <xsd:attribute name="provider" type="xsd:string" use="optional"/>
        <xsd:attribute name="wrap-passwords" type="xsd:boolean" use="optional" default="false"/>
    </xsd:complexType>

    <xsd:complexType name="key-store-ref-type">
        <!-- Protection parameter -->
        <xsd:choice minOccurs="0" maxOccurs="1">
{'fraction_non_alphanumeric': 0.16673088036987094, 'fraction_numerical': 0.009487574648429975, 'mean_word_length': 2.938732928679818, 'pattern_counts': {'":': 0, '<': 322, '<?xml version=': 2, '>': 322, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657466', 'n_tokens_mistral': 6678, 'n_tokens_neox': 6166, 'n_words': 1092}