<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../xslt/schema.xslt"?>

<!-- (C) 2011 OpenStack LLC., All Rights Reserved -->

<schema
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:identity="http://docs.openstack.org/identity/api/v2.0"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
    xmlns:xsdxt="http://docs.rackspacecloud.com/xsd-ext/v1.0"
    xmlns:atom="http://www.w3.org/2005/Atom"
    targetNamespace="http://docs.openstack.org/identity/api/v2.0"
>

    <!-- Import ATOM specific schema definitions -->
    <import vc:minVersion="1.1" namespace="http://www.w3.org/2005/Atom"
            schemaLocation="atom/atom.xsd" />

    <!-- Elements -->
    <element name="auth" type="identity:AuthenticationRequest"/>
    <element name="credential" type="identity:CredentialType"/>
    <element name="credentials" type="identity:CredentialListType"/>
    <element name="passwordCredentials" type="identity:PasswordCredentialsRequiredUsername" substitutionGroup="identity:credential"/>
    
    <!-- Complex Types -->
    <complexType name="CredentialType" abstract="true">
        <annotation>
            <xsd:documentation
                xml:lang="EN"
                xmlns="http://www.w3.org/1999/xhtml">
                <p>
                    Base type for credential in Keystone.
                </p>
            </xsd:documentation>
        </annotation>
        <sequence>
            <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
        </sequence>
        <anyAttribute namespace="##other" processContents="lax"/>        
    </complexType>
    
    <complexType name="AuthenticationRequest">
        <sequence>
           <element ref="identity:credential" minOccurs="1"/>
           <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>        
        </sequence>
        <attribute name="tenantId" type="xsd:string" use="optional"/>
        <anyAttribute namespace="##other" processContents="lax"/>                
    </complexType>

    <complexType name="PasswordCredentialsBase">
        <complexContent>
            <extension base="identity:CredentialType">
                <attribute name="username" type="xsd:string" use="optional" />
                <attribute name="password" type="xsd:string" use="required" />
            </extension>
        </complexContent>
    </complexType>

    <complexType name="PasswordCredentialsWithoutUsername">
        <complexContent>
            <restriction base="identity:PasswordCredentialsBase">
                <attribute name="username" type="xsd:string" use="prohibited" />
                <attribute name="password" type="xsd:string" use="required" />
            </restriction>
        </complexContent>
    </complexType>

    <complexType name="PasswordCredentialsRequiredUsername">
        <complexContent>
            <restriction base="identity:PasswordCredentialsBase">
                <attribute name="username" type="xsd:string" use="required" />
                <attribute name="password" type="xsd:string" use="required" />
            </restriction>
        </complexContent>
    </complexType>

    <complexType name="CredentialListType">
        <sequence>
           <element ref="identity:credential" minOccurs="1" maxOccurs="unbounded"/>
        </sequence>
        <anyAttribute namespace="##other" processContents="lax"/>
    </complexType>
</schema>
