<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : ping-schema-protocol.xsd
    Created on : April 22, 2003, 9:56 AM
    Author     : bsimons
    Description: Describes the ping client-server request/response protocol
-->

<xsd:schema targetNamespace="http://ping.chip.org/schemas/ping-talk"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:pingt="http://ping.chip.org/schemas/ping-talk"
            xmlns:pingr="http://ping.chip.org/schemas/ping-record"
            xmlns:cred="http://ping.chip.org/schemas/ping-credentials"
            xmlns:attr="http://ping.chip.org/schemas/ping-actor-attributes"
            xmlns:pid="http://ping.chip.org/schemas/pid"
            xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
            xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
            jaxb:extensionBindingPrefixes="xjc"
            jaxb:version="1.0"
            elementFormDefault="unqualified">
            
    <import namespace="http://ping.chip.org/schemas/ping-credentials" 
            schemaLocation="ping-credentials.xsd"/>
    <import namespace="http://ping.chip.org/schemas/pid" 
        schemaLocation="ping-schema-pid.xsd"/>
    <import namespace="http://ping.chip.org/schemas/ping-actor-attributes" 
            schemaLocation="ping-actor-attributes.xsd"/>
    
    <!--Abstract type that contains the attributes of a request-->     
    <complexType name="AbstractRequest" abstract="true">
        <!--The identifier of the request-->
        <attribute name="RequestId" type="string" use="required"/>
        <!--The major version of the schema that defines the structure
            of the request-->
        <attribute name="MajorVersion" type="integer" use="required"/>
        <!--The minor version of the schema that definies the structure
            of the request-->
        <attribute name="MinorVersion" type="integer" use="required"/>
        <!--The time that the request was issued-->
        <attribute name="IssueInstant" type="dateTime" use="required"/>
    </complexType>
    
    <element name="Request" type="pingt:RequestType" />
    <!--The request sent to the server-->
    <complexType name="RequestType">
        <complexContent>
            <extension base="pingt:AbstractRequest">
                <sequence>
                    <!--The Actor's ticket (if any) that identifies the session
                        information of the actor issuing the request-->
                    <element name="ActorTicket" type="string" minOccurs="0"/>
                    <!--The actual action being requested-->
                    <element name="Action" type="pingt:ActionType"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    
    <!--Information about the action being requested-->
    <complexType name="ActionType">
        <sequence>
            <!--URI that identifies the type of specific type of action 
                contained in the "any" element-->
            <element name="ActionDescription" type="anyURI"/>
            <!--Holds the specific action-->
            <any minOccurs="0" processContents="lax">
                <annotation><appinfo>
                    <xjc:dom />
                </appinfo></annotation>
            </any>
        </sequence>
    </complexType>
    <element name="AuthenticateAction" type="pingt:AuthenticateActionType" />
    <!--Action for authenticating an actor.  This is part of the core protocol
        because information (Actor Ticket) received from performing this action 
        can be included in the request-->
    <complexType name="AuthenticateActionType">
        <sequence>
            <!--The ID of the authenticating actor-->
            <element name="PingId" type="pid:AnyIdType" />
            <!--The credentials of the authenticating actor-->
            <element ref="cred:Credentials"/>
            <element name="SingleTicket" type="boolean" minOccurs="0" />
            <element name="ExpirationDate" type="date" minOccurs="0" />
        </sequence>
    </complexType>
    
    <!--Abstract type that contains the attributes of a response-->
    <complexType name="AbstractResponse" abstract="true">
        <!--The identifier of the response-->
        <attribute name="ResponseId" type="string" use="required"/>
        <!--The identifier of the request that the response relates to-->
        <attribute name="InResponseTo" type="string" use="optional"/>
        <!--The major version of the schema that defines the structure
            of the response-->
        <attribute name="MajorVersion" type="integer" use="required"/>
        <!--The minor version of the schema that definies the structure
            of the response-->
        <attribute name="MinorVersion" type="integer" use="required"/>
        <!--The time that the response was issued-->
        <attribute name="IssueInstant" type="dateTime" use="required"/>
    </complexType>
    
    <element name="Response" type="pingt:ResponseType" />
    <!--The response sent to the server-->
    <complexType name="ResponseType">
        <complexContent>
            <extension base="pingt:AbstractResponse">
                <sequence>
                    <!--The status of the request/response interaction-->
                    <element ref="pingt:Status"/>
                    <!--The actual result of the response to the specific 
                        action.  The absence of a Result indicates that the
                        action did not complete successfully.  Failure can occur
                        because of lack of authorization, or a specific error in
                        the client or server.  Errors are reported in the Status
                        element of the request.-->
                    <element name="Result" type="pingt:ResultType" minOccurs="0"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    
    <!--Information about the result in the response-->
    <complexType name="ResultType">
        <sequence>
            <!--URI that identifies the type of specific type of result
                contained in the "any" element-->
            <element name="ResultDescription" type="anyURI"/>
            <!--Holds the specific result-->
            <any minOccurs="0" processContents="lax">
                <annotation><appinfo>
                    <xjc:dom />
                </appinfo></annotation>
            </any>
        </sequence>
    </complexType>
    
    <element name="AuthenticateResult" type="pingt:AuthenticateResultType" />
    <!--Result for authenticating an actor.  This relates to the 
        AuthenticateAction-->
    <complexType name="AuthenticateResultType">
        <sequence>
            <!--The ID of the authenticated actor -->
            <element name="ActorId" type="string" minOccurs="0"/>
            <!--The session identifier of the authenticated actor-->
            <element name="ActorTicket" type="string" minOccurs="0"/>
            <!--The current role that the actor is "acting" as for the session
                that was just created-->
            <element name="CurrentRole" type="string" minOccurs="0"/>
            <!--The actor's attributes-->
            <element ref="attr:ActorAttributes" minOccurs="0"/>
            <element name="SingleTicket" type="boolean" minOccurs="0" />
            <element name="IssueDate" type="date"/>
            <element name="ExpirationDate" type="date" minOccurs="0"/>
        </sequence>
    </complexType>
    
    <element name="Status" type="pingt:StatusType" />
    <!--Encapsulates the status of the request/response interaction-->
    <complexType name="StatusType">
        <sequence>
            <!--The code identifying the status-->
            <element ref="pingt:StatusCode"/>
            <!--A message populated by the server explaining the status-->
            <element ref="pingt:StatusMessage" minOccurs="0" maxOccurs="1"/>
        </sequence>
    </complexType>
    
    <element name="StatusCode" type="pingt:StatusCodeType" />
    <!--The code identifying the status-->
    <complexType name="StatusCodeType">
        <sequence>
            <!--Multi-layered-->
            <element ref="pingt:StatusCode" minOccurs="0"/>
        </sequence>
        <!--The value of the code.  This is one of SUCCESS, SENDER, or RECEIVER.
        SENDER indicates that the sender of the request made an error 
        formulating it.  RECEIVER indicates that the receiver of the request
        couldn't process it.  SUCCESS indicates that the action processed 
        without error. Note that a request can be successful but not produce a
        result (in the case of the actor not being authorized).-->
        <attribute name="Value" type="QName" use="required"/>
    </complexType>
    <element name="StatusMessage" type="string"/>
</xsd:schema>