7b460cd2a96b2b7e23e4d4706e020ffc8506e0b9
[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="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="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}" />
72                     <filterset begintoken="$" endtoken="$">
73                         <filter token="IDP_HOME" value="${idp.home.path}" />
74                         <filter token="IDP_VERSION" value="${version}" />
75                     </filterset>
76                 </copy>
77                 <chmod file="${idp.home.path}/bin/*.sh" perm="+x" />
78
79                 <copy todir="${idp.home.path}/conf" preservelastmodified="true" overwrite="true">
80                     <fileset dir="${resources.dir}/conf-tmpl" />
81                     <filterset begintoken="$" endtoken="$">
82                         <filter token="IDP_HOME" value="${idp.home.path}" />
83                         <filter token="IDP_VERSION" value="${version}" />
84                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
85                         <filter token="IDP_SCOPE" value="${idp.scope}" />
86                         <filter token="IDP_CERTIFICATE" value="${idp.cert}" />
87                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
88                     </filterset>
89                 </copy>
90
91                 <stringFromFile input="${idp.home.path}/credentials/idp.crt" addProperty="idp.cert" />
92                 <regexSplit input="${idp.cert}"
93                             regex="\A.*-----\s((?:.*\s)*)-----END.*\Z"
94                             addproperty="idp.metadata.cert" />
95                 <copy todir="${idp.home.path}/metadata" preservelastmodified="true" overwrite="true">
96                     <fileset dir="${resources.dir}/metadata-tmpl" />
97                     <filterset begintoken="$" endtoken="$">
98                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
99                         <filter token="IDP_SCOPE" value="${idp.scope}" />
100                         <filter token="IDP_CERTIFICATE" value="${idp.metadata.cert}" />
101                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
102                     </filterset>
103                 </copy>
104             </then>
105         </if>
106
107         <copy todir="${idp.home.path}/lib" preservelastmodified="true">
108             <fileset dir="${lib.dir}" />
109             <fileset file="${dist.dir}/${jar.name}" />
110             <fileset file="${build-lib.dir}/servlet-2.4.jar" />
111         </copy>
112
113         <copy todir="${idp.home.path}/lib/endorsed" preservelastmodified="true" failonerror="false">
114             <fileset dir="endorsed" />
115         </copy>
116
117         <!-- create web.xml -->
118         <copy file="${webapp.dir}/WEB-INF/web.xml"
119               todir="${installer.dir}"
120               preservelastmodified="true"
121               overwrite="true">
122             <filterset begintoken="$" endtoken="$">
123                 <filter token="IDP_HOME" value="${idp.home.url}" />
124             </filterset>
125         </copy>
126
127         <!-- build the war file -->
128         <war warfile="${idp.home.path}/war/${war.name}.war" webxml="${installer.dir}/web.xml">
129             <lib dir="${basedir}/lib" />
130             <webinf dir="${webapp.dir}/WEB-INF" excludes="web.xml" />
131             <fileset dir="${webapp.dir}" excludes="WEB-INF/**" />
132         </war>
133
134         <!-- Remove generated web.xml -->
135         <delete file="${installer.dir}/web.xml" />
136     </target>
137
138 </project>