1 <!-- Main build configutaion for Shibboleth java components - Walter Hoehn 06/04/2002 -->
3 <project name="Shibboleth" default="install" basedir=".">
5 <!-- Set global properties for this build -->
6 <property name="distnameWayf" value="shibboleth-wayf" />
7 <property name="root" value="." />
8 <property name="src" value="${root}/src/" />
9 <property name="tests" value="${root}/tests/" />
10 <property name="approot" value="${root}/webApplication/" />
11 <property name="appconfig" value="${src}/conf/" />
12 <property name="configroot" value="${root}/webAppConfig/" />
13 <property name="build" value="${approot}/WEB-INF/classes/" />
14 <property name="libdir" value="${approot}/WEB-INF/lib/" />
15 <property name="buildlibs" value="${root}/lib/" />
16 <property name="endorsed" value="${root}/endorsed/" />
17 <property name="distlibs" value="${root}/lib/" />
18 <property name="custom" value="${root}/custom/" />
19 <property name="custom.libs" value="${custom}/lib"/>
20 <property name="custom.webapges" value="${custom}/web"/>
21 <property name="dist" value="${root}/dist/" />
22 <property name="docs" value="${root}/doc/" />
23 <property name="javadocs" value="${docs}/api/" />
25 <property name="year" value="2002-2005"/>
26 <property name="copyright" value="Copyright © ${year} UCAID. All Rights Reserved."/>
29 <!-- antcontrib tasks -->
30 <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${buildlibs}/ant-contrib.jar"/>
32 <!-- Import the tasks for building custom extensions -->
33 <import file="${custom}/extension-build.xml"/>
35 <!-- Construct the CLASSPATH -->
36 <path id="build.path">
37 <pathelement path="${classpath}" />
38 <pathelement location="${build}" />
39 <fileset dir="${custom}">
40 <include name="**/*.jar" />
42 <fileset dir="${endorsed}">
43 <include name="**/*.jar" />
45 <fileset dir="${libdir}">
46 <include name="**/*.jar" />
48 <fileset dir="${buildlibs}">
49 <include name="**/*.jar" />
54 <!-- Prepare directory structure for project build-->
56 <mkdir dir="${build}" />
57 <mkdir dir="${dist}" />
58 <mkdir dir="${custom.libs}"/>
59 <mkdir dir="${custom.webapges}"/>
62 <not> <available file="build.properties" /> </not>
64 <copy file="conf/default.build.properties" tofile="build.properties" />
68 <property file="build.properties" />
72 <!-- This target should be run before checking code into the repository -->
73 <target name="pre-checkin" depends="compile, test-all, clean-all" />
76 <!-- Compile classes and move them to ${build} -->
77 <target name="compile" depends="init"
78 description="Compile source files">
79 <!-- Compile the shib code into the build path -->
80 <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
81 <classpath refid="build.path" />
83 <!-- Copy xml schemas to the build path -->
84 <copy todir="${build}/schemas">
85 <fileset dir="${src}/schemas"/>
88 <!-- Build extensions -->
89 <antcall target="build-exts">
90 <param name="exts.dir" value="${custom}"/>
95 <!-- Generate API docs -->
96 <target name="javadocs">
97 <mkdir dir="${docs}" />
98 <mkdir dir="${javadocs}" />
99 <javadoc packagenames='edu.internet2.middleware.*'
100 sourcepath='${src}' destdir='${javadocs}'
101 author='true' version='true'
102 windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
103 bottom='${copyright}'>
104 <classpath refid="build.path" />
109 <!-- Build command-line utilities -->
110 <target name="build-util" depends="compile">
111 <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
114 <!-- Cleanup after the build, test, and distribution processes -->
115 <target name="clean" depends="clean-all" />
116 <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util, clean-ext" />
117 <target name="clean-build">
118 <delete dir="${build}" />
119 <delete dir="${custom.libs}"/>
120 <delete dir="${custom.webapges}"/>
122 <target name="clean-test">
124 <fileset dir="${root}">
125 <include name="**/TEST*.txt" />
129 <target name="clean-dist">
130 <delete dir="${dist}" />
132 <target name="clean-javadocs">
133 <delete dir="${javadocs}" />
135 <target name="clean-util">
137 <fileset dir="${buildlibs}">
138 <include name="shib-util.jar" />
142 <!-- For IDE development, run this target first to delete all
143 directories generated by the install process before
144 recreating and reinstalling everything. -->
145 <target name="clean-install" depends="init"
146 description="Delete old configuration and Tomcat webapp directories.">
147 <delete dir="${idp.home}" />
148 <delete dir="${sp.home}" />
149 <delete dir="${tomcat.home}/webapps/${idp.webapp.name}" />
150 <delete dir="${tomcat.home}/webapps/${sp.webapp.name}" />
154 <!-- Add to the classpath for unit tests -->
155 <path id="test.path">
156 <path refid="build.path"/>
157 <pathelement location="${tests}"/>
160 <!-- Compile classes needed for unit testing -->
161 <target name="compile-tests" depends="compile">
162 <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
163 <classpath refid="build.path" />
167 <!-- Run automated tests on compiled code -->
168 <target name="test-all" depends="test-IdP, test-SP" />
170 <target name="test-IdP" depends="compile-tests">
171 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
172 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
173 <classpath refid="test.path" />
174 <formatter type="plain" />
175 <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
176 <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
177 <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
178 <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
179 <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
180 <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
181 <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
185 <target name="test-SP" depends="compile-tests">
186 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
187 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
188 <classpath refid="test.path" />
189 <formatter type="plain" />
190 <test name="edu.internet2.middleware.shibboleth.aap.AAPTests" />
195 <!-- Tomcat Management -->
196 <target name="setupTomcatTasks">
197 <path id="tomcat.classpath">
198 <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
201 <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
202 <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
203 <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
204 <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
207 <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
208 <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
211 <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
212 <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
215 <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
216 <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"
217 war="file:${basedir}/${dist}/${idp.webapp.name}.war"/>
220 <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
221 <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
225 <!-- Automated key generation for crypto handles -->
226 <target name="genSecret" depends="compile">
227 <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
228 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
232 <!-- Generate salt for use with targetted id -->
233 <target name="genSalt" depends="compile">
234 <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
235 <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
238 <target name="exampleCertificates">
240 This target provides an example of the generation of
241 self-signed Certificates for the IdP and SP. You may
242 change the cn= and use it to generate new identities
243 when you want to replace "example.org" with your real
244 organization dns. However,the generated key and
245 certificate also have to be defined to the Credentials
246 of the IdP and SP config files and added to the Metadata.
248 <genkey alias="tomcat" storepass="exampleorg"
249 keystore="${tomcat.home}/conf/idp-example.jks"
250 keyalg="RSA" validity="365"
251 dname="cn=idp.example.org, o=example.org, c=US"
253 <genkey alias="tomcat" storepass="exampleorg"
254 keystore="${tomcat.home}/conf/sp-example.jks"
255 keyalg="RSA" validity="365"
256 dname="cn=sp.example.org, o=example.org, c=US"
261 <!-- Package Shibboleth -->
262 <target name="package-idp" depends="compile, install.url" description="Creates the IdP war file and moves it to ${dist}">
263 <!-- copy values to deployment descriptor -->
264 <copy file="${configroot}/${idp.deployment.descriptor}" tofile="${configroot}/idp.xml" overwrite="true" />
265 <replace file="${configroot}/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
267 <!-- create the war -->
268 <war warfile="${dist}/${idp.webapp.name}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no">
269 <!-- Grab any custom extension libraries -->
270 <lib dir="${custom.libs}"/>
272 <!-- Grab any web material from custom extensions -->
273 <fileset dir="${custom.webapges}"/>
276 <!-- clean up generated descriptor -->
277 <delete file="${configroot}/idp.xml"/>
280 <target name="package-wayf" depends="compile" description="Creates the WAYF war and moves it to ${dist}">
281 <war warfile="${dist}/${distnameWayf}.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
284 <target name="package-sp" depends="compile, install.url" description="Creates the Java SP war and moves it to ${dist}">
285 <!-- copy values to deployment descriptor -->
286 <copy file="${configroot}/${sp.deployment.descriptor}" tofile="${configroot}/sp.xml" overwrite="true" />
287 <replace file="${configroot}/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
289 <!-- create the war -->
290 <war warfile="${dist}/${sp.webapp.name}.war" webxml="${configroot}/sp.xml" basedir="${approot}" update="no">
291 <!-- Grab any custom extension libraries -->
292 <lib dir="${custom.libs}"/>
294 <!-- Grab any web material from custom extensions -->
295 <fileset dir="${custom.webapges}"/>
298 <!-- clean up generated descriptor -->
299 <delete file="${configroot}/sp.xml"/>
303 <!-- Install Shibboleth -->
304 <target name="install.init">
305 <taskdef name="xinput" classname="edu.internet2.middleware.shibboleth.utils.ant.XInput" classpath="${build}" />
306 <typedef name="xoption" classname="edu.internet2.middleware.shibboleth.utils.ant.XInputOption" classpath="${build}" />
309 <target name="install.url">
310 <taskdef name="urlconvert" classname="edu.internet2.middleware.shibboleth.utils.ant.URLConvert" classpath="${build}"/>
311 <urlconvert path="${idp.home}" addProperty="idp.home.url"/>
312 <urlconvert path="${sp.home}" addProperty="sp.home.url"/>
315 <target name="install" depends="init, install.init" description="Install Shibboleth">
317 <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
319 <input message="What name do you want to use for the Identity Provider web application? [default: ${idp.webapp.name}]"
320 addproperty="idp.webapp.name.input" defaultValue="${idp.webapp.name}" />
321 <var name="idp.webapp.name" value="${idp.webapp.name.input}" />
323 <antcall target="install.idp" />
328 <target name="install.idp" depends="init, install.init">
329 <xinput message="Deploying the java web application. Do you want to install it directly onto the filesystem or use the tomcat manager application?"
330 addproperty="idp.install-type.input" type="menu" casesensitive="no" defaultValue="${idp.install-type}">
331 <xoption value="filesystem.prompt">filesystem</xoption>
332 <xoption>manager</xoption>
334 <var name="idp.install-type" value="${idp.install-type.input}" />
336 <antcall target="install.idp.${idp.install-type}" />
339 <!-- Prompt user for filesystem installation options and save them to build.properties -->
340 <target name="install.idp.filesystem.prompt" depends="init, install.init">
341 <input message="Select an installation base for the Shibboleth Identity Provider [default: ${idp.home}]"
342 addproperty="idp.home.input" defaultvalue="${idp.home}" />
343 <var name="idp.home" value="${idp.home.input}" />
344 <input message="Enter tomcat home directory [default: ${tomcat.home}]"
345 addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
346 <var name="tomcat.home" value="${tomcat.home.input}" />
349 <available file="${idp.home}/etc" />
351 <xinput type="confirm" addproperty="copy-idp-conf">WARNING!! The directory `${idp.home}${file.separator}etc` already exists. Do you want to overwrite the existing configuration?</xinput>
354 <property name="copy-idp-conf" value="y" />
358 <antcall target="install.idp.filesystem" />
359 <antcall target="savePropertyFile" />
362 <!-- Install Shibboleth IdP to filesystem using the properties in build.properties -->
363 <target name="install.idp.filesystem" depends="init, install.init, build-util, install.url, package-idp"
364 description="Install Shibboleth IdP to filesystem using the properties in build.properties">
366 <!-- Move IdP war to Tomcat deployment directory -->
367 <copy file="${dist}/${idp.webapp.name}.war" tofile="${tomcat.home}/webapps/${idp.webapp.name}.war" />
369 <!-- copy IdP jars and utilities -->
370 <copy todir="${idp.home}/lib">
371 <fileset dir="lib" includesfile="conf/idp-lib.include" />
374 <copy todir="${idp.home}/bin">
377 <chmod dir="${idp.home}/bin" perm="ug+rx" includes="**/*"/>
379 <mkdir dir="${idp.home}/logs" />
381 <!-- copy IdP configuration -->
384 <equals arg1="${copy-idp-conf}" arg2="y" />
385 <not> <available file="${idp.home}/etc" /> </not>
388 <delete dir="${idp.home}/etc" />
389 <antcall target="install.idp.filesystem.config" />
394 <!-- Install Shibboleth SP to filesystem using the properties in build.properties -->
395 <target name="install.sp.filesystem" depends="init, install.init, build-util, install.url, package-sp"
396 description="Install Shibboleth SP to filesystem using the properties in build.properties">
398 <!-- Move SP war to Tomcat deployment directory -->
399 <copy file="${dist}/${sp.webapp.name}.war" tofile="${tomcat.home}/webapps/${sp.webapp.name}.war" />
401 <!-- copy sp jars and utilities -->
402 <copy todir="${sp.home}/lib">
403 <fileset dir="lib" includesfile="conf/idp-lib.include" />
406 <copy todir="${sp.home}/bin">
409 <chmod dir="${sp.home}/bin" perm="ug+rx" includes="**/*"/>
411 <mkdir dir="${sp.home}/logs" />
413 <!-- copy sp configuration -->
416 <equals arg1="${copy-sp-conf}" arg2="y" />
417 <not> <available file="${sp.home}/etc" /> </not>
420 <delete dir="${sp.home}/etc" />
421 <antcall target="install.sp.filesystem.config" />
427 <!-- copy shibboleth configuration to $IDP_HOME/etc, overwriting any existing configuration -->
428 <target name="install.idp.filesystem.config" depends="init, install.init, install.url">
429 <mkdir dir="${idp.home}/etc" />
430 <copy todir="${idp.home}/etc" overwrite="true">
431 <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
433 <move file="${idp.home}/etc/dist.idp.xml" tofile="${idp.home}/etc/idp.xml" overwrite="true" />
434 <replace file="${idp.home}/etc/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
435 <replace file="${idp.home}/etc/idp.xml" token="$IDP_WEBAPP_NAME$" value="${idp.webapp.name}" />
438 <!-- copy SP configuration to $SP_HOME$/etc, overwriting any existing configuration -->
439 <target name="install.sp.filesystem.config" depends="init, install.init">
440 <mkdir dir="${sp.home}/etc" />
441 <copy todir="${sp.home}/etc" overwrite="true">
442 <fileset dir="${src}/conf" includesfile="conf/sp-conf.include"/>
444 <move file="${sp.home}/etc/dist.sp.xml" tofile="${sp.home}/etc/sp.xml" overwrite="true" />
445 <replace file="${sp.home}/etc/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
448 <!-- install Shibboleth-IdP war using tomcat's manager app -->
449 <target name="install.idp.manager" depends="init, install.init">
450 <antcall target="setupTomcatTasks" />
452 <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
453 <var name="tomcat.home" value="${tomcat.home.input}" />
455 <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
456 <var name="tomcat.url" value="${tomcat.url.input}" />
458 <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
459 <var name="tomcat.username" value="${tomcat.username.input}" />
461 <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
462 <var name="tomcat.password" value="${tomcat.password.input}" />
464 <antcall target="tomcat.deploy" />
465 <antcall target="savePropertyFile" />
468 <!-- save configuration to build.properties -->
469 <target name="savePropertyFile">
470 <propertyfile file="build.properties">
471 <entry key="idp.home" value="${idp.home}" />
472 <entry key="sp.home" value="${sp.home}" />
473 <entry key="idp.webapp.name" value="${idp.webapp.name}" />
474 <entry key="sp.webapp.name" value="${sp.webapp.name}" />
475 <entry key="idp.install-type" value="${idp.install-type}" />
476 <entry key="tomcat.home" value="${tomcat.home}" />
477 <entry key="tomcat.url" value="${tomcat.url}" />
478 <entry key="tomcat.username" value="${tomcat.username}" />
479 <entry key="tomcat.password" value="${tomcat.password}" />