<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Shibboleth Identity Provider configuration
     idp.xml TEMPLATE for the SWITCHaai federation
     see SWITCHaai installation guide -->

<IdPConfig 
    xmlns="urn:mace:shibboleth:idp:config:1.0" 
    xmlns:cred="urn:mace:shibboleth:credentials:1.0" 
    xmlns:name="urn:mace:shibboleth:namemapper:1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="urn:mace:shibboleth:idp:config:1.0 ../schemas/shibboleth-idpconfig-1.0.xsd" 
    blockStaleRequests="true" blameSP="true"
    AAUrl="https://aai-aa.example.ch/shibboleth-idp/AA" 
    resolverConfig="file:///etc/shibboleth/resolver.xml"
    defaultRelyingParty="urn:mace:switch.ch:SWITCHaai" 
    providerId="urn:mace:switch.ch:SWITCHaai:example.ch">


    <!-- This section contains configuration options that apply only to a site or group of sites
         This would normally be adjusted when a new federation or bilateral trust relationship is established -->
    <RelyingParty name="urn:mace:switch.ch:SWITCHaai" signingCredential="switchaai_cred"> 
        <!-- (signingCredential) must correspond to a <Credential/> element below -->
        <NameID nameMapping="shm"/>
        <!-- (nameMapping) must correspond to a <NameMapping/> element below -->
    </RelyingParty>
  
    <!-- Configuration for the attribute release policy engine
         For most configurations this won't need adjustment -->
    <ReleasePolicyEngine>
        <ArpRepository implementation="edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository">
            <Path>file:///etc/shibboleth/arps</Path>
        </ArpRepository>
    </ReleasePolicyEngine>

  
    <!-- Logging Configuration
         The defaults work fine in this section, but it is sometimes helpful to use "DEBUG" as the level for 
         the <ErrorLog/> when trying to diagnose problems -->
    <Logging>
        <ErrorLog level="WARN" 
                  location="file:///var/log/shibboleth/shib-error.log" />
        <TransactionLog level="INFO" 
                        location="file:///var/log/shibboleth/shib-access.log" />
    </Logging>

    <!-- Uncomment the configuration section below and comment out the one above if you would like to manually configure log4j -->
    <!--
    <Logging>
        <Log4JConfig location="file:///tmp/log4j.properties" />
    </Logging> -->


    <!-- This configuration section determines how Shibboleth maps between SAML Subjects and local principals.
         The default mapping uses shibboleth handles, but other formats can be added.
         The mappings listed here are only active when they are referenced within a <RelyingParty/> element above -->
    <NameMapping 
        xmlns="urn:mace:shibboleth:namemapper:1.0" 
        id="shm" 
        format="urn:mace:shibboleth:1.0:nameIdentifier" 
        type="SharedMemoryShibHandle" 
        handleTTL="28800"/>


    <!-- Determines how SAML artifacts are stored and retrieved
         The (sourceLocation) attribute must be specified when using type 2 artifacts -->
    <ArtifactMapper implementation="edu.internet2.middleware.shibboleth.artifact.provider.MemoryArtifactMapper" />


    <!-- This configuration section determines the keys/certs to be used when signing SAML assertions -->
    <!-- The credentials listed here are used when referenced within <RelyingParty/> elements above -->
    <Credentials xmlns="urn:mace:shibboleth:credentials:1.0">
        <FileResolver Id="switchaai_cred">
           <Key>
               <Path>file:///etc/shibboleth/www.example.ch.key</Path>
           </Key>
           <Certificate>
               <Path>file:///etc/shibboleth/www.example.ch.crt</Path>
           </Certificate>
        </FileResolver>

        <!-- this block may be used instead of the FileResolver - the IdP will then use the same keystore as Tomcat -->
        <!-- 
        <KeyStoreResolver Id="switchaai_cred" storeType="JKS">
            <Path>file:/etc/tomcat/www.example.ch.jks</Path>
            <KeyAlias>www.example.ch</KeyAlias>
            <CertAlias>www.example.ch</CertAlias>
            <StorePassword>KEYSTOREPASS</StorePassword>
            <KeyPassword>KEYSTOREPASS</KeyPassword>
        </KeyStoreResolver>
        -->
    </Credentials>

    <!-- Protocol handlers specify what type of requests the IdP can respond to.  The default set listed here should work 
         for most configurations.  Modifications to this section may require modifications to the deployment descriptor -->
    <ProtocolHandler implementation="edu.internet2.middleware.shibboleth.idp.provider.ShibbolethV1SSOHandler">
        <Location>.+/shibboleth-idp/SSO</Location>
    </ProtocolHandler>
    <ProtocolHandler implementation="edu.internet2.middleware.shibboleth.idp.provider.SAMLv1_AttributeQueryHandler">
        <Location>.+/shibboleth-idp/AA</Location>
    </ProtocolHandler>
    <ProtocolHandler implementation="edu.internet2.middleware.shibboleth.idp.provider.SAMLv1_1ArtifactQueryHandler">
        <Location>.+/shibboleth-idp/Artifact</Location>
    </ProtocolHandler>
    <ProtocolHandler implementation="edu.internet2.middleware.shibboleth.idp.provider.Shibboleth_StatusHandler">
        <Location>https://[^:/]+(:443)?/shibboleth-idp/Status</Location>
    </ProtocolHandler>

    <!-- This section configures the loading of SAML2 metadata, which contains information about system entities and 
         how to authenticate them.  The metadatatool utility can be used to keep federation metadata files in synch.
         Metadata can also be placed directly within this these elements. -->
    <MetadataProvider type="edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata"
        uri="file:///etc/shibboleth/metadata.switchaai.xml"/>

</IdPConfig>
