Finish up build
[java-idp.git] / src / installer / resources / build.xml
1 <project name="Shibboleth Identity Provider" basedir="../../.." default="install">
2
3     <property name="installer.dir" value="${basedir}/src/installer" />
4     <property name="resources.dir" value="${installer.dir}/resources" />
5     <property name="tools.dir" value="${basedir}/src/tools" />
6     <property name="webapp.dir" value="${basedir}/src/main/webapp" />
7     <property name="war.name" value="idp" />
8
9     <!-- Installation specific property file -->
10     <property file="${resources.dir}/install.properties" />
11
12     <!-- Load ant-contrib tasks -->
13     <taskdef resource="net/sf/antcontrib/antlib.xml" />
14
15     <!-- Load Internet2 ant extensions -->
16     <taskdef resource="edu/internet2/middleware/ant/antlib.xml" />
17
18     <target name="install" description="Installs the identity provider software.">
19         <input message="Is this a new installation? Answering yes will overwrite your current configuration."
20                addproperty="new.install"
21                validargs="yes,no"
22                defaultvalue="no" />
23
24         <if>
25             <equals arg1="${new.install}" arg2="yes" />
26             <then>
27                 <input message="Where should the Shibboleth Identity Provider software be installed?"
28                        addproperty="idp.home.input"
29                        defaultvalue="${idp.home}" />
30                 <var name="idp.home" value="${idp.home.input}" />
31
32                 <pathToAbsolutePath path="${idp.home}" addproperty="idp.home.path" />
33                 <pathToUrl path="${idp.home}" addproperty="idp.home.url" />
34
35                 <input message="What is the hostname of the Shibboleth Identity Provider server?"
36                        addproperty="idp.hostname.input"
37                        defaultvalue="${idp.hostname}" />
38                 <var name="idp.hostname" value="${idp.hostname.input}" />
39
40                 <input message="A keystore is about to be generated for you. Please enter a password that will be used to protect it."
41                        addproperty="idp.keystore.pass" />
42
43                 <propertyfile file="${resources.dir}/install.properties">
44                     <entry key="idp.home" value="${idp.home.input}" />
45                     <entry key="idp.hostname" value="${idp.hostname.input}" />
46                 </propertyfile>
47
48                 <mkdir dir="${idp.home.path}" />
49                 <mkdir dir="${idp.home.path}/bin" />
50                 <mkdir dir="${idp.home.path}/conf" />
51                 <mkdir dir="${idp.home.path}/credentials" />
52                 <mkdir dir="${idp.home.path}/lib" />
53                 <mkdir dir="${idp.home.path}/lib/endorsed" />
54                 <mkdir dir="${idp.home.path}/logs" />
55                 <mkdir dir="${idp.home.path}/metadata" />
56                 <mkdir dir="${idp.home.path}/war" />
57
58                 <var name="idp.entity.id" value="https://${idp.hostname}/idp/shibboleth" />
59
60                 <regexSplit input="${idp.hostname}" regex="^.*\.(.*\..*$)" addproperty="idp.scope" />
61
62                 <echo message="Generating signing and encryption key, certificate, and keystore. " />
63                 <selfSignedCert hostname="${idp.hostname}"
64                                 privateKeyFile="${idp.home.path}/credentials/idp.key"
65                                 certificateFile="${idp.home.path}/credentials/idp.crt"
66                                 keystoreFile="${idp.home.path}/credentials/idp.jks"
67                                 keystorePassword="${idp.keystore.pass}"
68                                 uriSubjectAltNames="${idp.entity.id}" />
69
70                 <copy todir="${idp.home.path}/bin" preservelastmodified="true">
71                     <fileset dir="${tools.dir}/bash" />
72                     <fileset dir="${tools.dir}/bat" />
73                     <filterset begintoken="$" endtoken="$">
74                         <filter token="IDP_HOME" value="${idp.home.path}" />
75                         <filter token="IDP_VERSION" value="${version}" />
76                     </filterset>
77                 </copy>
78                 <chmod file="${idp.home.path}/bin/*.sh" perm="+x" />
79
80                 <copy todir="${idp.home.path}/conf" preservelastmodified="true" overwrite="true">
81                     <fileset dir="${resources.dir}/conf-tmpl" />
82                     <filterset begintoken="$" endtoken="$">
83                         <filter token="IDP_HOME" value="${idp.home.path}" />
84                         <filter token="IDP_VERSION" value="${version}" />
85                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
86                         <filter token="IDP_SCOPE" value="${idp.scope}" />
87                         <filter token="IDP_CERTIFICATE" value="${idp.cert}" />
88                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
89                     </filterset>
90                 </copy>
91
92                 <stringFromFile input="${idp.home.path}/credentials/idp.crt" addProperty="idp.cert" />
93                 <regexSplit input="${idp.cert}"
94                             regex="\A.*-----\s((?:.*\s)*)-----END.*\Z"
95                             addproperty="idp.metadata.cert" />
96                 <copy todir="${idp.home.path}/metadata" preservelastmodified="true" overwrite="true">
97                     <fileset dir="${resources.dir}/metadata-tmpl" />
98                     <filterset begintoken="$" endtoken="$">
99                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
100                         <filter token="IDP_SCOPE" value="${idp.scope}" />
101                         <filter token="IDP_CERTIFICATE" value="${idp.metadata.cert}" />
102                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
103                     </filterset>
104                 </copy>
105             </then>
106         </if>
107
108         <copy todir="${idp.home.path}/lib" preservelastmodified="true">
109             <fileset dir="${basedir}/lib" />
110         </copy>
111
112         <copy todir="${idp.home.path}/lib/endorsed" preservelastmodified="true" failonerror="false">
113             <fileset dir="endorsed" />
114         </copy>
115
116         <!-- create web.xml -->
117         <copy file="${webapp.dir}/WEB-INF/web.xml"
118               todir="${installer.dir}"
119               preservelastmodified="true"
120               overwrite="true">
121             <filterset begintoken="$" endtoken="$">
122                 <filter token="IDP_HOME" value="${idp.home.url}" />
123             </filterset>
124         </copy>
125
126         <!-- build the war file -->
127         <war warfile="${idp.home.path}/war/${war.name}.war" webxml="${installer.dir}/web.xml">
128             <lib dir="${basedir}/lib" />
129             <webinf dir="${webapp.dir}/WEB-INF" excludes="web.xml" />
130             <fileset dir="${webapp.dir}" excludes="WEB-INF/**" />
131         </war>
132
133         <!-- Remove generated web.xml -->
134         <delete file="${installer.dir}/web.xml" />
135     </target>
136
137 </project>