</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>edu.internet2.middleware</groupId>
+ <artifactId>ant-extensions</artifactId>
+ <version>13Apr2008</version>
+ <scope>runtime</scope>
+ </dependency>
<!-- Test dependencies -->
<dependency>
<version>1.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-mock</artifactId>
+ <version>2.0.8</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
</profiles>
<!-- Project Metadata -->
- <url>https://opensaml.org/</url>
+ <url>https://shibboleth.internet2.edu/</url>
<inceptionYear>2006</inceptionYear>
<mailingLists>
<mailingList>
- <name>OpenSAML Users</name>
- <subscribe>https://spaces.internet2.edu/display/OpenSAML/MailingList</subscribe>
- <unsubscribe>https://spaces.internet2.edu/display/OpenSAML/MailingList</unsubscribe>
- <post>mace-opensaml-users@internet2.edu</post>
- <archive>https://mail.internet2.edu/wws/arc/mace-opensaml-users</archive>
- <otherArchives>
- <otherArchive>http://groups.google.com/group/opensaml-users</otherArchive>
- </otherArchives>
+ <name>Shibboleth Announce</name>
+ <subscribe>http://shibboleth.internet2.edu/support.html#lists</subscribe>
+ <unsubscribe>http://shibboleth.internet2.edu/support.html#lists</unsubscribe>
+ <post>shibboleth-announce@internet2.edu</post>
+ <archive>https://mail.internet2.edu/wws/arc/shibboleth-announce</archive>
+ </mailingList>
+ <mailingList>
+ <name>Shibboleth Users</name>
+ <subscribe>http://shibboleth.internet2.edu/support.html#lists</subscribe>
+ <unsubscribe>http://shibboleth.internet2.edu/support.html#lists</unsubscribe>
+ <post>shibboleth-users@internet2.edu</post>
+ <archive>https://mail.internet2.edu/wws/arc/shibboleth-users</archive>
+ </mailingList>
+ <mailingList>
+ <name>Shibboleth Development</name>
+ <subscribe>http://shibboleth.internet2.edu/support.html#lists</subscribe>
+ <unsubscribe>http://shibboleth.internet2.edu/support.html#lists</unsubscribe>
+ <post>shibboleth-dev@internet2.edu</post>
+ <archive>https://mail.internet2.edu/wws/arc/shibboleth-dev</archive>
</mailingList>
</mailingLists>
<scm>
- <connection>scm:svn:https://svn.middleware.georgetown.edu/java-xmltooling/</connection>
- <developerConnection>scm:svn:https://svn.middleware.georgetown.edu/java-xmltooling/</developerConnection>
+ <connection>scm:svn:https://svn.middleware.georgetown.edu/java-idp/</connection>
+ <developerConnection>scm:svn:https://svn.middleware.georgetown.edu/java-idp/</developerConnection>
<tag>HEAD</tag>
- <url>http://svn.middleware.georgetown.edu/view/?root=java-xmltooling</url>
+ <url>http://svn.middleware.georgetown.edu/view/?root=java-idp</url>
</scm>
<developers>
fi
# add in the dependency .jar files
-DIRLIBS=${ANT_HOME}/build-lib/*.jar
+DIRLIBS=${ANT_HOME}/src/installer/lib/*.jar
for i in ${DIRLIBS}
do
# if the directory is empty, then it will return the input string
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
fi
-$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main -e "$@"
+$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main -e -f src/installer/resources/build.xml "$@"
--- /dev/null
+rem ---------------------------------------------------------------------------
+rem Append to CLASSPATH
+rem
+rem $Id$
+rem ---------------------------------------------------------------------------
+
+rem Process the first argument
+if ""%1"" == """" goto end
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%1
+shift
+
+rem Process the remaining arguments
+:setArgs
+if ""%1"" == """" goto doneSetArgs
+set LOCALCLASSPATH=%LOCALCLASSPATH% %1
+shift
+goto setArgs
+:doneSetArgs
+:end
)
REM add in the dependency .jar files
-for %%i in (%ANT_HOME%\build-lib\*.jar) do (
- call tools\cpappend.bat %%i
+for %%i in (%ANT_HOME%\src\installer\lib\*.jar) do (
+ call %ANT_HOME%\cpappend.bat %%i
)
if exist %JAVA_HOME%\lib\tools.jar (
set LOCALCLASSPATH=%LOCALCLASSPATH%;%JAVA_HOME%\lib\classes.zip
)
-%JAVACMD% -cp "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main -e %*
+%JAVACMD% -cp "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main -e -f src/installer/resources/build.xml %*
+++ /dev/null
-# JDK version to target, allowed values are 1.4 or 1.5\r
-jdk.target = 1.5\r
-\r
-# Library directories\r
-build-lib.dir=${basedir}/build-lib\r
-lib.dir=${basedir}/lib\r
-thirdpaty-lib.dir=${basedir}/thirdparty-lib\r
-\r
-# Resources files\r
-resources.dir=${basedir}/resources\r
-classpathres.dir=${resources.dir}/classpath\r
-conf.dir=${resources.dir}/conf\r
-metadata.dir=${resources.dir}/metadata\r
-metainf.dir=${resources.dir}/META-INF\r
-webinf.dir=${resources.dir}/WEB-INF\r
-webpages.dir=${resources.dir}/webpages\r
-\r
-# Source directories\r
-core-src.dir=${basedir}/src\r
-test-src.dir=${basedir}/test\r
-\r
-# Tools directory\r
-tools.dir=${basedir}/tools\r
-\r
-# Documentation directories\r
-year = 2002-2007\r
-copyright = Copyright © ${year} UCAID. All Rights Reserved.\r
-doc.dir=${basedir}/doc\r
-javadoc.dir=${doc.dir}/javadoc\r
-reports.dir=${doc.dir}/reports\r
-test-report.dir=${reports.dir}/unit-test\r
-\r
-# Directories for some build generated resources\r
-build.dir=${basedir}/build\r
-core-prep-source.dir=${build.dir}/core/src\r
-core-classes.dir=${build.dir}/core/classes\r
-test-classes.dir=${build.dir}/test\r
-test-results.dir=${build.dir}/test-results\r
-webinf-temp.dir=${build.dir}/WEB-INF\r
-\r
-# Distribution file releated itmes\r
-base-package.name = identityprovider\r
-version = trunk\r
-dist.dir=${basedir}/dist\r
-jar.name=${base-package.name}-${version}.jar\r
-src-dist.name=${base-package.name}-${version}-src\r
-bin-dist.name=${base-package.name}-${version}-bin
\ No newline at end of file
-<project name="Shibboleth Identity Provider" basedir="." default="install">
+<project name="Shibboleth Identity Provider" basedir="../../.." default="install">
- <!-- User based property file that overrides any property below -->
- <property file="${user.name}-build.properties" />
-
- <!-- Project based property file -->
- <property file="build.properties" />
+ <property name="installer.dir" value="${basedir}/src/installer" />
+ <property name="resources.dir" value="${installer.dir}/resources" />
+ <property name="tools.dir" value="${basedir}/src/tools" />
+ <property name="webapp.dir" value="${basedir}/src/main/webapp" />
+ <property name="war.name" value="idp" />
<!-- Installation specific property file -->
<property file="install.properties" />
<!-- Load Internet2 ant extensions -->
<taskdef resource="edu/internet2/middleware/ant/antlib.xml" />
- <!-- Load Checkstyle tasks -->
- <taskdef resource="checkstyletask.properties" />
-
- <!-- Classpath for building core classes-->
- <path id="build-path">
- <fileset dir="${build-lib.dir}" includes="**/*.jar" />
- <fileset dir="${lib.dir}" includes="**/*.jar" />
- </path>
-
- <!-- Classpath for testing classes-->
- <path id="test-path">
- <path refid="build-path" />
- <pathelement location="${core-classes.dir}" />
- <pathelement location="${core-src.dir}" />
- <pathelement location="${test-classes.dir}" />
- <pathelement location="${test-classes.dir}/data" />
- <pathelement location="${test-classes.dir}/log4j.xml" />
- <pathelement location="${test-src.dir}" />
- <pathelement location="${classpathres.dir}" />
- </path>
-
- <!-- Prepare directory structure for build -->
- <target name="build-init">
- <mkdir dir="${build.dir}" />
- </target>
-
- <!-- Compile core (non-test) classes -->
- <target name="compile-core" depends="build-init, clean-compile">
- <mkdir dir="${core-prep-source.dir}" />
- <mkdir dir="${core-classes.dir}" />
-
- <copy todir="${core-prep-source.dir}" preservelastmodified="true">
- <fileset dir="${core-src.dir}" />
- <filterset begintoken="$" endtoken="$">
- <filter token="IDP_HOME" value="${idp.home}" />
- <filter token="IDP_VERSION" value="${version}" />
- </filterset>
- </copy>
-
- <javac srcdir="${core-prep-source.dir}"
- destdir="${core-classes.dir}"
- includes="**/*.java"
- debug="on"
- source="1.5">
- <classpath refid="build-path" />
- </javac>
-
- <delete dir="${core-prep-source.dir}" />
-
- </target>
-
- <!-- Compile unit test classes -->
- <target name="compile-test" depends="compile-core">
- <mkdir dir="${test-classes.dir}" />
-
- <javac srcdir="${test-src.dir}" destdir="${test-classes.dir}" includes="**/*.java" debug="on" source="1.5">
- <classpath refid="test-path" />
- </javac>
-
- </target>
-
- <!-- Compile and run unit tests -->
- <target name="test" depends="compile-core, compile-test" description="Runs the unit tests for the project.">
- <mkdir dir="${test-results.dir}" />
-
- <echo message="Excuting unit tests using endorsed directory ${java.endorsed.dirs}" />
- <junit printsummary="off"
- fork="yes"
- forkmode="once"
- haltonerror="false"
- haltonfailure="false"
- dir="${basedir}"
- errorproperty="testFailed">
- <jvmarg value="-Djava.endorsed.dirs=${java.endorsed.dirs}" />
- <classpath refid="test-path" />
- <formatter type="xml" />
- <batchtest todir="${test-results.dir}">
- <fileset dir="${test-classes.dir}">
- <include name="**/*Test.class" />
- </fileset>
- </batchtest>
- </junit>
- <junitreport todir="${test-results.dir}">
- <fileset dir="${test-results.dir}">
- <include name="TEST-*.xml" />
- </fileset>
- <report format="frames" todir="${test-report.dir}" />
- </junitreport>
-
- <echo message="Test report available at ${test-report.dir}/index.html" />
- <fail if="testFailed" message="Test failure; see ${test-report.dir}/index.html for more information." />
- </target>
-
- <!-- Javadoc core (non-test) classes -->
- <target name="javadoc" description="Creates the JavaDoc documentatin for the project.">
- <mkdir dir="${javadoc.dir}" />
- <javadoc packagenames="org.opensaml.*"
- sourcepath="${core-src.dir}"
- destdir="${javadoc.dir}"
- author="false"
- version="true"
- windowtitle="${ant.project.name} ${version} Java API"
- doctitle="${ant.project.name} ${version} Java API"
- bottom="${copyright}"
- overview="${core-src.dir}/overview.html">
- <classpath refid="build-path" />
- </javadoc>
- </target>
-
- <!-- Removes previously compiled files -->
- <target name="clean-compile">
- <delete dir="${build.dir}" />
- <delete dir="${dist.dir}" />
- </target>
-
- <!-- Removes all build generated content -->
- <target name="clean" depends="clean-compile" description="Removes any artifact produced by the build process.">
- <delete dir="${javadoc.dir}" />
- <delete dir="${reports.dir}" />
- <delete dir="${dist.dir}" />
- </target>
-
- <!-- Create JAR file -->
- <target name="package" depends="compile-core" description="Creates the project library jar file.">
- <mkdir dir="${dist.dir}" />
-
- <jar destfile="${dist.dir}/${jar.name}" whenempty="fail">
- <fileset dir="${classpathres.dir}" />
- <zipfileset dir="${metainf.dir}" prefix="META-INF/" />
- <zipfileset dir="${core-classes.dir}" />
- </jar>
-
- </target>
-
<target name="install" description="Installs the identity provider software.">
- <input message="Is this a new installation? Answering yes will overwrite your current configuration. [yes|no]"
+ <input message="Is this a new installation? Answering yes will overwrite your current configuration."
addproperty="new.install"
+ validargs="yes,no"
defaultvalue="no" />
<if>
<equals arg1="${new.install}" arg2="yes" />
<then>
- <input message="Where should the Shibboleth Identity Provider software be installed? [default: ${idp.home}]"
+ <input message="Where should the Shibboleth Identity Provider software be installed?"
addproperty="idp.home.input"
defaultvalue="${idp.home}" />
<var name="idp.home" value="${idp.home.input}" />
- <input message="What is the hostname of the Shibboleth Identity Provider server? [default: ${idp.hostname}]"
+ <pathToAbsolutePath path="${idp.home}" addproperty="idp.home.path" />
+ <pathToUrl path="${idp.home}" addproperty="idp.home.url" />
+
+ <input message="What is the hostname of the Shibboleth Identity Provider server?"
addproperty="idp.hostname.input"
defaultvalue="${idp.hostname}" />
<var name="idp.hostname" value="${idp.hostname.input}" />
-
+
<input message="A keystore is about to be generated for you. Please enter a password that will be used to protect it."
addproperty="idp.keystore.pass" />
<entry key="idp.hostname" value="${idp.hostname.input}" />
</propertyfile>
- <mkdir dir="${idp.home}" />
- <mkdir dir="${idp.home}/bin" />
- <mkdir dir="${idp.home}/conf" />
- <mkdir dir="${idp.home}/credentials" />
- <mkdir dir="${idp.home}/lib" />
- <mkdir dir="${idp.home}/lib/endorsed" />
- <mkdir dir="${idp.home}/logs" />
- <mkdir dir="${idp.home}/metadata" />
- <mkdir dir="${idp.home}/war" />
+ <mkdir dir="${idp.home.path}" />
+ <mkdir dir="${idp.home.path}/bin" />
+ <mkdir dir="${idp.home.path}/conf" />
+ <mkdir dir="${idp.home.path}/credentials" />
+ <mkdir dir="${idp.home.path}/lib" />
+ <mkdir dir="${idp.home.path}/lib/endorsed" />
+ <mkdir dir="${idp.home.path}/logs" />
+ <mkdir dir="${idp.home.path}/metadata" />
+ <mkdir dir="${idp.home.path}/war" />
<var name="idp.entity.id" value="https://${idp.hostname}/idp/shibboleth" />
<echo message="Generating signing and encryption key, certificate, and keystore. " />
<selfSignedCert hostname="${idp.hostname}"
- privateKeyFile="${idp.home}/credentials/idp.key"
- certificateFile="${idp.home}/credentials/idp.crt"
- keystoreFile="${idp.home}/credentials/idp.jks"
+ privateKeyFile="${idp.home.path}/credentials/idp.key"
+ certificateFile="${idp.home.path}/credentials/idp.crt"
+ keystoreFile="${idp.home.path}/credentials/idp.jks"
keystorePassword="${idp.keystore.pass}"
- uriSubjectAltNames="${idp.entity.id}"/>
+ uriSubjectAltNames="${idp.entity.id}" />
- <copy todir="${idp.home}/bin" preservelastmodified="true">
+ <copy todir="${idp.home.path}/bin" preservelastmodified="true">
<fileset dir="${tools.dir}" />
<filterset begintoken="$" endtoken="$">
- <filter token="IDP_HOME" value="${idp.home}" />
+ <filter token="IDP_HOME" value="${idp.home.path}" />
<filter token="IDP_VERSION" value="${version}" />
</filterset>
</copy>
- <chmod file="${idp.home}/bin/*.sh" perm="+x" />
+ <chmod file="${idp.home.path}/bin/*.sh" perm="+x" />
- <copy todir="${idp.home}/conf" preservelastmodified="true" overwrite="true">
- <fileset dir="${conf.dir}" />
+ <copy todir="${idp.home.path}/conf" preservelastmodified="true" overwrite="true">
+ <fileset dir="${resources.dir}/conf-tmpl" />
<filterset begintoken="$" endtoken="$">
- <filter token="IDP_HOME" value="${idp.home}" />
+ <filter token="IDP_HOME" value="${idp.home.path}" />
<filter token="IDP_VERSION" value="${version}" />
<filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
<filter token="IDP_SCOPE" value="${idp.scope}" />
</filterset>
</copy>
- <stringFromFile input="${idp.home}/credentials/idp.crt" addProperty="idp.cert" />
+ <stringFromFile input="${idp.home.path}/credentials/idp.crt" addProperty="idp.cert" />
<regexSplit input="${idp.cert}"
regex="\A.*-----\s((?:.*\s)*)-----END.*\Z"
addproperty="idp.metadata.cert" />
- <copy todir="${idp.home}/metadata" preservelastmodified="true" overwrite="true">
- <fileset dir="${metadata.dir}" />
+ <copy todir="${idp.home.path}/metadata" preservelastmodified="true" overwrite="true">
+ <fileset dir="${resources.dir}/metadata-tmpl" />
<filterset begintoken="$" endtoken="$">
<filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
<filter token="IDP_SCOPE" value="${idp.scope}" />
</then>
</if>
- <copy todir="${idp.home}/lib" preservelastmodified="true">
+ <copy todir="${idp.home.path}/lib" preservelastmodified="true">
<fileset dir="${lib.dir}" />
<fileset file="${dist.dir}/${jar.name}" />
<fileset file="${build-lib.dir}/servlet-2.4.jar" />
</copy>
-
- <copy todir="${idp.home}/lib/endorsed" preservelastmodified="true" failonerror="false">
+
+ <copy todir="${idp.home.path}/lib/endorsed" preservelastmodified="true" failonerror="false">
<fileset dir="endorsed" />
</copy>
- <copy todir="${webinf-temp.dir}">
- <fileset dir="${webinf.dir}" />
+ <!-- create web.xml -->
+ <copy file="${webapp.dir}/WEB-INF/web.xml"
+ todir="${installer.dir}"
+ preservelastmodified="true"
+ overwrite="true">
<filterset begintoken="$" endtoken="$">
- <filter token="IDP_HOME" value="${idp.home}" />
- <filter token="IDP_VERSION" value="${version}" />
+ <filter token="IDP_HOME" value="${idp.home.url}" />
</filterset>
</copy>
- <jar destfile="${idp.home}/war/${war.name}" whenempty="fail">
- <zipfileset dir="${webinf-temp.dir}" prefix="WEB-INF/" />
- <zipfileset dir="${webpages.dir}" prefix="" />
- <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib/" />
- <zipfileset file="${dist.dir}/${jar.name}" prefix="WEB-INF/lib/" />
- </jar>
- </target>
-
- <!-- **************************************************************** -->
- <!-- *** *** -->
- <!-- *** Developer Tasks *** -->
- <!-- *** *** -->
- <!-- **************************************************************** -->
-
- <!-- Checks code against style guidelines -->
- <target name="checkstyle" description="Developer task: Produces coding standard compliance report.">
- <mkdir dir="${reports.dir}" />
+ <!-- build the war file -->
+ <war warfile="${idp.home.path}/war/${war.name}.war" webxml="${installer.dir}/web.xml">
+ <lib dir="${basedir}/lib" />
+ <webinf dir="${webapp.dir}/WEB-INF" excludes="web.xml" />
+ <fileset dir="${webapp.dir}" excludes="WEB-INF/**" />
+ </war>
- <checkstyle config="${basedir}/checkstyle.xml" failOnViolation="false" classpathref="build-path">
- <fileset dir="src" includes="**/*.java" />
- <formatter type="plain" toFile="${reports.dir}/checkstyle-report.txt" />
- </checkstyle>
+ <!-- Remove generated web.xml -->
+ <delete file="${installer.dir}/web.xml" />
</target>
-</project>
+</project>
\ No newline at end of file
idp.home = /opt/shibboleth-idp-${version}
-war.name=idp.war
idp.hostname=idp.example.org
\ No newline at end of file
<exclude>org.apache.xalan:*</exclude>
<exclude>org.apache.ant:*</exclude>
<exclude>ant-contrib:*</exclude>
+ <exclude>edu.internet2.middleware:ant-extensions:*</exclude>
</excludes>
<includes>
<include>*:jar:*</include>
<includes>
<include>org.apache.ant:*</include>
<include>ant-contrib:*</include>
+ <include>edu.internet2.middleware:ant-extensions:*</include>
</includes>
</dependencySet>
<dependencySet>
</dependencySets>
<fileSets>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+
<!-- Copy up our installer srcipts into the root of the package -->
<fileSet>
<directory>src/installer/bash</directory>
<outputDirectory>/src/main/webapp</outputDirectory>
</fileSet>
- <!-- Docs -->
+ <!-- Documentation -->
<fileSet>
<includes>
<include>RELEASE-NOTES*</include>
<include>LICENSE*</include>
</includes>
</fileSet>
-
- <!-- Documentation -->
<fileSet>
<directory>doc/</directory>
<outputDirectory>/doc</outputDirectory>
<exclude>org.apache.xalan:*</exclude>
<exclude>org.apache.ant:*</exclude>
<exclude>ant-contrib:*</exclude>
+ <exclude>edu.internet2.middleware:ant-extensions:*</exclude>
</excludes>
<includes>
<include>*:jar:*</include>
<includes>
<include>org.apache.ant:*</include>
<include>ant-contrib:*</include>
+ <include>edu.internet2.middleware:ant-extensions:*</include>
</includes>
</dependencySet>
<dependencySet>
+++ /dev/null
-package edu.internet2.middleware.shibboleth.idp;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opensaml.Configuration;
-import org.opensaml.util.resource.ClasspathResource;
-import org.opensaml.util.resource.Resource;
-import org.opensaml.util.resource.ResourceException;
-import org.opensaml.xml.XMLObjectBuilderFactory;
-import org.opensaml.xml.io.MarshallerFactory;
-import org.opensaml.xml.io.UnmarshallerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-
-import edu.internet2.middleware.shibboleth.common.BaseTestCase;
-import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
-
-/**
- * Base unit test case for Spring configuration tests.
- */
-public class BaseIdPTestCase extends BaseTestCase {
-
- /** Factory for XMLObject builders. */
- protected XMLObjectBuilderFactory builderFactory;
-
- /** Factory for XMLObject marshallers. */
- protected MarshallerFactory marshallerFactory;
-
- /** Factory for XMLObject unmarshallers. */
- protected UnmarshallerFactory unmarshallerFactory;
-
- /** Configuration resources to be loaded for all unit tests. */
- private List<Resource> configResources;
-
- /** {@inheritDoc} */
- protected void setUp() throws Exception {
- builderFactory = Configuration.getBuilderFactory();
- marshallerFactory = Configuration.getMarshallerFactory();
- unmarshallerFactory = Configuration.getUnmarshallerFactory();
-
- configResources = new ArrayList<Resource>();
- }
-
- /**
- * Creates a Spring application context from the instance defined config resources.
- *
- * @return the created context
- *
- * @throws ResourceException thrown if there is a problem reading the configuration resources
- */
- protected ApplicationContext createSpringContext() throws ResourceException {
- return createSpringContext(configResources);
- }
-
- /**
- * Creates a Spring application context from the given configuration and any instance registered configurations.
- *
- * @param config spring configuration file to be located on the classpath
- *
- * @return the configured spring context
- *
- * @throws ResourceException thrown if the given resources can not be located
- */
- protected ApplicationContext createSpringContext(String config) throws ResourceException {
- String[] configs = new String[1];
- configs[0] = config;
- return createSpringContext(configs);
- }
-
- /**
- * Creates a Spring application context from the given configurations and any instance registered configurations.
- *
- * @param configs spring configuration files to be located on the classpath
- *
- * @return the configured spring context
- *
- * @throws ResourceException thrown if the given resources can not be located
- */
- protected ApplicationContext createSpringContext(String[] configs) throws ResourceException {
- ArrayList<Resource> resources = new ArrayList<Resource>();
- resources.addAll(configResources);
- if (configs != null) {
- for (String config : configs) {
- resources.add(new ClasspathResource(config));
- }
- }
-
- return createSpringContext(resources);
- }
-
- /**
- * Creates a Spring context from the given resources.
- *
- * @param configs context configuration resources
- *
- * @return the created context
- *
- * @throws ResourceException thrown if there is a problem reading the configuration resources
- */
- protected ApplicationContext createSpringContext(List<Resource> configs) throws ResourceException {
- GenericApplicationContext gContext = new GenericApplicationContext();
- SpringConfigurationUtils.populateRegistry(gContext, configs);
- gContext.refresh();
- return gContext;
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package edu.internet2.middleware.shibboleth.idp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.opensaml.Configuration;
+import org.opensaml.util.resource.ClasspathResource;
+import org.opensaml.util.resource.Resource;
+import org.opensaml.util.resource.ResourceException;
+import org.opensaml.xml.ConfigurationException;
+import org.opensaml.xml.XMLObject;
+import org.opensaml.xml.XMLObjectBuilderFactory;
+import org.opensaml.xml.io.Marshaller;
+import org.opensaml.xml.io.MarshallerFactory;
+import org.opensaml.xml.io.Unmarshaller;
+import org.opensaml.xml.io.UnmarshallerFactory;
+import org.opensaml.xml.io.UnmarshallingException;
+import org.opensaml.xml.parse.BasicParserPool;
+import org.opensaml.xml.parse.XMLParserException;
+import org.opensaml.xml.util.XMLHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
+
+/**
+ * Base unit test case for Spring configuration tests.
+ */
+public class BaseTestCase extends XMLTestCase {
+
+ /** Parser manager used to parse XML. */
+ protected static BasicParserPool parser;
+
+ /** Factory for XMLObject builders. */
+ protected XMLObjectBuilderFactory builderFactory;
+
+ /** Factory for XMLObject marshallers. */
+ protected MarshallerFactory marshallerFactory;
+
+ /** Factory for XMLObject unmarshallers. */
+ protected UnmarshallerFactory unmarshallerFactory;
+
+ /** Class logger. */
+ private static Logger log = LoggerFactory.getLogger(BaseTestCase.class);
+
+ /** Configuration resources to be loaded for all unit tests. */
+ private List<Resource> configResources;
+
+ /** {@inheritDoc} */
+ protected void setUp() throws Exception {
+ XMLUnit.setIgnoreWhitespace(true);
+
+ try {
+ ShibTestBootstrap.bootstrap();
+ } catch (ConfigurationException e) {
+ fail(e.getMessage());
+ }
+
+ parser = new BasicParserPool();
+ parser.setNamespaceAware(true);
+ builderFactory = Configuration.getBuilderFactory();
+ marshallerFactory = Configuration.getMarshallerFactory();
+ unmarshallerFactory = Configuration.getUnmarshallerFactory();
+
+ configResources = new ArrayList<Resource>();
+ }
+
+ /**
+ * Creates a Spring application context from the instance defined config resources.
+ *
+ * @return the created context
+ *
+ * @throws ResourceException thrown if there is a problem reading the configuration resources
+ */
+ protected ApplicationContext createSpringContext() throws ResourceException {
+ return createSpringContext(configResources);
+ }
+
+ /**
+ * Creates a Spring application context from the given configuration and any instance registered configurations.
+ *
+ * @param config spring configuration file to be located on the classpath
+ *
+ * @return the configured spring context
+ *
+ * @throws ResourceException thrown if the given resources can not be located
+ */
+ protected ApplicationContext createSpringContext(String config) throws ResourceException {
+ String[] configs = new String[1];
+ configs[0] = config;
+ return createSpringContext(configs);
+ }
+
+ /**
+ * Creates a Spring application context from the given configurations and any instance registered configurations.
+ *
+ * @param configs spring configuration files to be located on the classpath
+ *
+ * @return the configured spring context
+ *
+ * @throws ResourceException thrown if the given resources can not be located
+ */
+ protected ApplicationContext createSpringContext(String[] configs) throws ResourceException {
+ ArrayList<Resource> resources = new ArrayList<Resource>();
+ resources.addAll(configResources);
+ if (configs != null) {
+ for (String config : configs) {
+ resources.add(new ClasspathResource(config));
+ }
+ }
+
+ return createSpringContext(resources);
+ }
+
+ /**
+ * Creates a Spring context from the given resources.
+ *
+ * @param configs context configuration resources
+ *
+ * @return the created context
+ *
+ * @throws ResourceException thrown if there is a problem reading the configuration resources
+ */
+ protected ApplicationContext createSpringContext(List<Resource> configs) throws ResourceException {
+ GenericApplicationContext gContext = new GenericApplicationContext();
+ SpringConfigurationUtils.populateRegistry(gContext, configs);
+ gContext.refresh();
+ return gContext;
+ }
+
+ /**
+ * Asserts a given XMLObject is equal to an expected DOM. The XMLObject is marshalled and the resulting DOM object
+ * is compared against the expected DOM object for equality.
+ *
+ * @param expectedDOM the expected DOM
+ * @param xmlObject the XMLObject to be marshalled and compared against the expected DOM
+ */
+ public void assertEquals(Document expectedDOM, XMLObject xmlObject) {
+ assertEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject);
+ }
+
+ /**
+ * Asserts a given XMLObject is equal to an expected DOM. The XMLObject is marshalled and the resulting DOM object
+ * is compared against the expected DOM object for equality.
+ *
+ * @param failMessage the message to display if the DOMs are not equal
+ * @param expectedDOM the expected DOM
+ * @param xmlObject the XMLObject to be marshalled and compared against the expected DOM
+ */
+ public void assertEquals(String failMessage, Document expectedDOM, XMLObject xmlObject) {
+ Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
+ if (marshaller == null) {
+ fail("Unable to locate marshaller for " + xmlObject.getElementQName()
+ + " can not perform equality check assertion");
+ }
+
+ try {
+ Element generatedDOM = marshaller.marshall(xmlObject, parser.newDocument());
+ if (log.isDebugEnabled()) {
+ log.debug("Marshalled DOM was " + XMLHelper.nodeToString(generatedDOM));
+ }
+ assertXMLEqual(failMessage, expectedDOM, generatedDOM.getOwnerDocument());
+ } catch (Exception e) {
+ log.error("Marshalling failed with the following error:", e);
+ fail("Marshalling failed with the following error: " + e);
+ }
+ }
+
+ /**
+ * Unmarshalls an element file into its SAMLObject.
+ *
+ * @param elementFile the classpath path to an XML document to unmarshall
+ *
+ * @return the SAMLObject from the file
+ */
+ protected XMLObject unmarshallElement(String elementFile) {
+ try {
+ Document doc = parser.parse(BaseTestCase.class.getResourceAsStream(elementFile));
+ Element samlElement = doc.getDocumentElement();
+
+ Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(samlElement);
+ if (unmarshaller == null) {
+ fail("Unable to retrieve unmarshaller by DOM Element");
+ }
+
+ return unmarshaller.unmarshall(samlElement);
+ } catch (XMLParserException e) {
+ fail("Unable to parse element file " + elementFile);
+ } catch (UnmarshallingException e) {
+ fail("Unmarshalling failed when parsing element file " + elementFile + ": " + e);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package edu.internet2.middleware.shibboleth.idp;\r
+\r
+import org.opensaml.DefaultBootstrap;\r
+import org.opensaml.xml.ConfigurationException;\r
+\r
+/**\r
+ * Extension to the SAML test bootstrap process which sets up configuration for testing purposes.\r
+ */\r
+public class ShibTestBootstrap extends DefaultBootstrap {\r
+\r
+ /** List of XMLTooling configuration files with test configuration. */\r
+ private static String[] testConfigs = { "/shibboleth-saml-ext-config.xml", };\r
+\r
+ /** {@inheritDoc} */\r
+ public static synchronized void bootstrap() throws ConfigurationException {\r
+ DefaultBootstrap.bootstrap();\r
+\r
+ initializeXMLTooling(testConfigs);\r
+ }\r
+}
\ No newline at end of file
import org.springframework.context.ApplicationContext;
-import edu.internet2.middleware.shibboleth.idp.BaseIdPTestCase;
+import edu.internet2.middleware.shibboleth.idp.BaseTestCase;
/**
* Base unit test case for Spring configuration tests.
*/
-public class BaseConf1TestCase extends BaseIdPTestCase {
+public class BaseConf1TestCase extends BaseTestCase {
/** Application context containing the loaded IdP configuration. */
private ApplicationContext appCtx;