Code cleanups in preparation for 2.0 work. Aligned resolver unit tests with recent...
[java-idp.git] / bin / metadatatool
1 #!/bin/sh
2
3 ##We need a JVM
4 if [ ! -n "$JAVA_HOME" ] ; then
5   echo "Error: JAVA_HOME is not defined."
6   exit
7 fi
8
9 if [ ! -n "$JAVACMD" ] ; then
10   JAVACMD=$JAVA_HOME/bin/java
11 fi
12
13 if [ ! -x "$JAVACMD" ] ; then
14   echo "Error: JAVA_HOME is not defined correctly."
15   echo "Cannot execute $JAVACMD"
16   exit
17 fi
18
19
20 ##Find the shibboleth components
21 SHIB_HOME=
22 if [ -n "$IDP_HOME" ] ; then
23         SHIB_HOME=$IDP_HOME
24 fi
25 if [ -n "$SP_HOME" ] ; then
26         SHIB_HOME=$SP_HOME
27 fi
28 if [ ! -n "$SHIB_HOME" ] ; then
29         echo "Error: Neither IDP_HOME nor SP_HOME is defined."
30         exit
31 fi
32
33 ENDORSED=$SHIB_HOME/endorsed
34
35 if [ ! \( -f "$SHIB_HOME/lib/shib-util.jar" -a -r "$SHIB_HOME/lib/shib-util.jar" \) ] ; then
36   echo "Error: Cannot find the shibboleth jar (shib-util.jar)."
37   echo "       If you downloaded the shibboleth source, you need to run \"ant build-util\""
38   exit
39 fi
40
41 ##Grab all the dependencies
42 if [ -n "$CLASSPATH" ] ; then
43   SHIB_UTIL_CLASSPATH=$CLASSPATH
44 fi
45
46 DIRLIBS=${SHIB_HOME}/lib/*.jar
47 for i in ${DIRLIBS}
48 do
49     # if the directory is empty, then it will return the input string
50     # this is stupid, so case for it
51     if [ "$i" != "${DIRLIBS}" ] ; then
52       if [ -z "$SHIB_UTIL_CLASSPATH" ] ; then
53         SHIB_UTIL_CLASSPATH=$i
54       else
55         SHIB_UTIL_CLASSPATH="$i":$SHIB_UTIL_CLASSPATH
56       fi
57     fi
58 done
59 SHIB_UTIL_CLASSPATH=$SHIB_UTIL_CLASSPATH:"$SHIB_HOME"
60
61 ##Here we go
62 $JAVACMD -Djava.endorsed.dirs="$ENDORSED" -cp $SHIB_UTIL_CLASSPATH  edu.internet2.middleware.shibboleth.utils.MetadataTool "$@"