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

<xs:schema targetNamespace="urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI"
  xmlns:ac="urn:oasis:names:tc:SAML:2.0:ac" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns="urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI"
  finalDefault="extension">

  <xs:import namespace="urn:oasis:names:tc:SAML:2.0:ac" schemaLocation="sstc-saml-schema-authn-context-1.0.xsd"/>

  <xs:annotation>
    <xs:documentation> 
      urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI
    </xs:documentation>
  </xs:annotation>

  <xs:complexType name="AuthnContextDeclaration">
    <xs:complexContent>
      <xs:restriction base="ac:AuthnContextDeclarationBaseType">
        <xs:sequence>
          <xs:element ref="ac:Identification" minOccurs="0"/>
          <xs:element ref="TechnicalProtection"/>
          <xs:element ref="ac:OperationalProtection" minOccurs="0"/>
          <xs:element ref="AuthnMethod"/>
          <xs:element ref="ac:GoverningAgreements" minOccurs="0"/>
          <xs:element ref="ac:AuthenticatingAuthority" minOccurs="0"
            maxOccurs="unbounded"/>
          <xs:element ref="ac:Extension" minOccurs="0"
            maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="ID" type="xs:ID"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="AuthnMethod" type="AuthnMethodType"/>

  <xs:complexType name="AuthnMethodType">
    <xs:complexContent>
      <xs:restriction base="ac:AuthnMethodBaseType">
        <xs:sequence>
          <xs:element ref="AuthnMechanism"/>
          <xs:element ref="Authenticator"/>
          <xs:element ref="ac:AuthenticatorTransportProtocol"
            minOccurs="0"/>
          <xs:element ref="ac:Extension" minOccurs="0"
            maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>    
    
  <xs:element name="TechnicalProtection" type="TechnicalProtectionType"/>

  <xs:complexType name="TechnicalProtectionType">
    <xs:complexContent>
      <xs:restriction base="ac:TechnicalProtectionBaseType">
        <xs:sequence>
          <xs:choice>
            <xs:element ref="PrivateKeyProtection"/>
            <xs:element ref="ac:SecretKeyProtection" minOccurs="0"/>
            <xs:element ref="ac:Extension" minOccurs="0"
              maxOccurs="unbounded"/>
          </xs:choice>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="AuthnMechanism" type="SmartcardAuthnMechanismType"/>

  <xs:complexType name="SmartcardAuthnMechanismType">
    <xs:complexContent>
      <xs:restriction base="ac:PrincipalAuthenticationMechanismType">
        <xs:sequence>
            <xs:element ref="ac:ActivationPin"/>
            <xs:element ref="ac:Extension" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
 
  <xs:element name="Authenticator" type="SmartCardPKIAuthenticatorType"/>

  <xs:complexType name="SmartCardPKIAuthenticatorType">
    <xs:complexContent>
      <xs:restriction base="ac:AuthenticatorBaseType">
        <xs:choice>
          <xs:element ref="ac:AsymmetricDecryption"/>
          <xs:element ref="ac:AsymmetricKeyAgreement"/>
          <xs:element ref="ac:DigSig"/>
        </xs:choice>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="PrivateKeyProtection" type="PrivateKeyProtectionType"/>

  <xs:complexType name="PrivateKeyProtectionType">
    <xs:complexContent>
      <xs:restriction base="ac:PrivateKeyProtectionType">
        <xs:sequence>
          <xs:element ref="KeyActivation"/>
          <xs:element ref="KeyStorage"/>
          <xs:element ref="ac:Extension" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="KeyActivation" type="KeyActivationType"/>

  <xs:complexType name="KeyActivationType">
    <xs:complexContent>
      <xs:restriction base="ac:KeyActivationType">
        <xs:choice>
          <xs:element ref="ac:ActivationPin"/>
        </xs:choice>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:element name="KeyStorage" type="KeyStorageType"/>

  <xs:complexType name="KeyStorageType">
    <xs:complexContent>
      <xs:restriction base="ac:KeyStorageType">
        <xs:attribute name="medium" use="required">
          <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
              <xs:enumeration value="memory"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

</xs:schema>