Early draft of upgrade script, handles everything but Applications section.
[shibboleth/sp.git] / configs / upgrade.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
3     xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
4     xmlns:oldconf="urn:mace:shibboleth:target:config:1.0"
5     xmlns:cred="urn:mace:shibboleth:credentials:1.0"
6     xmlns="urn:mace:shibboleth:2.0:native:sp:config"
7     xmlns:saml1="urn:oasis:names:tc:SAML:1.0:assertion"
8     xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
9     xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
10     exclude-result-prefixes="oldconf cred saml1">
11
12     <!-- Add a comment to the start of the output file. -->
13     <xsl:template match="/">
14         <xsl:comment>
15             <xsl:text>&#160;Generated by upgrade utility: check carefully before deploying.&#160;</xsl:text>
16         </xsl:comment>
17         <xsl:apply-templates/>
18     </xsl:template>
19     
20     <!--Force UTF-8 encoding for the output.-->
21     <xsl:output omit-xml-declaration="no" method="xml" encoding="UTF-8" indent="yes"/>
22
23     <xsl:template match="oldconf:SPConfig">
24         <SPConfig logger="{@logger}" clockSkew="{@clockSkew}">
25             <xsl:text>&#10;</xsl:text>
26             <xsl:apply-templates select="oldconf:Global"/>
27             <xsl:text>&#10;</xsl:text>
28             <xsl:apply-templates select="oldconf:Local"/>
29             <xsl:text>&#10;</xsl:text>
30             <xsl:apply-templates select="oldconf:Global/oldconf:UnixListener"/>
31             <xsl:apply-templates select="oldconf:Global/oldconf:TCPListener"/>
32             <xsl:text>&#10;</xsl:text>
33    &#160;<xsl:comment>
34            <xsl:text>&#160;This set of components stores sessions and other persistent data in daemon memory.&#160;</xsl:text>
35        </xsl:comment>
36    &#160;<StorageService type="Memory" id="mem" cleanupInterval="900"/>
37    &#160;<SessionCache type="StorageService" StorageService="mem" cacheTimeout="{oldconf:Global/oldconf:MemorySessionCache/@cacheTimeout}" inprocTimeout="900" cleanupInterval="900"/>
38    &#160;<ReplayCache StorageService="mem"/>
39    &#160;<ArtifactMap artifactTTL="180"/>
40            <xsl:text>&#10;</xsl:text>
41    &#160;<xsl:comment>
42            <xsl:text>&#160;This set of components stores sessions and other persistent data in an ODBC database.&#160;</xsl:text>
43        </xsl:comment>
44    &#160;<xsl:comment>
45             <xsl:text>
46    &#160;&lt;StorageService type="ODBC" id="db" cleanupInterval="900"&gt;
47        &#160;&lt;ConnectionString&gt;DRIVER=drivername;SERVER=dbserver;UID=shibboleth;PWD=password;DATABASE=shibboleth;APP=Shibboleth&lt;/ConnectionString&gt;
48    &#160;&lt;/StorageService&gt;
49    &#160;&lt;SessionCache type="StorageService" StorageService="db" cacheTimeout="3600" inprocTimeout="900" cleanupInterval="900"/&gt;
50    &#160;&lt;ReplayCache StorageService="db"/&gt;
51    &#160;&lt;ArtifactMap StorageService="db" artifactTTL="180"/&gt;
52     </xsl:text>
53        </xsl:comment>
54             <xsl:text>&#10;</xsl:text>
55             <xsl:apply-templates select="oldconf:Local/oldconf:RequestMapProvider"/>
56             <xsl:text>&#10;</xsl:text>
57             <xsl:apply-templates select="oldconf:Applications"/>
58         </SPConfig>
59     </xsl:template>
60     
61     <!-- Turn <Global> into <OutOfProcess> with the ODBC extension commented out. -->
62     <xsl:template match="oldconf:Global">
63    &#160;<OutOfProcess logger="{@logger}">
64        &#160;<xsl:comment>
65                <xsl:text>
66        &#160;&lt;Extensions&gt;
67            &#160;&lt;Library path="odbc-store.so" fatal="true"/&gt;
68         &lt;/Extensions&gt;
69         </xsl:text>
70         </xsl:comment>
71    &#160;</OutOfProcess>
72     </xsl:template>
73
74     <xsl:template match="oldconf:Local">
75    &#160;<InProcess logger="{@logger}">
76             
77    &#160;</InProcess>
78     </xsl:template>
79
80     <xsl:template match="oldconf:Global/oldconf:UnixListener">
81    &#160;<UnixListener address="shibd.sock"/>
82     </xsl:template>
83
84     <xsl:template match="oldconf:Global/oldconf:TCPListener">
85    &#160;<TCPListener address="{@address}" port="{@port}" acl="{@acl}"/>
86     </xsl:template>
87
88     <!-- Transplant old RequestMap into the new namespace, but just copy all the settings. -->
89     <xsl:template match="oldconf:RequestMapProvider">
90    &#160;<RequestMapper type="Native">
91        <xsl:apply-templates select="oldconf:RequestMap"/>
92    &#160;</RequestMapper>
93     </xsl:template>
94     <xsl:template match="oldconf:RequestMap">
95        &#160;<RequestMap>
96             <xsl:apply-templates select="@*"/>
97             <xsl:for-each select="oldconf:Host">
98            &#160;<Host>
99                 <xsl:apply-templates select="@*"/>
100                 <xsl:apply-templates select="oldconf:Path"/>
101            &#160;</Host>
102             </xsl:for-each>
103        &#160;</RequestMap>
104     </xsl:template>
105     <xsl:template match="oldconf:Path">
106                &#160;<Path>
107                         <xsl:apply-templates select="@*"/>
108                         <xsl:apply-templates select="oldconf:Path"/>
109                &#160;</Path>
110     </xsl:template>
111
112     <xsl:template match="oldconf:Applications">
113    &#160;<ApplicationDefaults>
114         <!-- Step up and pull in credentials from the top level. -->
115         <xsl:apply-templates select="../oldconf:CredentialsProvider"/>
116    &#160;</ApplicationDefaults>
117     </xsl:template>
118     
119     <!-- Map legacy <FileResolver> elements to CredentialResolver plugins. -->
120     <xsl:template match="oldconf:CredentialsProvider">
121         <xsl:apply-templates select="//cred:FileResolver"/>
122     </xsl:template>
123     <xsl:template match="cred:FileResolver">
124        &#160;<CredentialResolver type="File" key="{cred:Key/cred:Path/text()}" certificate="{cred:Certificate/cred:Path/text()}" keyName="{@Id}"/>
125     </xsl:template>
126
127     <xsl:template match="@*">
128         <xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
129     </xsl:template>
130
131     <xsl:template match="text()"/>
132
133 </xsl:stylesheet>