<?xml version="1.0" encoding="UTF-8"?>
<!-- ================================================================
 Redistribution and use of this software and associated documentation
 ("Software"), with or without modification, are permitted provided
 that the following conditions are met:

 1. Redistributions of source code must retain copyright
    statements and notices.  Redistributions must also contain a
    copy of this document.

 2. Redistributions in binary form must reproduce this list of
    conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

 3. The name "OpenEJB" must not be used to endorse or promote
    products derived from this Software without prior written
    permission of The OpenEJB Group.  For written permission,
    please contact openejb-group@openejb.sf.net.

 4. Products derived from this Software may not be called "OpenEJB"
    nor may "OpenEJB" appear in their names without prior written
    permission of The OpenEJB Group. OpenEJB is a registered
    trademark of The OpenEJB Group.

 5. Due credit should be given to the OpenEJB Project
    (http://openejb.org/).

 THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.

 ====================================================================

 This software consists of voluntary contributions made by many
 individuals on behalf of the OpenEJB Project.  For more information
 please see <http://openejb.org/>.

 ================================================================ -->

<xsd:schema
    xmlns:css="http://www.openejb.org/xml/ns/corba-css-config-2.0"
    targetNamespace="http://www.openejb.org/xml/ns/corba-css-config-2.0"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    version="1.0">

    <xsd:element name="css" type="css:cssType"/>

    <xsd:complexType name="cssType">
        <xsd:sequence>
            <xsd:element name="description" type="css:descriptionType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="compoundSecMechTypeList" minOccurs="0">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="compoundSecMech" type="css:compoundSecMechType" maxOccurs="unbounded"/>
                    </xsd:sequence>
                    <xsd:attribute name="stateful" type="xsd:boolean" use="optional" default="false"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="descriptionType">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute ref="xml:lang"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="compoundSecMechType">
        <xsd:sequence>
            <xsd:element name="description" type="css:descriptionType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:group ref="css:transportMechGroup" minOccurs="0"/>
            <xsd:group ref="css:asMechGroup" minOccurs="0"/>
            <xsd:element name="sasMech" type="css:sasMechType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:group name="transportMechGroup">
        <xsd:choice>
            <xsd:element name="SSL" type="css:SSLType"/>
            <xsd:element name="SECIOP" type="css:SECIOPType"/>
        </xsd:choice>
    </xsd:group>

    <xsd:complexType name="SSLType">
        <xsd:sequence>
            <xsd:element name="description" type="css:descriptionType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="supports" type="css:associationOptionList"/>
            <xsd:element name="requires" type="css:associationOptionList"/>
            <xsd:group ref="css:trustGroup" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attribute name="handshakeTimeout" type="xsd:short"/>
    </xsd:complexType>

    <xsd:complexType name="SECIOPType">
        <xsd:sequence>
            <xsd:element name="description" type="css:descriptionType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="supports" type="css:associationOptionList"/>
            <xsd:element name="requires" type="css:associationOptionList"/>
            <xsd:group ref="css:trustGroup"/>
        </xsd:sequence>
        <xsd:attribute name="mechOID" type="xsd:string"/>
        <xsd:attribute name="targetName" type="xsd:string"/>
    </xsd:complexType>

    <xsd:group name="trustGroup">
        <xsd:choice>
            <xsd:element name="trustEveryone" type="css:trustEveryoneType"/>
            <xsd:element name="trustNoone" type="css:trustNooneType"/>
            <xsd:element name="trustList">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="entity" type="css:entityType" maxOccurs="unbounded"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:choice>
    </xsd:group>

    <xsd:complexType name="trustEveryoneType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType"/>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="trustNooneType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType"/>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="entityType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
                <xsd:attribute name="hostname" type="xsd:string" use="optional"/>
                <xsd:attribute name="distinguishedName" type="xsd:string" use="optional"/>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:group name="asMechGroup">
        <xsd:choice>
            <xsd:element name="GSSUPStatic" type="css:GSSUPStaticType"/>
            <xsd:element name="GSSUPDynamic" type="css:GSSUPDynamicType"/>
        </xsd:choice>
    </xsd:group>

    <xsd:complexType name="GSSUPStaticType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
                <xsd:attribute name="username" type="xsd:string"/>
                <xsd:attribute name="password" type="xsd:string"/>
                <xsd:attribute name="domain" type="xsd:string"/>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="GSSUPDynamicType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
                <xsd:attribute name="domain" type="xsd:string" use="optional"/>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="sasMechType">
        <xsd:sequence>
            <xsd:element name="description" type="css:descriptionType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:group ref="css:ittGroup"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:group name="ittGroup">
        <xsd:choice>
            <xsd:element name="ITTAbsent" type="css:ITTAbsentType"/>
            <xsd:element name="ITTAnonymous" type="css:ITTAnonymousType"/>
            <xsd:element name="ITTPrincipalNameStatic" type="css:ITTPrincipalNameStaticType"/>
            <xsd:element name="ITTPrincipalNameDynamic" type="css:ITTPrincipalNameDynamicType"/>
        </xsd:choice>
    </xsd:group>

    <xsd:complexType name="ITTAbsentType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType"/>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ITTAnonymousType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType"/>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ITTPrincipalNameStaticType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
                <xsd:attribute name="name" type="xsd:string"/>
                <xsd:attribute name="oid" type="xsd:string" use="optional"/>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ITTPrincipalNameDynamicType">
        <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
                <xsd:attribute name="principal-class" type="xsd:string"/>
                <xsd:attribute name="domain" type="xsd:string" use="optional"/>
                <xsd:attribute name="realm" type="xsd:string" use="optional"/>
                <xsd:attribute name="oid" type="xsd:string" use="optional"/>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:simpleType name="associationOption">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="NoProtection"/>
            <xsd:enumeration value="Integrity"/>
            <xsd:enumeration value="Confidentiality"/>
            <xsd:enumeration value="DetectReplay"/>
            <xsd:enumeration value="DetectMisordering"/>
            <xsd:enumeration value="EstablishTrustInTarget"/>
            <xsd:enumeration value="EstablishTrustInClient"/>
            <xsd:enumeration value="NoDelegation"/>
            <xsd:enumeration value="SimpleDelegation"/>
            <xsd:enumeration value="CompositeDelegation"/>
            <xsd:enumeration value="IdentityAssertion"/>
            <xsd:enumeration value="DelegationByClient"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="associationOptionList">
        <xsd:list itemType="css:associationOption"/>
    </xsd:simpleType>

</xsd:schema>
