[java-identity-provider] 02/02: JPAR-182 Check our Distributions for consistency
Rod Widdowson
rdw at steadingsoftware.com
Thu Sep 16 15:42:41 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch dev/JPAR-182
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=eccc1bb8652ed0ef39a0cdcd333934955baaad30
commit eccc1bb8652ed0ef39a0cdcd333934955baaad30
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Sep 16 16:39:51 2021 +0100
JPAR-182 Check our Distributions for consistency
https://shibboleth.atlassian.net/browse/JPAR-182
Wire in the IdP enforcer
- Add a complete set of keyRings
- Change the pom file appropriately
- Delete the old installer tests.
---
idp-distribution/pom.xml | 31 +
.../src/main/enforcer/keyRings/addingAKey.txt | 6 +
.../src/main/enforcer/keyRings}/antlr.gpg | Bin
.../src/main/enforcer/keyRings}/ch.qos.logback.gpg | Bin
.../src/main/enforcer/keyRings}/com.beust.gpg | Bin
.../main/enforcer/keyRings}/com.duosecurity.gpg | Bin
.../src/main/enforcer/keyRings}/com.fasterxml.gpg | Bin
.../keyRings}/com.fasterxml.jackson.core.gpg | Bin
.../keyRings}/com.fasterxml.jackson.datatype.gpg | Bin
.../enforcer/keyRings}/com.fasterxml.woodstox.gpg | Bin
.../main/enforcer/keyRings}/com.github.jasminb.gpg | Bin
.../keyRings}/com.google.code.findbugs.gpg | Bin
.../enforcer/keyRings}/com.google.errorprone.gpg | Bin
.../main/enforcer/keyRings}/com.google.guava.gpg | Bin
.../main/enforcer/keyRings}/com.google.j2objc.gpg | Bin
.../main/enforcer/keyRings}/com.sun.activation.gpg | Bin
.../src/main/enforcer/keyRings}/com.sun.istack.gpg | Bin
.../src/main/enforcer/keyRings}/com.sun.mail.gpg | Bin
.../src/main/enforcer/keyRings}/com.unboundid.gpg | Bin
.../src/main/enforcer/keyRings}/commons-cli.gpg | Bin
.../src/main/enforcer/keyRings}/commons-codec.gpg | Bin
.../src/main/enforcer/keyRings}/commons-lang.gpg | Bin
.../src/main/enforcer/keyRings/empty.gpg | 0
.../src/main/enforcer/keyRings}/eu.bitwalker.gpg | Bin
.../enforcer/keyRings}/io.dropwizard.metrics.gpg | Bin
.../main/enforcer/keyRings}/jakarta.xml.bind.gpg | Bin
.../main/enforcer/keyRings}/javax.persistence.gpg | Bin
.../src/main/enforcer/keyRings}/joda-time.gpg | Bin
.../src/main/enforcer/keyRings}/net.bytebuddy.gpg | Bin
.../main/enforcer/keyRings}/net.shibboleth.ext.gpg | Bin
.../enforcer/keyRings}/net.shibboleth.liberty.gpg | Bin
.../keyRings}/net.shibboleth.utilities.gpg | Bin
.../src/main/enforcer/keyRings}/net.spy.gpg | Bin
.../src/main/enforcer/keyRings/org.apache.ant.gpg | Bin 0 -> 2658 bytes
.../main/enforcer/keyRings/org.apache.commons.gpg | Bin 0 -> 33098 bytes
.../keyRings}/org.apache.httpcomponents.gpg | Bin
.../enforcer/keyRings}/org.apache.santuario.gpg | Bin
.../enforcer/keyRings}/org.apache.velocity.gpg | Bin
.../main/enforcer/keyRings}/org.bouncycastle.gpg | Bin
.../enforcer/keyRings}/org.checkerframework.gpg | Bin
.../enforcer/keyRings}/org.codehaus.janino.gpg | Bin
.../enforcer/keyRings}/org.codehaus.woodstox.gpg | Bin
.../main/enforcer/keyRings}/org.cryptacular.gpg | Bin
.../src/main/enforcer/keyRings}/org.dom4j.gpg | Bin
.../src/main/enforcer/keyRings}/org.glassfish.gpg | Bin
.../main/enforcer/keyRings}/org.glassfish.jaxb.gpg | Bin
.../enforcer/keyRings/org.hibernate.common.gpg | Bin 0 -> 2304 bytes
.../src/main/enforcer/keyRings}/org.hibernate.gpg | Bin
.../src/main/enforcer/keyRings}/org.javassist.gpg | Bin
.../src/main/enforcer/keyRings/org.jboss.gpg | Bin 0 -> 2304 bytes
.../main/enforcer/keyRings/org.jboss.logging.gpg | Bin 0 -> 2304 bytes
.../keyRings/org.jboss.spec.javax.transaction.gpg | Bin 0 -> 2304 bytes
.../src/main/enforcer/keyRings}/org.jetbrains.gpg | Bin
.../src/main/enforcer/keyRings}/org.ldaptive.gpg | Bin
.../src/main/enforcer/keyRings}/org.opensaml.gpg | Bin
.../src/main/enforcer/keyRings}/org.slf4j.gpg | Bin
.../enforcer/keyRings}/org.springframework.gpg | Bin
.../keyRings}/org.springframework.webflow.gpg | Bin
.../idp/dependencies/DependencyTest.java | 725 ---------------------
.../shibboleth/idp/dependencies/GPGKeyRing.java | 257 --------
.../net/shibboleth/idp/dependencies/ParsedPom.java | 517 ---------------
.../net/shibboleth/idp/dependencies/PomLoader.java | 35 -
.../net/shibboleth/idp/dependencies/stores/dom4j | 0
.../idp/dependencies/stores/org.apache.commons.gpg | Bin 1776 -> 0 bytes
.../idp/dependencies/stores/org.hibernate.common | 0
.../shibboleth/idp/dependencies/stores/org.jboss | 0
.../idp/dependencies/stores/org.jboss.logging | 0
.../stores/org.jboss.spec.javax.transaction | 0
68 files changed, 37 insertions(+), 1534 deletions(-)
diff --git a/idp-distribution/pom.xml b/idp-distribution/pom.xml
index 2df60fc74..523e1b7ac 100644
--- a/idp-distribution/pom.xml
+++ b/idp-distribution/pom.xml
@@ -250,6 +250,37 @@
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.shibboleth.idp</groupId>
+ <artifactId>idp-enforcer</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>idp-enforce</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <idpEnforcer implementation="net.shibboleth.idp.enforcer.impl.IdPEnforcer">
+ <enforcerData>${basedir}/src/main/enforcer</enforcerData>
+ <parentPomDir>../idp-parent</parentPomDir>
+ <jarDirs>${project.build.directory}/${idp.finalName}/bin/lib ${project.build.directory}/${idp.finalName}/webapp/WEB-INF/lib</jarDirs>
+ <checkSignatures>true</checkSignatures>
+ <checkDependencies>true</checkDependencies>
+ <listJarSources>false</listJarSources>
+ </idpEnforcer>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/idp-distribution/src/main/enforcer/keyRings/addingAKey.txt b/idp-distribution/src/main/enforcer/keyRings/addingAKey.txt
new file mode 100644
index 000000000..ec7d0c247
--- /dev/null
+++ b/idp-distribution/src/main/enforcer/keyRings/addingAKey.txt
@@ -0,0 +1,6 @@
+1) Download the new key as foo.asc
+2) copy empty.gpg to ./<GroupName>.gpg (which makes sure its old style)
+2) gpg --no-default-keyring --keyring ./<GroupName>.gpg --import foo.asc
+3) rm ./<GroupName>.bak
+4) rm ./<GroupName>.gpg.lock
+
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/antlr.gpg b/idp-distribution/src/main/enforcer/keyRings/antlr.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/antlr.gpg
rename to idp-distribution/src/main/enforcer/keyRings/antlr.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/ch.qos.logback.gpg b/idp-distribution/src/main/enforcer/keyRings/ch.qos.logback.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/ch.qos.logback.gpg
rename to idp-distribution/src/main/enforcer/keyRings/ch.qos.logback.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.beust.gpg b/idp-distribution/src/main/enforcer/keyRings/com.beust.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.beust.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.beust.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.duosecurity.gpg b/idp-distribution/src/main/enforcer/keyRings/com.duosecurity.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.duosecurity.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.duosecurity.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.gpg b/idp-distribution/src/main/enforcer/keyRings/com.fasterxml.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.fasterxml.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.jackson.core.gpg b/idp-distribution/src/main/enforcer/keyRings/com.fasterxml.jackson.core.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.jackson.core.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.fasterxml.jackson.core.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.jackson.datatype.gpg b/idp-distribution/src/main/enforcer/keyRings/com.fasterxml.jackson.datatype.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.jackson.datatype.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.fasterxml.jackson.datatype.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.woodstox.gpg b/idp-distribution/src/main/enforcer/keyRings/com.fasterxml.woodstox.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.fasterxml.woodstox.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.fasterxml.woodstox.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.github.jasminb.gpg b/idp-distribution/src/main/enforcer/keyRings/com.github.jasminb.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.github.jasminb.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.github.jasminb.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.code.findbugs.gpg b/idp-distribution/src/main/enforcer/keyRings/com.google.code.findbugs.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.code.findbugs.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.google.code.findbugs.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.errorprone.gpg b/idp-distribution/src/main/enforcer/keyRings/com.google.errorprone.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.errorprone.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.google.errorprone.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.guava.gpg b/idp-distribution/src/main/enforcer/keyRings/com.google.guava.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.guava.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.google.guava.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.j2objc.gpg b/idp-distribution/src/main/enforcer/keyRings/com.google.j2objc.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.google.j2objc.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.google.j2objc.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.activation.gpg b/idp-distribution/src/main/enforcer/keyRings/com.sun.activation.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.activation.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.sun.activation.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.istack.gpg b/idp-distribution/src/main/enforcer/keyRings/com.sun.istack.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.istack.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.sun.istack.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.mail.gpg b/idp-distribution/src/main/enforcer/keyRings/com.sun.mail.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.sun.mail.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.sun.mail.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.unboundid.gpg b/idp-distribution/src/main/enforcer/keyRings/com.unboundid.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/com.unboundid.gpg
rename to idp-distribution/src/main/enforcer/keyRings/com.unboundid.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-cli.gpg b/idp-distribution/src/main/enforcer/keyRings/commons-cli.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-cli.gpg
rename to idp-distribution/src/main/enforcer/keyRings/commons-cli.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-codec.gpg b/idp-distribution/src/main/enforcer/keyRings/commons-codec.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-codec.gpg
rename to idp-distribution/src/main/enforcer/keyRings/commons-codec.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-lang.gpg b/idp-distribution/src/main/enforcer/keyRings/commons-lang.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-lang.gpg
rename to idp-distribution/src/main/enforcer/keyRings/commons-lang.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-lang3 b/idp-distribution/src/main/enforcer/keyRings/empty.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/commons-lang3
rename to idp-distribution/src/main/enforcer/keyRings/empty.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/eu.bitwalker.gpg b/idp-distribution/src/main/enforcer/keyRings/eu.bitwalker.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/eu.bitwalker.gpg
rename to idp-distribution/src/main/enforcer/keyRings/eu.bitwalker.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/io.dropwizard.metrics.gpg b/idp-distribution/src/main/enforcer/keyRings/io.dropwizard.metrics.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/io.dropwizard.metrics.gpg
rename to idp-distribution/src/main/enforcer/keyRings/io.dropwizard.metrics.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/jakarta.xml.bind.gpg b/idp-distribution/src/main/enforcer/keyRings/jakarta.xml.bind.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/jakarta.xml.bind.gpg
rename to idp-distribution/src/main/enforcer/keyRings/jakarta.xml.bind.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/javax.persistence.gpg b/idp-distribution/src/main/enforcer/keyRings/javax.persistence.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/javax.persistence.gpg
rename to idp-distribution/src/main/enforcer/keyRings/javax.persistence.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/joda-time.gpg b/idp-distribution/src/main/enforcer/keyRings/joda-time.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/joda-time.gpg
rename to idp-distribution/src/main/enforcer/keyRings/joda-time.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.bytebuddy.gpg b/idp-distribution/src/main/enforcer/keyRings/net.bytebuddy.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.bytebuddy.gpg
rename to idp-distribution/src/main/enforcer/keyRings/net.bytebuddy.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.ext.gpg b/idp-distribution/src/main/enforcer/keyRings/net.shibboleth.ext.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.ext.gpg
rename to idp-distribution/src/main/enforcer/keyRings/net.shibboleth.ext.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.liberty.gpg b/idp-distribution/src/main/enforcer/keyRings/net.shibboleth.liberty.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.liberty.gpg
rename to idp-distribution/src/main/enforcer/keyRings/net.shibboleth.liberty.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.utilities.gpg b/idp-distribution/src/main/enforcer/keyRings/net.shibboleth.utilities.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.shibboleth.utilities.gpg
rename to idp-distribution/src/main/enforcer/keyRings/net.shibboleth.utilities.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.spy.gpg b/idp-distribution/src/main/enforcer/keyRings/net.spy.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/net.spy.gpg
rename to idp-distribution/src/main/enforcer/keyRings/net.spy.gpg
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.apache.ant.gpg b/idp-distribution/src/main/enforcer/keyRings/org.apache.ant.gpg
new file mode 100644
index 000000000..34e30be2f
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.apache.ant.gpg differ
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.apache.commons.gpg b/idp-distribution/src/main/enforcer/keyRings/org.apache.commons.gpg
new file mode 100644
index 000000000..f351988f8
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.apache.commons.gpg differ
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.httpcomponents.gpg b/idp-distribution/src/main/enforcer/keyRings/org.apache.httpcomponents.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.httpcomponents.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.apache.httpcomponents.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.santuario.gpg b/idp-distribution/src/main/enforcer/keyRings/org.apache.santuario.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.santuario.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.apache.santuario.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.velocity.gpg b/idp-distribution/src/main/enforcer/keyRings/org.apache.velocity.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.velocity.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.apache.velocity.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.bouncycastle.gpg b/idp-distribution/src/main/enforcer/keyRings/org.bouncycastle.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.bouncycastle.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.bouncycastle.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.checkerframework.gpg b/idp-distribution/src/main/enforcer/keyRings/org.checkerframework.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.checkerframework.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.checkerframework.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.codehaus.janino.gpg b/idp-distribution/src/main/enforcer/keyRings/org.codehaus.janino.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.codehaus.janino.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.codehaus.janino.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.codehaus.woodstox.gpg b/idp-distribution/src/main/enforcer/keyRings/org.codehaus.woodstox.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.codehaus.woodstox.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.codehaus.woodstox.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.cryptacular.gpg b/idp-distribution/src/main/enforcer/keyRings/org.cryptacular.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.cryptacular.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.cryptacular.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.dom4j.gpg b/idp-distribution/src/main/enforcer/keyRings/org.dom4j.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.dom4j.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.dom4j.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.glassfish.gpg b/idp-distribution/src/main/enforcer/keyRings/org.glassfish.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.glassfish.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.glassfish.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.glassfish.jaxb.gpg b/idp-distribution/src/main/enforcer/keyRings/org.glassfish.jaxb.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.glassfish.jaxb.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.glassfish.jaxb.gpg
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.hibernate.common.gpg b/idp-distribution/src/main/enforcer/keyRings/org.hibernate.common.gpg
new file mode 100644
index 000000000..ba064b5ce
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.hibernate.common.gpg differ
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.hibernate.gpg b/idp-distribution/src/main/enforcer/keyRings/org.hibernate.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.hibernate.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.hibernate.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.javassist.gpg b/idp-distribution/src/main/enforcer/keyRings/org.javassist.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.javassist.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.javassist.gpg
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.jboss.gpg b/idp-distribution/src/main/enforcer/keyRings/org.jboss.gpg
new file mode 100644
index 000000000..ba064b5ce
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.jboss.gpg differ
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.jboss.logging.gpg b/idp-distribution/src/main/enforcer/keyRings/org.jboss.logging.gpg
new file mode 100644
index 000000000..ba064b5ce
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.jboss.logging.gpg differ
diff --git a/idp-distribution/src/main/enforcer/keyRings/org.jboss.spec.javax.transaction.gpg b/idp-distribution/src/main/enforcer/keyRings/org.jboss.spec.javax.transaction.gpg
new file mode 100644
index 000000000..ba064b5ce
Binary files /dev/null and b/idp-distribution/src/main/enforcer/keyRings/org.jboss.spec.javax.transaction.gpg differ
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jetbrains.gpg b/idp-distribution/src/main/enforcer/keyRings/org.jetbrains.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jetbrains.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.jetbrains.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.ldaptive.gpg b/idp-distribution/src/main/enforcer/keyRings/org.ldaptive.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.ldaptive.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.ldaptive.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.opensaml.gpg b/idp-distribution/src/main/enforcer/keyRings/org.opensaml.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.opensaml.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.opensaml.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.slf4j.gpg b/idp-distribution/src/main/enforcer/keyRings/org.slf4j.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.slf4j.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.slf4j.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.springframework.gpg b/idp-distribution/src/main/enforcer/keyRings/org.springframework.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.springframework.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.springframework.gpg
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.springframework.webflow.gpg b/idp-distribution/src/main/enforcer/keyRings/org.springframework.webflow.gpg
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.springframework.webflow.gpg
rename to idp-distribution/src/main/enforcer/keyRings/org.springframework.webflow.gpg
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
deleted file mode 100644
index de74cd9db..000000000
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.dependencies;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.security.Security;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.annotation.Nonnull;
-
-import org.apache.http.client.HttpClient;
-import org.apache.maven.shared.invoker.DefaultInvocationRequest;
-import org.apache.maven.shared.invoker.DefaultInvoker;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.shared.invoker.MavenInvocationException;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.opensaml.core.testing.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.testng.SkipException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.ext.spring.resource.HTTPResource;
-import net.shibboleth.idp.dependencies.GPGKeyRing.Signature;
-import net.shibboleth.idp.dependencies.ParsedPom.PomArtifact;
-import net.shibboleth.idp.installer.plugin.impl.PluginInstallerSupport;
-import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
-import net.shibboleth.utilities.java.support.xml.ParserPool;
-
-/**
- * Test that what we see is what we wanted in abuild - we do this by reading the pom
- */
-public class DependencyTest extends OpenSAMLInitBaseTestCase implements PomLoader {
-
- /** Set this up if you want to run the tests from eclipse. */
- private static String LOCAL_MAVEN_HOME = null;
-
- /** A list of things which get added to real versions. */
- private static final List<String> extensionGarnish = List.of("-SNAPSHOT", "-GA", "-jre", "-empty-to-avoid-conflict-with-guava");
-
- /** Parse for us to use. */
- private ParserPool parserPool;
-
- /** Work space. Deleted on exit. */
- private Path workingDir;
-
- /** The parsed idp-parent pom. */
- private ParsedPom idpParent;
-
- /** The parsed java-parent pom. */
- private ParsedPom projectParent;
-
- /** where we are writing to (target/dependencyReport.txt).*/
- private PrintWriter report;
-
- /** The key rings for our signature test. */
- private final Map<String, Optional<GPGKeyRing>> keyRings = new HashMap<>();
-
- /** The ArtefactId to GroupId mapping */
- private final Map<String, String> artifactToGroup = new HashMap<>();
-
- /** Is this a snapshot build (the idp version ends with -SNAPSHOT.*/
- private boolean isSnapShot;
-
- /** Http Client. */
- private HttpClient httpClient;
-
- /** We have as an assumption that the CWD is idp-installer. Test this.
- * @throws IOException if the directory isn't what we expect it to be
- */
- @BeforeClass public void testWorkingDir() throws IOException {
- final Path path = Path.of(".");
- final String myPath = path.toFile().getCanonicalPath();
- final String indirectPath = path.resolve("..").resolve("idp-installer").toFile().getCanonicalPath();
-
- assertTrue(path.resolve("..").resolve("idp-war").toFile().exists());
- assertEquals(myPath, indirectPath);
- }
-
- /** Set up maven.
- * This relies on a couple of dodgy tests when running from maven from the command line and
- * on the user setting up {@link #LOCAL_MAVEN_HOME} when running from eclipse.
- */
- @BeforeClass public void setupMavenEnvironment() {
- if (System.getProperty("maven.home") != null) {
- return;
- }
- String home = LOCAL_MAVEN_HOME;
- if (home == null) {
- home = System.getenv("MAVEN_HOME");
- }
- if (home == null) {
- home = System.getenv("_");
- }
- if (home == null) {
- throw new SkipException("Maven Not Located");
- }
- if (!Files.exists(Path.of(home).resolve("bin").resolve("mvn"))) {
- throw new SkipException("Maven Not found");
- }
-
- System.setProperty("maven.home", home);
- }
-
- /** Parse the idp-parent pom and all related.
- * @throws Exception if a folder or files has issues,
- * if the pom is badly formed, or if the download fails
- */
-
- @BeforeClass(dependsOnMethods = {"setupMavenEnvironment", "testWorkingDir", "initialize"}) public void parsePom() throws Exception {
- workingDir = Files.createTempDirectory("dependencyTest");
- parserPool = XMLObjectProviderRegistrySupport.getParserPool();
-
- idpParent = new ParsedPom(parserPool, this, Path.of("../idp-parent/pom.xml"), "idp-parent/pom.xml", null, Collections.emptyMap());
- final Path lib = Path.of("../idp-war-distribution/target/idp-war-distribution-"+ idpParent.getOurInfo().getVersion()).resolve("WEB-INF").resolve("lib");
- if (!Files.exists(lib)) {
- throw new SkipException("War distribution target not found");
- }
- assertNotNull(idpParent.getParent());
- final Path parentPath = downloadPom(idpParent.getParent());
- projectParent = new ParsedPom(parserPool, this, parentPath, "parent/pom.xml", new Properties(), Collections.emptyMap());
- idpParent = new ParsedPom(parserPool, this, Path.of("../idp-parent/pom.xml"), "idp-parent/pom.xml", projectParent.getProperties(), projectParent.getManagedDependencies());
- assertTrue(projectParent.getCompileDependencies().isEmpty(), "project parent contributes compile dependencies");
- assertTrue(projectParent.getRuntimeDependencies().isEmpty(), "project parent contributes run time dependencies");
- isSnapShot = idpParent.getOurInfo().getVersion().endsWith("-SNAPSHOT");
- }
-
- /** Populate the {@link #artifactToGroup} map.
- * First from the parse pom and then by hand.
- */
- @BeforeClass(dependsOnMethods = "parsePom") public void setupGroupMapping() {
- for (final PomArtifact dep : idpParent.getCompileDependencies()) {
- artifactToGroup.put(dep.getArtifactId(), dep.getGroupId());
- }
- for (final PomArtifact dep : idpParent.getRuntimeDependencies()) {
- final String comp = artifactToGroup.get(dep.getArtifactId());
- if (comp != null) {
- assertEquals(comp, dep.getGroupId(), "Group mismatch dependency for " + dep.getArtifactId());
- } else {
- artifactToGroup.put(dep.getArtifactId(), dep.getGroupId());
- }
- }
- for (final PomArtifact artifact : idpParent.getManagedDependencies().values()) {
- if (!artifactToGroup.containsKey(artifact.getArtifactId())) {
- artifactToGroup.put(artifact.getArtifactId(), artifact.getGroupId());
- }
- }
- for (final PomArtifact artifact : projectParent.getManagedDependencies().values()) {
- if (!artifactToGroup.containsKey(artifact.getArtifactId())) {
- artifactToGroup.put(artifact.getArtifactId(), artifact.getGroupId());
- }
- }
-
- addMapping("annotations", "org.jetbrains");
- addMapping("antlr", "antlr");
- addMapping("byte-buddy", "net.bytebuddy");
- addMapping("checker-qual", "org.checkerframework");
- addMapping("classmate", "com.fasterxml");
- addMapping("commons-cli", "commons-cli");
- addMapping("commons-compiler", "org.codehaus.janino");
- addMapping("commons-lang3", "org.apache.commons");
- addMapping("commons-pool2", "org.apache.commons");
- addMapping("dom4j", "org.dom4j");
- addMapping("error_prone_annotations", "com.google.errorprone");
- addMapping("failureaccess", "com.google.guava");
- addMapping("hibernate-commons-annotations", "org.hibernate.common");
- addMapping("istack-commons-runtime", "com.sun.istack");
- addMapping("j2objc-annotations", "com.google.j2objc");
- addMapping("jandex", "org.jboss");
- addMapping("jboss-logging", "org.jboss.logging");
- addMapping("jboss-transaction-api_1.2_spec", "org.jboss.spec.javax.transaction");
- addMapping("javassist", "org.javassist");
- addMapping("javax.persistence-api", "javax.persistence");
- addMapping("listenablefuture", "com.google.guava");
- addMapping("spymemcached", "net.spy");
- addMapping("spring-binding", "org.springframework.webflow");
- addMapping("stax2-api", "org.codehaus.woodstox");
- addMapping("txw2", "org.glassfish.jaxb");
- addMapping("woodstox-core", "com.fasterxml.woodstox");
- }
-
- /** Add the pair to the artifact to group mapping. With test for duplicate
- * @param artifactId the atifact
- * @param groupId the groupid
- */
- private void addMapping(String artifactId, String groupId) {
- final String old = artifactToGroup.put(artifactId, groupId);
- if (old != null) {
- report.format("Duplicate group declaration for %s\n" , artifactId);
- }
-
- }
-
- /** Create the reporter print stream
- * @throws Exception if we cannot build our client
- */
- @BeforeClass(dependsOnMethods = {"testWorkingDir"}) public void initialize() throws Exception {
- final HttpClientBuilder builder = new HttpClientBuilder();
- builder.setConnectionTimeout(Duration.ofSeconds(5));
- httpClient = builder.buildClient();
- final File out = new File("target/dependencyReport.txt");
- final FileOutputStream outStream = new FileOutputStream(out);
- report = new PrintWriter(new BufferedOutputStream(outStream));
- report.format("POM based Testing started at %s\n\n", Instant.now().toString());
- if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
- Security.addProvider(new BouncyCastleProvider());
- }
- }
-
- /** Clean up after ourselves. */
- @AfterClass public void teardown() {
- report.flush();
- report.close();
- PluginInstallerSupport.deleteTree(workingDir);
- }
-
- /** The Body of the signature test. Are all the files what we expected?
- * @throws IOException if the enumeration failed.
- */
- @Test(enabled=true) public void testSignatures() throws IOException {
- report.format("\nSigning Test Started at %s\n", Instant.now().toString());
- final Path lib = Path.of("../idp-war-distribution/target/idp-war-distribution-"+ idpParent.getOurInfo().getVersion()).resolve("WEB-INF").resolve("lib");
-
- final int sigFails = Files.list(lib).mapToInt(e -> checkSignature(e)).sum();
- if (sigFails != 0) {
- report.format("\t%d non-exempt jar files did not have valid signatures\n", sigFails);
- } else {
- report.format("\tAll non-exempt jar files correctly signed\n");
- }
- report.format("Signing Test Completed at %s\n", Instant.now().toString());
- //assertEquals(sigFails, 0, "Signature Failures");
- }
-
- /** Given the Path and the parent dir check the signature.
- * @param jarFile the file to check
- * @return 1 if anything went wrong
- */
- private int checkSignature(Path jarFile) {
- final Pair<String,String> name = splitFileName(jarFile.getFileName().toString());
- final String group = artifactToGroup.get(name.getFirst());
- if (group == null) {
- report.format("%-30s: %-14s Could not determine group\n", name.getFirst(), name.getSecond());
- return 1;
- }
- final PomArtifact jarAsArtifact = idpParent.new PomArtifact(group, name.getFirst(), name.getSecond());
- if (idpParent.getGeneratedArtifacts().contains(jarAsArtifact)) {
- report.format("%-30s: %-14s Generated by IdP build. Not checked\n", name.getFirst(), name.getSecond());
- return 0;
- }
- if (isSnapShot && name.getSecond().endsWith("-SNAPSHOT")) {
- report.format("%-30s: %-14s Snapshot version on a snapshot build. Not Checked\n", name.getFirst(), name.getSecond());
- return 0;
- }
- final GPGKeyRing keyRing = getKeyRing(group);
- if (keyRing == null) {
- report.format("%-30s: %-14s No keyring for group %s\n", name.getFirst(), name.getSecond(), group);
- return 1;
- }
- final Signature sig = getSignature(jarAsArtifact);
- if (sig == null) {
- report.format("%-30s: %-14s Could not find signature (group : %s)\n",
- name.getFirst(), name.getSecond(), group);
- return 1;
- }
- if (!keyRing.contains(sig)) {
- report.format("%-30s: %-14s KeyId (%s) not found in keyring for %s\n", name.getFirst(), name.getSecond(), sig.toString(), group);
- return 1;
- }
-
- try (final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(jarFile.toFile()))) {
- if (!keyRing.checkSignature(stream, sig)) {
- report.format("%-30s: %-14s Signature Mismatch : %s in keyring %s\n",
- name.getFirst(), name.getSecond(), keyRing.getKeyInfo(sig), group);
- return 1;
- }
- } catch (IOException e) {
- e.printStackTrace();
- return 1;
- }
- report.format("%-30s: %-14s Signature Match in keyring %s : %s \n",
- name.getFirst(), name.getSecond(), group, keyRing.getKeyInfo(sig));
- return 0;
- }
-
- /** Locate and load the signature for this artefact
- * @param artifact what to load
- * @return the Signature or null if we couldn't locate it.
- */
- private Signature getSignature(final PomArtifact artifact) {
- Path path;
- try {
- path = download(artifact, "jar.asc");
- } catch (final Exception e1) {
- e1.printStackTrace();
- return null;
- }
- if (!Files.exists(path)) {
- return null;
- }
- try (final InputStream stream = new BufferedInputStream(new FileInputStream(path.toFile()))){
- return GPGKeyRing.signatureOf(stream);
- }
- catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /** Locate the keyring in the cache or load & cache it (or a negative lookup).
- * @param group the group to load
- * @return a keyring or null if there wasn't one.
- */
- private GPGKeyRing getKeyRing(final String group) {
- final Optional<GPGKeyRing> opt = keyRings.get(group);
- if (opt != null) {
- if (opt.isEmpty()) {
- return null;
- }
- return opt.get();
- }
-
- try {
- final GPGKeyRing store = new GPGKeyRing(group);
- keyRings.put(group, Optional.of(store));
- return store;
- } catch (Exception e) {
- keyRings.put(group, Optional.empty());
- return null;
- }
- }
-
- /** The Body of the Dependency test. Are all the files what we expected? Who produced what?
- * @throws IOException if the file doesn't exist
- * @throws MavenInvocationException if we fail to download a pom or a dependency
- */
- @Test(enabled=true) public void testDependencies() throws IOException, MavenInvocationException {
- report.format("Dependency Test Started at %s\n", Instant.now().toString());
- if (!idpParent.getDuplicates().isEmpty()) {
- report.format("Duplicates found parsing the poms\n");
- for (final Pair<PomArtifact,PomArtifact> poms : idpParent.getDuplicates()) {
- final PomArtifact f = poms.getFirst();
- final PomArtifact s = poms.getSecond();
-
- report.format("%-30s: %10s (from %s) and %s (from %s)\n", f.getMapKey(),
- f.getVersion(), f.getSourcePomFilename(),
- s.getVersion(), s.getSourcePomFilename());
- }
- }
- final Path lib = Path.of("../idp-war-distribution/target/idp-war-distribution-"+ idpParent.getOurInfo().getVersion()).resolve("WEB-INF").resolve("lib");
-
- final Map<String, String> names = new HashMap<>();
- int wrongVersion = 0;
- int found = 0;
- int nonUsed = 0;
- int dupNames = 0;
- final int similarNames = Files.list(lib).mapToInt(e -> addName(names, lib.relativize(e).toString())).sum();
- report.format("Dependencies found in war file\n\n");
-
- List<PomArtifact> dependencies = new ArrayList<>(idpParent.getCompileDependencies().size() + idpParent.getRuntimeDependencies().size());
- dependencies.addAll(idpParent.getCompileDependencies());
- dependencies.addAll(idpParent.getRuntimeDependencies());
- Collections.sort(dependencies);
- // ArtifactId->(Ver->[source, source])
- final Map<String, Map<String, Set<String>>> dependencySource = new HashMap<>();
- PomArtifact last = null;
- for (PomArtifact artifact : dependencies) {
- final String id = artifact.getArtifactId();
- final String ver = artifact.getVersion();
- final String sourcePomFilename = "(from " + artifact.getSourcePomFilename() + ")";
- final String version = names.remove(id);
- if (idpParent.getGeneratedArtifacts().contains(artifact)) {
- if (!artifact.equals(last)) {
- report.format("%-30s: %12s\tGenerated by parent war\n", id, ver);
- }
- } else if (artifact.equals(last)) {
- report.format("%-30s\t: %12s\tRuntime & Compile: %-22s\n", id, ver, sourcePomFilename);
- dupNames++;
- } else if (version == null) {
- report.format("%-30s\t: %12s\tNot found in war %-22s\n", id, ver, sourcePomFilename);
- nonUsed++;
- } else if (version.equals(ver)) {
- report.format("%-30s\t: %12s\tFound in war %-22s\n", id, ver, sourcePomFilename);
- found++;
- analyzeChild(dependencySource, artifact);
- } else {
- report.format("%-22s\t: %-12s\tVersion Mismatch- found %s %s\n", id, ver, version, sourcePomFilename);
- analyzeChild(dependencySource, artifact.withVersion(version));
- if (!ver.equals(PomArtifact.BAD_VERSION)) {
- wrongVersion++;
- }
- }
- last = artifact;
- }
- if (dupNames != 0) {
- report.format("\n%d Duplicate names\n", dupNames);
- }
- if (similarNames != 0) {
- report.format("\n%d Artifacts with multiple versions\n", similarNames);
- }
-
- report.format("\n%d dependencies, %d found, %d not found, %d mismatched\n\nDependency Sources\n", dependencies.size(), found, nonUsed, wrongVersion);
-
- final List<String> contributedDeps = new ArrayList<>(names.keySet());
- Collections.sort(contributedDeps);
- int noSource = 0;
-
- report.format("Found in WAR but not explicitly defined as a dependency:\n\n");
-
- for (final String dependency: contributedDeps) {
- final Map<String, Set<String>> map = dependencySource.get(dependency);
- final String version = names.get(dependency);
- if (map == null) {
- if (!dependency.startsWith("idp-")) {
- report.format("%-22s\t: %-12s\tNo source artefact found\n", dependency, version);
- noSource++;
- }
- } else {
- final Set<String> sources = map.remove(version);
- if (sources == null) {
- report.format("%-22s\t: %-12s\tNO Dependency contributes this version\n", dependency, version);
- noSource ++;
- } else {
- reportContributions(dependency, version, sources);
- }
- final List<String> versions = new ArrayList<>(map.keySet());
- Collections.sort(versions);
- for (final String ver:versions) {
- reportContributions(dependency, ver, map.get(ver));
- }
- }
- }
- report.format("%d Orphaned artifact(s)\n", noSource);
- report.format("%d Similar artifact names(s)\n", similarNames);
- report.format("%d Wrong Versions(s)\n", wrongVersion);
- report.format("Dependency Test Completed at %s\n\n ", Instant.now().toString());
- assertEquals(wrongVersion, 0, "Mismatched version");
- assertEquals(similarNames, 0, "Multiple similarly named jars");
- //assertEquals(noSource, 0, "Orphaned Artefacts");
- //assertTrue(idpParent.getDuplicates().isEmpty(), "Duplicate dependencies");
- }
-
- /** report the contributions of the provided dependency & version.
- * @param dependency the artifact ID
- * @param version the version we are considering
- * @param sources what caused this to exist
- */
- private void reportContributions(final String dependency, final String version, final Collection<String> sources) {
- List<String> srcs = new ArrayList<>(sources);
- Collections.sort(srcs);
- report.format("%-22s\t: %-12s\tContributed by ", dependency, version);
- for (int i = 0; i < (srcs.size()-1); i++) {
- report.format("%s,", srcs.get(i));
- if ((i&3)==3) {
- report.format("\n \t");
- }
- }
- report.format("%s\n", srcs.get(srcs.size()-1));
- }
-
- /** Given an artifact do an "mvn dependency:copy-dependencies" on it.
- * Then analyse the output file into the map. The dependency name
- * yields a map. Looking this up with a version yields a set of the sources.
- * @param dependencySource where to accumulate the results
- * @param artifact what to start with.
- * @throws MavenInvocationException if maven fails.
- * @throws IOException if a file doesbn't exist.
- */
- private void analyzeChild(final Map<String, Map<String, Set<String>>> dependencySource,
- final PomArtifact artifact) throws MavenInvocationException, IOException {
- final File pomFile = outputPom(artifact);
- final String artifactName = artifact.getArtifactId()+"-"+artifact.getVersion();
- final Path outputDir = workingDir.resolve(artifactName);
-
- final Properties props = new Properties(2);
- props.setProperty("includeScope","runtime");
- props.setProperty("outputDirectory", outputDir.toString());
- InvocationRequest request = new DefaultInvocationRequest().setProperties(props).setPomFile(pomFile).setGoals( Arrays.asList( "dependency:copy-dependencies" ) );
-
- Invoker invoker = new DefaultInvoker();
- invoker.execute( request );
- if (Files.exists(outputDir)) {
- Files.list(outputDir).forEach(e -> addDep(dependencySource, outputDir.relativize(e).toString(), artifact));
- }
- }
-
- /** Add the artifact as a source of this file.
- * @param dependencySources where to accumulate the answers
- * @param dep the file name of the dependency which was down-loaded
- * @param artifact the artifact which provoked the download
- */
- private void addDep(final Map<String, Map<String, Set<String>>> dependencySources,
- final String dep,
- final PomArtifact artifact) {
- final Pair<String,String> depId = splitFileName(dep);
-
- if (artifact.getArtifactId().equals(depId.getFirst()) && artifact.getVersion().equals(depId.getSecond())) {
- // it's us. Not interesting
- return;
- }
-
- // for each version, what contributed this dependency
- Map<String, Set<String>> depEntry = dependencySources.get(depId.getFirst());
- if (depEntry == null) {
- depEntry = new HashMap<>();
- dependencySources.put(depId.getFirst(), depEntry);
- }
- Set<String> provider = depEntry.get(depId.getSecond());
- if (provider == null) {
- provider = new HashSet<>();
- depEntry.put(depId.getSecond(), provider);
- }
- provider.add(artifact.getArtifactId()+"-"+artifact.getVersion());
- }
-
- /** Create a pom file which has one dependency - this artifact.
- * @param artifact the artifact.
- * @return the file.
- * @throws FileNotFoundException if the created pom file doesnt exist?
- */
- private File outputPom(PomArtifact artifact) throws FileNotFoundException {
- final File file = workingDir.resolve(new StringBuilder(artifact.getArtifactId())
- .append("-")
- .append(artifact.getVersion())
- .append(".xml").
- toString()).toFile();
- try (final PrintWriter pom = new PrintWriter(new BufferedOutputStream(new FileOutputStream(file)))) {
- pom.format("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
- + " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
- + " <modelVersion>4.0.0</modelVersion>\n"
- + "\n"
- + " <parent>\n"
- + " <groupId>%s</groupId>\n"
- + " <artifactId>%s</artifactId>\n"
- + " <version>%s</version>\n"
- + " </parent>\n"
- + "\n", idpParent.getOurInfo().getGroupId(), idpParent.getOurInfo().getArtifactId(), idpParent.getOurInfo().getVersion());
- pom.format(" <groupId>shibboleth.net.dependency</groupId>\n"
- + " <version>0.0.1</version>\n"
- + " <name>Shibboleth Dependency</name>\n"
- + " <artifactId>idp-dep-%s</artifactId>\n"
- + " <packaging>jar</packaging>\n\n", artifact.getArtifactId());
- pom.format(" <dependencies>\n"
- + " <dependency>\n"
- + " <groupId>%s</groupId><artifactId>%s</artifactId><version>%s</version>\n"
- + " </dependency>\n"
- + " </dependencies>\n\n", artifact.getGroupId(),artifact.getArtifactId(), artifact.getVersion());
- pom.format(" <repositories>\n"
- + " <repository>\n"
- + " <id>shib-release</id>\n"
- + " <url>https://build.shibboleth.net/nexus/content/groups/public</url>\n"
- + " <snapshots>\n"
- + " <enabled>false</enabled>\n"
- + " </snapshots>\n"
- + " </repository>\n"
- + " <repository>\n"
- + " <id>shib-snapshot</id>\n"
- + " <url>https://build.shibboleth.net/nexus/content/repositories/snapshots</url>\n"
- + " <releases>\n"
- + " <enabled>false</enabled>\n"
- + " </releases>\n"
- + " </repository>\n"
- + " </repositories>\n"
- + "</project>\n");
- pom.flush();
- pom.close();
- }
- return file;
- }
-
- /** Split the file name into the artifact (first) and version (second).
- * @param inName the file name
- * @return a pair.
- */
- private Pair<String, String> splitFileName(final String inName) {
- final String name;
- if (inName.endsWith(".jar")) {
- name = inName.substring(0, inName.length()-4);
- } else {
- name = inName;
- }
- int last = name.lastIndexOf("-");
- for (String otherGarnish : extensionGarnish) {
- if (name.endsWith(otherGarnish)) {
- last = name.substring(0, name.length()-otherGarnish.length()).lastIndexOf("-");
- break;
- }
- }
- final String base = name.substring(0, last);
- String versionExtension = name.substring(last+1);
- return new Pair<>(base, versionExtension);
- }
-
- /** Trivial accumulator to pull a name in the lib directory apart and insert it into the map.
- * @param names The map to accumulate into
- * @param jarPath the file we are looking at.
- * @return 1 if there as a artifact with the same name.
- */
- private int addName(Map<String, String> names, String jarPath) {
- final Pair<String, String> nm = splitFileName(jarPath);
- final String oldName = names.put(nm.getFirst(), nm.getSecond());
- if (oldName == null) {
- return 0;
- }
- return 1;
- }
-
- /** {@inheritDoc} */
- @Override
- public Path downloadPom(final PomArtifact artifact) throws Exception {
- final Path path = download(artifact, "pom");
- assertTrue(Files.exists(path));
- return path;
- }
-
- /**
- * Get the base URL in Maven for the artifact.
- * @param artifact the input.
- * @return the address in nexus.
- */
- @Nonnull private String baseURLfor(@Nonnull final PomArtifact artifact) {
- if (artifact.getGroupId().startsWith("net.shibboleth") || artifact.getGroupId().startsWith("org.opensaml")) {
- return "https://build.shibboleth.net/nexus/service/local/repositories/releases/content/";
- }
- return "https://build.shibboleth.net/nexus/service/local/repositories/thirdparty/content/";
- }
-
- /** Tell Maven to download the POM for artifact and returns it's path.
- * @param artifact what to look for
- * @param type the type to dowb load ('pom' or 'jar.asc' and so on
- * @return the pom as a {@link Path}
- * @throws Exception from the copy
- */
- public Path download(final PomArtifact artifact, final String type) throws Exception {
- final Path path = workingDir.resolve(artifact.getArtifactId() + "." + type);
- final File output = path.toFile();
- assertFalse(output.exists());
-
- if (artifact.getVersion().endsWith("SNAPSHOT")) {
- // Gotta use maven...
- final String fullArtifactName = new StringBuilder(artifact.getGroupId())
- .append(':')
- .append(artifact.getArtifactId())
- .append(':')
- .append(artifact.getVersion())
- .append(':')
- .append(type)
- .toString();
- final Properties props = new Properties(3);
- props.setProperty("artifact",fullArtifactName);
- props.setProperty("mdep.stripVersion","true");
- props.setProperty("outputDirectory", workingDir.toString());
-
- InvocationRequest request = new DefaultInvocationRequest().setProperties(props).setGoals( Arrays.asList( "dependency:copy"));
- Invoker invoker = new DefaultInvoker();
- invoker.execute( request );
- } else {
- final String fullAddress = new StringBuilder(baseURLfor(artifact))
- .append(artifact.getGroupId().replaceAll("\\.", "/"))
- .append('/')
- .append(artifact.getArtifactId())
- .append('/')
- .append(artifact.getVersion())
- .append('/')
- .append(artifact.getArtifactId())
- .append('-')
- .append(artifact.getVersion())
- .append('.')
- .append(type)
- .toString();
- final HTTPResource inResource = new HTTPResource(httpClient, fullAddress);
-
- try (final OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(output));
- final InputStream inStream = inResource.getInputStream()) {
- inStream.transferTo(outputStream);
- }
- }
- return path;
- }
-}
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/GPGKeyRing.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/GPGKeyRing.java
deleted file mode 100644
index a3629ea93..000000000
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/GPGKeyRing.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.dependencies;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.NotThreadSafe;
-
-import org.bouncycastle.openpgp.PGPException;
-import org.bouncycastle.openpgp.PGPObjectFactory;
-import org.bouncycastle.openpgp.PGPPublicKey;
-import org.bouncycastle.openpgp.PGPPublicKeyRing;
-import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
-import org.bouncycastle.openpgp.PGPSignature;
-import org.bouncycastle.openpgp.PGPSignatureList;
-import org.bouncycastle.openpgp.PGPUtil;
-import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
-import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
-import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
-import org.slf4j.Logger;
-
-import net.shibboleth.idp.installer.impl.InstallationLogger;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-
-/**
- * Code to handle (load, update, check) the keyrings for each maven group.
- */
- at NotThreadSafe public final class GPGKeyRing {
-
- /** logger. */
- @Nonnull private final Logger log = InstallationLogger.getLogger(GPGKeyRing.class);
-
- /** The key store backup. */
- @Nullable private Path backup;
-
- /** KeyRing. */
- @NonnullAfterInit private PGPPublicKeyRingCollection keyRings;
-
- /** Constructor.
- * Locate and load the keyring for the provided group, First look for the keyring
- * and then for an asc file.
- * @param group the group to look for
- * @throws Exception under various error conditions.
- */
- public GPGKeyRing(final String group) throws Exception {
- try (final InputStream armoredKeys = getClass().getResourceAsStream("/net/shibboleth/idp/dependencies/stores/"+group);
- final InputStream keyRingStream = getClass().getResourceAsStream("/net/shibboleth/idp/dependencies/stores/"+group+".gpg")) {
- if (keyRingStream != null) {
- log.debug("Loading keyring for {}", group);
- keyRings = new PGPPublicKeyRingCollection(keyRingStream, new JcaKeyFingerprintCalculator());
- } else if (armoredKeys != null) {
- log.debug("Loading asci keys for {}", group);
- keyRings = loadRingFromAsc(armoredKeys);
- } else {
- log.warn("No asc of keyring found for {}", group);
- throw new FileNotFoundException("Could not locate keyring");
- }
- } catch (final Exception e) {
- log.error("Could not load explicit trust store for {} from stream", group, e);
- throw e;
- }
- }
-
- /** Return a store loaded from the supplied stream.
- *
- * @param in the stream
- * @return a suitable store
- * @throws IOException from {@link Files#newInputStream(Path, java.nio.file.OpenOption...)} and from
- * {@link PGPPublicKeyRingCollection#PGPPublicKeyRingCollection(InputStream,
- * org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator)}
- */
- private static PGPPublicKeyRingCollection loadRingFromAsc(final InputStream in) throws IOException {
- try (final InputStream decoded = PGPUtil.getDecoderStream(in)) {
- final ArrayList<PGPPublicKeyRing> listr = new ArrayList<>();
-
- PGPObjectFactory pgpFact = new PGPObjectFactory(decoded, new JcaKeyFingerprintCalculator());
- Object obj;
- while ((obj = pgpFact.nextObject()) != null) {
- // Inner loop - when new factories return nothing we are done
- do {
- if (!(obj instanceof PGPPublicKeyRing)) {
- throw new IOException(obj.getClass().getName() + " found where PGPPublicKeyRing expected");
- }
- listr.add((PGPPublicKeyRing) obj);
- obj = pgpFact.nextObject();
- } while (obj != null);
- pgpFact = new PGPObjectFactory(decoded, new JcaKeyFingerprintCalculator());
- }
- return new PGPPublicKeyRingCollection(listr);
- } catch (final PGPException e) {
- throw new IOException("Error reading key ring", e);
- }
- }
-
- /** Lookup and return the key information for this key (and any parent).
- * @param sigForKey the signature to lookup
- * @return the string in a normalized form.
- */
- protected String getKeyInfo(final Signature sigForKey) {
- final PGPPublicKeyRing keyRing;
- try {
- keyRing = keyRings.getPublicKeyRing(sigForKey.getSignature().getKeyID());
- } catch (final PGPException e) {
- log.warn("Couldn't locate key", e);
- return null;
- }
- if (keyRing == null) {
- log.info("Provided key stream did not contain a key for {}", sigForKey);
- return null;
- }
- final StringBuilder builder = new StringBuilder("KeyId: ").append(sigForKey.toString());
- final Iterator<PGPPublicKey> keyIterator = keyRing.getPublicKeys();
- final Set<String> seenNames = new HashSet<>();
- while (keyIterator.hasNext()) {
- final PGPPublicKey key = keyIterator.next();
- final Iterator<String> namesIterator = key.getUserIDs();
- while (namesIterator.hasNext()) {
- final String name = namesIterator.next();
- if (seenNames.add(name)) {
- builder.append("\tUsername:\t").append(name);
- }
- }
- }
- return builder.toString();
- }
-
- /** Provide an opaque signature object from an input stream.
- * @param stream what to read.
- * @return the Signature.
- * @throws IOException if there is a problem reading the file of it it doesn't represent a signature
- */
- protected static Signature signatureOf(final InputStream stream) throws IOException {
- return new Signature(stream);
- }
-
- /** Does the key that made this signature exist in our keyrings?
- * @param signature what to ask about
- * @return whether it is there
- */
- protected boolean contains(final Signature signature) {
-
- final PGPSignature sig = signature.getSignature();
-
- log.debug("Looking for key with Id {}", signature);
-
- try {
- return keyRings.getPublicKey(sig.getKeyID()) != null;
- } catch (final PGPException e) {
- log.warn("Error looking for key {}", signature, e);
- return false;
- }
- }
-
- /** Run a signature check over the streams.
- * @param input what to check
- * @param signature what to check with
- * @return whether it passed or not
- * @throws IOException if we get an error reading the stream
- */
- protected boolean checkSignature(final InputStream input, final Signature signature) throws IOException {
- try {
- final PGPSignature pgpSignature = signature.getSignature();
- final PGPPublicKey pubKey = keyRings.getPublicKey(pgpSignature.getKeyID());
- pgpSignature.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), pubKey);
-
- final byte[] buffer = new byte[1024];
- int count = input.read(buffer);
- while (count > 0) {
- pgpSignature.update(buffer, 0, count);
- count = input.read(buffer);
- }
- final boolean result = pgpSignature.verify();
- if (result) {
- log.debug("Signature Check Succeeded");
- } else {
- log.debug("Signature Check Failed");
- }
- return result;
- } catch (final PGPException e) {
- log.warn("Error thrown during signature check", e);
- return false;
- }
- }
-
-
- /**
- * An opaque handle around a {@link PGPSignature}.
- */
- public static final class Signature {
-
- /** What we are hiding. */
- @Nonnull private PGPSignature signature;
-
- /** printable key. */
- @Nonnull private String keyId;
-
- /**
- * Constructor.
- *
- * @param input input data
- *
- * @throws IOException if an error occurs
- */
- protected Signature(final @Nonnull InputStream input) throws IOException {
- try (final InputStream sigStream = PGPUtil.getDecoderStream(input)) {
- final JcaPGPObjectFactory factory = new JcaPGPObjectFactory(sigStream);
- final Object first = factory.nextObject();
- if (first instanceof PGPSignatureList) {
- final PGPSignatureList list = (PGPSignatureList) first;
- signature = list.get(0);
- } else {
- throw new IOException("Provided file was not a signature");
- }
- }
- keyId = String.format("0X%016X", signature.getKeyID());
- }
-
- /**
- * Get signature.
- *
- * @return the signature
- */
- protected PGPSignature getSignature() {
- return signature;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return keyId;
- }
- }
-}
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
deleted file mode 100644
index f94a62397..000000000
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.dependencies;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.annotation.Nonnull;
-
-import org.opensaml.core.testing.OpenSAMLInitBaseTestCase;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import com.beust.jcommander.internal.Nullable;
-
-import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-import net.shibboleth.utilities.java.support.xml.ElementSupport;
-import net.shibboleth.utilities.java.support.xml.ParserPool;
-import net.shibboleth.utilities.java.support.xml.XMLParserException;
-
-/**
- *
- */
-public class ParsedPom extends OpenSAMLInitBaseTestCase{
-
- /** Compile dependencies - what we care about. */
- private final Map<String, PomArtifact> compileDependencies = new HashMap<>();
-
- /** BOM dependencies. */
- private final Map<String, PomArtifact> bomDependencies = new HashMap<>();
-
- /** Rum time dependencies. */
- private final Map<String, PomArtifact> runtimeDependencies = new HashMap<>();
-
- /** Duplicate dependencies. */
- private final List<Pair<PomArtifact,PomArtifact>> duplicates = new ArrayList<>();
-
- /** Generated artifacts. */
- private final Set<PomArtifact> generated = new HashSet<>();
-
- /** Inherits dependencies. */
- private final Map<String, PomArtifact> managedDependencies;
-
- /** Which the POM.*/
- @Nonnull private final String sourcePomInfo;
-
- /** Properties. */
- private final Properties properties = new Properties();
-
- /** Parent Pom .*/
- private PomArtifact parent;
-
- /** Us. */
- private final PomArtifact us;
-
- /**
- * Constructor.
- *
- * @param parsers a short-cut to let us parse XML
- * @param pomLoader how to get a pom (for BOM loading)
- * @param pom the {@link Path} to the pom.
- * @param pomName an ID for the pom
- * @param parentPomProperties if present it is properties from the parent (which might be empty), if null we are *only*
- * looking for the parent pom coordinates.
- * @param map Managed dependencies from parent
- * @throws Exception if we have issued locating a bom
- */
- public ParsedPom(@Nonnull final ParserPool parsers,
- @Nonnull final PomLoader pomLoader,
- @Nonnull final Path pom,
- @Nonnull final String pomName,
- @Nullable final Properties parentPomProperties,
- @Nonnull final Map<String, PomArtifact> map)
- throws Exception {
-
- managedDependencies = new HashMap<>(map);
-
- sourcePomInfo = pomName;
- Document document;
- try (final InputStream stream = new BufferedInputStream(new FileInputStream(pom.toFile()))) {
- document = parsers.parse(stream);
- }
-
- final Element el = document.getDocumentElement();
- if (!"project".equals(el.getLocalName())) {
- throw new XMLParserException("Top level element was not <project>");
- }
- final List<Element> par = ElementSupport.getChildElementsByTagName(el, "parent");
-
- if (!par.isEmpty()) {
- parseParent(par.get(0));
- }
-
- us = new PomArtifact(el, parent);
-
- if (parentPomProperties == null) {
- return;
- }
- for (final Object p:parentPomProperties.keySet()) {
- String pName = (String) p;
- properties.setProperty(pName, parentPomProperties.getProperty(pName));
- }
- properties.setProperty("project.basedir", "<bogus_base_dir>");
- properties.setProperty("project.build.directory", "<bogus_build_dir>");
- properties.setProperty("project.version", us.getVersion());
- properties.setProperty("project.groupId", us.getGroupId());
- properties.setProperty("project.artifactId", us.getArtifactId());
-
- final List<Element> props = ElementSupport.getChildElementsByTagName(el, "properties");
- if (!props.isEmpty()) {
- parseProperties(props.get(0));
- }
-
- for (final Element dependencyMgt: ElementSupport.getChildElementsByTagName(el, "dependencyManagement")) {
- for (final Element dependencies : ElementSupport.getChildElementsByTagName(dependencyMgt, "dependencies")) {
- parseManagedDependencies(dependencies);
- }
- }
- for (final PomArtifact bom : bomDependencies.values()) {
- final ParsedPom parsedBom = new ParsedPom(parsers, pomLoader, pomLoader.downloadPom(bom), bom.toString(), new Properties(), Collections.emptyMap());
- for (PomArtifact dep : parsedBom.getManagedDependencies().values()) {
- addWithCheck(dep, managedDependencies);
- }
- }
-
- for (final Element dependencies : ElementSupport.getChildElementsByTagName(el, "dependencies")) {
- parseDependencies(dependencies);
- }
-
- final Set<PomArtifact> moduleCompiles = new HashSet<>();
- final Set<PomArtifact> moduleRuntimes = new HashSet<>();
- for (final Element modules: ElementSupport.getChildElementsByTagName(el, "modules")) {
- for (final Element module: ElementSupport.getChildElementsByTagName(modules, "module")) {
- // Kludge for Jackson
- final Path modulePath = Path.of(module.getTextContent()).resolve("pom.xml");
- if (Files.exists(modulePath)) {
- final ParsedPom modulePom = new ParsedPom(parsers, pomLoader, modulePath ,module.getTextContent(), properties, managedDependencies);
- moduleCompiles.addAll(modulePom.getCompileDependencies());
- moduleRuntimes.addAll(modulePom.getRuntimeDependencies());
- generated.add(modulePom.getOurInfo());
- }
- }
- }
- for (final PomArtifact dep : moduleCompiles) {
- addWithCheck(dep, compileDependencies);
- }
- for (final PomArtifact dep : moduleRuntimes) {
- addWithCheck(dep, runtimeDependencies);
- }
- }
-
- /** Get the text content of the element, performing property replacement as we go.
- * @param el the element
- * @return the value, with property replacement.
- */
- @Nonnull protected String getElementContent(final Element el) {
- String remainingContents = StringSupport.trimOrNull(el.getTextContent());
- remainingContents = Constraint.isNotNull(remainingContents, "<" + el.getLocalName() + "> must have content");
- final StringBuilder contents = new StringBuilder();
- for (int index = remainingContents.indexOf("${"); index >= 0; index = remainingContents.indexOf("${")) {
- contents.append(remainingContents.substring(0, index));
- remainingContents = remainingContents.substring(index);
- final int endIndex = remainingContents.indexOf("}");
- if (endIndex <= 1) {
- break;
- }
- final String propName = remainingContents.substring(2, endIndex);
- contents.append(Constraint.isNotNull(properties.getProperty(propName), propName + " is not defined"));
- remainingContents = remainingContents.substring(endIndex+1);
- }
- contents.append(remainingContents);
- return contents.toString();
- }
-
- /** Parse the dependency part of the pom.
- * @param item what to parse
- */
- private void parseDependencies(final Element item) {
- final List<Element> dependencies = ElementSupport.getChildElementsByTagName(item, "dependency");
-
- for (Element dependency : dependencies) {
- final PomArtifact artifact = new PomArtifact(dependency);
- final List<Element> types = ElementSupport.getChildElementsByTagName(dependency, "type");
- if (!types.isEmpty()) {
- final String type = StringSupport.trimOrNull(types.get(0).getTextContent());
- if ("pom".equals(type)) {
- addWithCheck(artifact, bomDependencies);
- continue;
- } else if (!"jar".equals(type)) {
- // not for us
- continue;
- }
- }
- final List<Element> scopes = ElementSupport.getChildElementsByTagName(dependency, "scope");
- if (!scopes.isEmpty()) {
- final String scope = StringSupport.trimOrNull(scopes.get(0).getTextContent());
- if ("runtime".equals(scope)) {
- addWithCheck(artifact, runtimeDependencies);
- continue;
- }
- if (!"compile".equals(scope)) {
- // not for us
- continue;
- }
- }
- addWithCheck(artifact, compileDependencies);
- continue;
- }
- }
-
- /** parse the Managed Dependencies from the provided item
- * @param item what to parse
- */
- private void parseManagedDependencies(final Element item) {
- final List<Element> dependencies = ElementSupport.getChildElementsByTagName(item, "dependency");
- for (Element dependency : dependencies) {
- final PomArtifact artifact = new PomArtifact(dependency);
- final List<Element> types = ElementSupport.getChildElementsByTagName(dependency, "type");
- if (!types.isEmpty()) {
- final String type = StringSupport.trimOrNull(types.get(0).getTextContent());
- if ("pom".equals(type)) {
- addWithCheck(artifact, bomDependencies);
- continue;
- } else if (!"jar".equals(type)) {
- // not for us
- continue;
- }
- }
- addWithCheck(artifact, managedDependencies);
- }
- }
-
- /** Add the artifact to the map, accumulating duplicates.
- * @param artifact what to add
- * @param map wghere to add it
- */
- private void addWithCheck(final PomArtifact artifact, final Map<String, PomArtifact> map) {
- final PomArtifact old = map.put(artifact.getMapKey(),artifact);
- if (old != null && !old.equals(artifact)) {
- duplicates.add(new Pair<>(old, artifact));
- }
- }
-
- /** Parse the properties from the pom.
- * @param item the <properties> element
- */
- private void parseProperties(Element item) {
-
- for (final Element child : ElementSupport.getChildElements(item)) {
- final String name = child.getLocalName();
- final String value = getElementContent(child);
-
- properties.setProperty(name, value);
- }
- }
-
- /** Parse the parent from the pom.
- * @param item the <parent> element
- */
- private void parseParent(Element item) {
- parent = new PomArtifact(item);
- }
-
- /** Returns the Compile Dependencies.
- * @return Returns the Compile Dependencies.
- */
- @Nonnull public Collection<PomArtifact> getCompileDependencies() {
- return compileDependencies.values();
- }
-
- /** Returns the Runtime Dependencies.
- * @return Returns the Runtime Dependencies.
- */
- @Nonnull public Collection<PomArtifact> getRuntimeDependencies() {
- return runtimeDependencies.values();
- }
-
- /** Returns the Managed Dependencies.
- * @return Returns the Managed Dependencies.
- */
- @Nonnull public Map<String, PomArtifact> getManagedDependencies() {
- return managedDependencies;
- }
-
- /** Get artifacts that were duplicated by this build
- * @return Returns the duplicates.
- */
- @Nonnull public List<Pair<PomArtifact, PomArtifact>> getDuplicates() {
- return duplicates;
- }
-
- /** returns any sub modules created by this module.
- * @return Returns the generated.
- */
- @Nonnull public Set<PomArtifact> getGeneratedArtifacts() {
- return generated;
- }
-
- /** Return our artifactInformation.
- * @return us.
- */
- public PomArtifact getOurInfo() {
- return us;
- }
-
- /** Return the parent.
- * @return the parent.
- */
- public PomArtifact getParent() {
- return parent;
- }
-
- /** The <properties> contents.
- * @return Returns the properties.
- */
- public Properties getProperties() {
- return properties;
- }
-
- /** Encapsulation of a <dependency> element. */
- public class PomArtifact implements Comparable<PomArtifact>{
-
- /** What version to give if we cannot find the version. */
- public final static String BAD_VERSION = "VERSION_NOT_DETERMINED";
-
- /** <groupId>.*/
- @Nonnull private final String groupId;
-
- /** <artifactId>.*/
- @Nonnull private final String artifactId;
-
- /** <version>.*/
- @Nonnull private final String version;
-
- /** <exclusions>. */
- @Nonnull private final Set<Pair<String, String>> exclusions = new HashSet<>();
-
- /**
- * Constructor.
- *
- * @param id the <artifactId>
- * @param group the <groupId>
- * @param ver the <version>
- */
- public PomArtifact(final String group, final String id, final String ver) {
- artifactId = id;
- groupId = group;
- version = ver;
- }
-
- /**
- * Constructor.
- *
- * @param item element to interrogate.
- */
- public PomArtifact(final Element item) {
- this(item, null);
- }
-
- /**
- * Constructor.
- *
- * @param item element to interrogate.
- * @param parentArtifact to inherit from
- */
- public PomArtifact(final Element item, final @Nullable PomArtifact parentArtifact) {
-
- final List<Element> grps = ElementSupport.getChildElementsByTagName(item, "groupId");
- if (grps.size() > 0) {
- groupId = getElementContent(grps.get(0));
- } else if (parentArtifact != null) {
- groupId = parentArtifact.getGroupId();
- } else {
- Constraint.isGreaterThan(0, grps.size(), "<groupId> should exist in dependency");
- groupId = null;
- }
-
- final List<Element> arts = ElementSupport.getChildElementsByTagName(item, "artifactId");
- Constraint.isGreaterThan(0, arts.size(), "<artifactId> should exist in dependency");
- artifactId = getElementContent(arts.get(0));
-
- final List<Element> vers = ElementSupport.getChildElementsByTagName(item, "version");
- if (vers.size() > 0) {
- version = getElementContent(vers.get(0));
- } else if (parentArtifact != null) {
- version = parentArtifact.getVersion();
- } else {
- final PomArtifact inherited = managedDependencies.get(groupId+"+"+artifactId);
- if (inherited != null) {
- version = inherited.getVersion();
- } else {
- version = BAD_VERSION;
- }
- }
-
- List<Element> excls = ElementSupport.getChildElementsByTagName(item, "exclusions");
- if (excls.size() > 0) {
- excls = ElementSupport.getChildElementsByTagName(excls.get(0), "exclusion");
- for (Element e : excls) {
- List<Element> els = ElementSupport.getChildElementsByTagName(e, "groupId");
- Constraint.isGreaterThan(0, els.size(), "<groupId> should exist in exclusion");
- final String grp = getElementContent(els.get(0));
- els = ElementSupport.getChildElementsByTagName(e, "artifactId");
- Constraint.isGreaterThan(0, els.size(), "<artifactId> should exist in exclusion");
- final String art = getElementContent(els.get(0));
- exclusions.add(new Pair<>(grp, art));
- }
- }
- }
-
- /**
- * @return Returns the groupId.
- */
- public String getGroupId() {
- return groupId;
- }
-
- /**
- * @return Returns the artifactId.
- */
- public String getArtifactId() {
- return artifactId;
- }
-
- /**
- * @return Returns the version.
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * @return the pom source.
- */
- public String getSourcePomFilename() {
- return sourcePomInfo;
- }
-
- /** Get the key we use in out maps.
- * @return the key - derives from groupId and EntityId
- */
- public String getMapKey() {
- return getGroupId()+"+"+getArtifactId();
- }
-
- /**
- * @return Returns the exclusions.
- */
- public Set<Pair<String, String>> getExclusions() {
- return exclusions;
- }
-
- /** {@inheritDoc} */
- public int compareTo(final PomArtifact o) {
- return getArtifactId().compareTo(o.getArtifactId());
- }
-
- /** {@inheritDoc} */
- public boolean equals(final Object obj) {
- if (obj != null && obj instanceof PomArtifact ) {
- final PomArtifact him = (PomArtifact) obj;
- return him.getArtifactId().equals(getArtifactId()) &&
- him.getGroupId().equals(getGroupId()) &&
- him.getVersion().equals(getVersion());
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public int hashCode() {
- return Objects.hash(artifactId, groupId, version);
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return artifactId + "-" + version;
- }
-
- /** return the same artifact but with an amended version.
- * @param ver the version
- * @return an amended artifact.
- */
- public PomArtifact withVersion(String ver) {
- return new PomArtifact(groupId, artifactId, ver);
- }
- }
-}
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/PomLoader.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/PomLoader.java
deleted file mode 100644
index cee5a0204..000000000
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/PomLoader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.dependencies;
-
-import java.nio.file.Path;
-
-import net.shibboleth.idp.dependencies.ParsedPom.PomArtifact;
-
-/**
- * Abstraction of a way to get hold of a pom.
- */
-public interface PomLoader {
-
- /** tell Something to download the artifact and returns it's path.
- * @param artifact what to look for
- * @return the pom as a {@link Path}
- * @throws Exception on an error
- */
- Path downloadPom(PomArtifact artifact) throws Exception;
-}
\ No newline at end of file
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/dom4j b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/dom4j
deleted file mode 100644
index e69de29bb..000000000
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.commons.gpg b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.commons.gpg
deleted file mode 100644
index 585db490b..000000000
Binary files a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.apache.commons.gpg and /dev/null differ
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.hibernate.common b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.hibernate.common
deleted file mode 100644
index e69de29bb..000000000
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss
deleted file mode 100644
index e69de29bb..000000000
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss.logging b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss.logging
deleted file mode 100644
index e69de29bb..000000000
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss.spec.javax.transaction b/idp-installer/src/test/resources/net/shibboleth/idp/dependencies/stores/org.jboss.spec.javax.transaction
deleted file mode 100644
index e69de29bb..000000000
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list