<?xml version="1.0" encoding="UTF-8"?>
<!--
  _=_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_=
  Repose
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  Copyright (C) 2010 - 2015 Rackspace US, Inc.
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  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"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns="http://docs.openrepose.org/repose/keystone-v2-basic-auth/v1.0"
           targetNamespace="http://docs.openrepose.org/repose/keystone-v2-basic-auth/v1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">

    <!-- Elements -->
    <xs:element name="keystone-v2-basic-auth" type="KeystoneV2BasicAuthConfig"/>

    <!-- Types -->
    <xs:complexType name="KeystoneV2BasicAuthConfig">
        <xs:annotation>
            <xs:documentation>
                <html:p>The root config type for the Keystone v2 Basic Auth filter configuration file.</html:p>
            </xs:documentation>
        </xs:annotation>

        <xs:sequence>
            <xs:element name="delegating" type="DelegatingType" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="keystone-v2-service-uri" type="xs:anyURI" use="required">
            <xs:annotation>
                <xs:documentation>
                    <html:p>
                        The target Keystone v2 endpoint URI for credential requests including scheme, host,
                        and port to service.
                    </html:p>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="token-cache-timeout-millis" type="ZeroOrPositiveInteger" use="optional" default="600000">
            <xs:annotation>
                <xs:documentation>
                    <html:p>Time in milliseconds to cache auth token. The default is 10 minutes. A value of Zero (0) is
                        disabled.
                    </html:p>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="connection-pool-id" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    <html:p>Http Connection pool ID to use when talking to Keystone v2 Identity</html:p>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="secret-type" type="SecretType" use="optional" default="api-key">
            <xs:annotation>
                <xs:documentation>
                    <html:p>
                        Type of the secret portion of the authentication credentials (e.g., api key or password).
                    </html:p>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="DelegatingType">
        <xs:annotation>
            <xs:documentation>
                <html:p>Whether or not you would like this filter to populate the delegation headers. Inclusion means
                    you do.
                </html:p>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="quality" type="QualityType" use="optional" default="0.9">
            <xs:annotation>
                <xs:documentation>
                    <html:p>
                        What quality you want any output headers to be.
                        When setting up a chain of delegating filters the highest quality number will be the one that is
                        eventually output.
                        Default is 0.9
                    </html:p>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:simpleType name="SecretType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="api-key"/>
            <xs:enumeration value="password"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="QualityType">
        <xs:restriction base="xs:double">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="1.0"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="ZeroOrPositiveInteger">
        <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
