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="ext-invoke">
90 <param name="exts.dir" value="${custom}"/>
91 <param name="ext.build.function" value="ext-build"/>
96 <!-- Generate API docs -->
97 <target name="javadocs">
98 <mkdir dir="${docs}" />
99 <mkdir dir="${javadocs}" />
100 <javadoc packagenames='edu.internet2.middleware.*'
101 sourcepath='${src}' destdir='${javadocs}'
102 author='true' version='true'
103 windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
104 bottom='${copyright}'>
105 <classpath refid="build.path" />
110 <!-- Build command-line utilities -->
111 <target name="build-util" depends="compile">
112 <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
115 <!-- Cleanup after the build, test, and distribution processes -->
116 <target name="clean" depends="clean-all" />
117 <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util" />
118 <target name="clean-build">
119 <delete dir="${build}" />
120 <delete dir="${custom.libs}"/>
121 <delete dir="${custom.webapges}"/>
122 <antcall target="ext-invoke">
123 <param name="exts.dir" value="${custom}"/>
124 <param name="ext.build.function" value="ext-clean"/>
127 <target name="clean-test">
129 <fileset dir="${root}">
130 <include name="**/TEST*.txt" />
134 <target name="clean-dist">
135 <delete dir="${dist}" />
137 <target name="clean-javadocs">
138 <delete dir="${javadocs}" />
140 <target name="clean-util">
142 <fileset dir="${buildlibs}">
143 <include name="shib-util.jar" />
147 <!-- For IDE development, run this target first to delete all
148 directories generated by the install process before
149 recreating and reinstalling everything. -->
150 <target name="clean-install" depends="init"
151 description="Delete old configuration and Tomcat webapp directories.">
152 <delete dir="${idp.home}" />
153 <delete dir="${sp.home}" />
154 <delete dir="${tomcat.home}/webapps/${idp.webapp.name}" />
155 <delete dir="${tomcat.home}/webapps/${sp.webapp.name}" />
159 <!-- Add to the classpath for unit tests -->
160 <path id="test.path">
161 <path refid="build.path"/>
162 <pathelement location="${tests}"/>
165 <!-- Compile classes needed for unit testing -->
166 <target name="compile-tests" depends="compile">
167 <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
168 <classpath refid="build.path" />
172 <!-- Run automated tests on compiled code -->
173 <target name="test-all" depends="test-IdP, test-SP" />
175 <target name="test-IdP" depends="compile-tests">
176 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
177 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
179 <fileset dir="${custom.libs}">
180 <include name="*.jar"/>
182 <filelist refid="test.path"/>
184 <formatter type="plain" />
185 <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
186 <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
187 <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
188 <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
189 <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
190 <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
191 <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
195 <target name="test-SP" depends="compile-tests">
196 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
197 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
199 <fileset dir="${custom.libs}">
200 <include name="*.jar"/>
202 <filelist refid="test.path"/>
204 <formatter type="plain" />
205 <test name="edu.internet2.middleware.shibboleth.aap.AAPTests" />
210 <!-- Tomcat Management -->
211 <target name="setupTomcatTasks">
212 <path id="tomcat.classpath">
213 <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
216 <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
217 <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
218 <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
219 <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
222 <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
223 <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
226 <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
227 <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
230 <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
231 <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"
232 war="file:${basedir}/${dist}/${idp.webapp.name}.war"/>
235 <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
236 <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
240 <!-- Automated key generation for crypto handles -->
241 <target name="genSecret" depends="compile">
242 <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
243 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
247 <!-- Generate salt for use with targetted id -->
248 <target name="genSalt" depends="compile">
249 <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
250 <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
253 <target name="exampleCertificates">
255 This target provides an example of the generation of
256 self-signed Certificates for the IdP and SP. You may
257 change the cn= and use it to generate new identities
258 when you want to replace "example.org" with your real
259 organization dns. However,the generated key and
260 certificate also have to be defined to the Credentials
261 of the IdP and SP config files and added to the Metadata.
263 <genkey alias="tomcat" storepass="exampleorg"
264 keystore="${tomcat.home}/conf/idp-example.jks"
265 keyalg="RSA" validity="365"
266 dname="cn=idp.example.org, o=example.org, c=US"
268 <genkey alias="tomcat" storepass="exampleorg"
269 keystore="${tomcat.home}/conf/sp-example.jks"
270 keyalg="RSA" validity="365"
271 dname="cn=sp.example.org, o=example.org, c=US"
276 <!-- Package Shibboleth -->
277 <target name="package-idp" depends="compile, install.url" description="Creates the IdP war file and moves it to ${dist}">
278 <!-- copy values to deployment descriptor -->
279 <copy file="${configroot}/${idp.deployment.descriptor}" tofile="${configroot}/idp.xml" overwrite="true" />
280 <replace file="${configroot}/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
282 <!-- create the war -->
283 <war warfile="${dist}/${idp.webapp.name}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no" duplicate="preserve">
284 <!-- Grab any custom extension libraries -->
285 <lib dir="${custom.libs}"/>
287 <!-- Grab any web material from custom extensions -->
288 <fileset dir="${custom.webapges}"/>
291 <!-- clean up generated descriptor -->
292 <delete file="${configroot}/idp.xml"/>
295 <target name="package-wayf" depends="compile" description="Creates the WAYF war and moves it to ${dist}">
296 <war warfile="${dist}/${distnameWayf}.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
299 <target name="package-sp" depends="compile, install.url" description="Creates the Java SP war and moves it to ${dist}">
300 <!-- copy values to deployment descriptor -->
301 <copy file="${configroot}/${sp.deployment.descriptor}" tofile="${configroot}/sp.xml" overwrite="true" />
302 <replace file="${configroot}/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
304 <!-- create the war -->
305 <war warfile="${dist}/${sp.webapp.name}.war" webxml="${configroot}/sp.xml" basedir="${approot}" update="no">
306 <!-- Grab any custom extension libraries -->
307 <lib dir="${custom.libs}"/>
309 <!-- Grab any web material from custom extensions -->
310 <fileset dir="${custom.webapges}"/>
313 <!-- clean up generated descriptor -->
314 <delete file="${configroot}/sp.xml"/>
318 <!-- Install Shibboleth -->
319 <target name="install.init">
320 <taskdef name="xinput" classname="edu.internet2.middleware.shibboleth.utils.ant.XInput" classpath="${build}" />
321 <typedef name="xoption" classname="edu.internet2.middleware.shibboleth.utils.ant.XInputOption" classpath="${build}" />
324 <target name="install.url">
325 <taskdef name="urlconvert" classname="edu.internet2.middleware.shibboleth.utils.ant.URLConvert" classpath="${build}"/>
326 <urlconvert path="${idp.home}" addProperty="idp.home.url"/>
327 <urlconvert path="${sp.home}" addProperty="sp.home.url"/>
330 <target name="install" depends="init, install.init" description="Install Shibboleth">
332 <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
334 <input message="What name do you want to use for the Identity Provider web application? [default: ${idp.webapp.name}]"
335 addproperty="idp.webapp.name.input" defaultValue="${idp.webapp.name}" />
336 <var name="idp.webapp.name" value="${idp.webapp.name.input}" />
338 <antcall target="install.idp" />
343 <target name="install.idp" depends="init, install.init">
344 <xinput message="Deploying the java web application. Do you want to install it directly onto the filesystem or use the tomcat manager application?"
345 addproperty="idp.install-type.input" type="menu" casesensitive="no" defaultValue="${idp.install-type}">
346 <xoption value="filesystem.prompt">filesystem</xoption>
347 <xoption>manager</xoption>
349 <var name="idp.install-type" value="${idp.install-type.input}" />
351 <antcall target="install.idp.${idp.install-type}" />
354 <!-- Prompt user for filesystem installation options and save them to build.properties -->
355 <target name="install.idp.filesystem.prompt" depends="init, install.init">
356 <input message="Select a home directory for the Shibboleth Identity Provider [default: ${idp.home}]"
357 addproperty="idp.home.input" defaultvalue="${idp.home}" />
358 <var name="idp.home" value="${idp.home.input}" />
359 <input message="Enter tomcat home directory [default: ${tomcat.home}]"
360 addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
361 <var name="tomcat.home" value="${tomcat.home.input}" />
364 <available file="${idp.home}/etc" />
366 <echo>--------------------------------------------------------------------------------------</echo>
368 <echo>--- NOTE: Existing Identiity Provider configuration at ${idp.home}/etc ${line.separator}--- will not be overwritten.</echo>
370 <echo>--------------------------------------------------------------------------------------</echo>
371 <property name="copy-idp-conf" value="n" />
374 <property name="copy-idp-conf" value="y" />
378 <antcall target="install.idp.filesystem" />
379 <antcall target="savePropertyFile" />
382 <!-- Install Shibboleth IdP to filesystem using the properties in build.properties -->
383 <target name="install.idp.filesystem" depends="init, install.init, build-util, install.url, package-idp"
384 description="Install Shibboleth IdP to filesystem using the properties in build.properties">
386 <!-- Move IdP war to Tomcat deployment directory -->
387 <copy file="${dist}/${idp.webapp.name}.war" tofile="${tomcat.home}/webapps/${idp.webapp.name}.war" />
389 <!-- copy IdP jars and utilities -->
390 <copy todir="${idp.home}/lib">
391 <fileset dir="lib" includesfile="conf/idp-lib.include" />
394 <copy todir="${idp.home}/bin">
397 <chmod dir="${idp.home}/bin" perm="ug+rx" includes="**/*"/>
399 <mkdir dir="${idp.home}/logs" />
401 <!-- copy IdP configuration -->
404 <equals arg1="${copy-idp-conf}" arg2="y" />
405 <not> <available file="${idp.home}/etc" /> </not>
408 <delete dir="${idp.home}/etc" />
409 <antcall target="install.idp.filesystem.config" />
413 <antcall target="ext-invoke">
414 <param name="exts.dir" value="${custom}"/>
415 <param name="ext.build.function" value="ext-install-filesystem"/>
416 <param name="ext.filesystem.home" value="${idp.home}"/>
417 <param name="ext.home.token" value="$IDP_HOME$"/>
421 <!-- Install Shibboleth SP to filesystem using the properties in build.properties -->
422 <target name="install.sp.filesystem" depends="init, install.init, build-util, install.url, package-sp"
423 description="Install Shibboleth SP to filesystem using the properties in build.properties">
425 <!-- Move SP war to Tomcat deployment directory -->
426 <copy file="${dist}/${sp.webapp.name}.war" tofile="${tomcat.home}/webapps/${sp.webapp.name}.war" />
428 <!-- copy sp jars and utilities -->
429 <copy todir="${sp.home}/lib">
430 <fileset dir="lib" includesfile="conf/idp-lib.include" />
433 <copy todir="${sp.home}/bin">
436 <chmod dir="${sp.home}/bin" perm="ug+rx" includes="**/*"/>
438 <mkdir dir="${sp.home}/logs" />
440 <!-- copy sp configuration -->
443 <equals arg1="${copy-sp-conf}" arg2="y" />
444 <not> <available file="${sp.home}/etc" /> </not>
447 <delete dir="${sp.home}/etc" />
448 <antcall target="install.sp.filesystem.config" />
452 <antcall target="ext-invoke">
453 <param name="exts.dir" value="${custom}"/>
454 <param name="ext.build.function" value="${ext-install-filesystem}"/>
455 <param name="ext.filesystem.home" value="${sp.home}"/>
456 <param name="ext.home.token" value="$SP_HOME$"/>
461 <!-- copy shibboleth configuration to $IDP_HOME/etc, overwriting any existing configuration -->
462 <target name="install.idp.filesystem.config" depends="init, install.init, install.url">
463 <mkdir dir="${idp.home}/etc" />
464 <copy todir="${idp.home}/etc" overwrite="true">
465 <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
467 <move file="${idp.home}/etc/dist.idp.xml" tofile="${idp.home}/etc/idp.xml" overwrite="true" />
468 <replace file="${idp.home}/etc/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
469 <replace file="${idp.home}/etc/idp.xml" token="$IDP_WEBAPP_NAME$" value="${idp.webapp.name}" />
472 <!-- copy SP configuration to $SP_HOME$/etc, overwriting any existing configuration -->
473 <target name="install.sp.filesystem.config" depends="init, install.init">
474 <mkdir dir="${sp.home}/etc" />
475 <copy todir="${sp.home}/etc" overwrite="true">
476 <fileset dir="${src}/conf" includesfile="conf/sp-conf.include"/>
478 <move file="${sp.home}/etc/dist.sp.xml" tofile="${sp.home}/etc/sp.xml" overwrite="true" />
479 <replace file="${sp.home}/etc/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
482 <!-- install Shibboleth-IdP war using tomcat's manager app -->
483 <target name="install.idp.manager" depends="init, install.init">
484 <antcall target="setupTomcatTasks" />
486 <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
487 <var name="tomcat.home" value="${tomcat.home.input}" />
489 <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
490 <var name="tomcat.url" value="${tomcat.url.input}" />
492 <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
493 <var name="tomcat.username" value="${tomcat.username.input}" />
495 <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
496 <var name="tomcat.password" value="${tomcat.password.input}" />
498 <antcall target="tomcat.deploy" />
499 <antcall target="savePropertyFile" />
502 <!-- save configuration to build.properties -->
503 <target name="savePropertyFile">
504 <propertyfile file="build.properties">
505 <entry key="idp.home" value="${idp.home}" />
506 <entry key="sp.home" value="${sp.home}" />
507 <entry key="idp.webapp.name" value="${idp.webapp.name}" />
508 <entry key="sp.webapp.name" value="${sp.webapp.name}" />
509 <entry key="idp.install-type" value="${idp.install-type}" />
510 <entry key="tomcat.home" value="${tomcat.home}" />
511 <entry key="tomcat.url" value="${tomcat.url}" />
512 <entry key="tomcat.username" value="${tomcat.username}" />
513 <entry key="tomcat.password" value="${tomcat.password}" />