[java-identity-provider] branch main updated: Support for checking prereq modules.
Scott Cantor
cantor.2 at osu.edu
Thu Oct 1 18:41:00 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=8a8c644147b98304cfdb419c4ecc63aa6c542b46
The following commit(s) were added to refs/heads/main by this push:
new 8a8c64414 Support for checking prereq modules.
8a8c64414 is described below
commit 8a8c644147b98304cfdb419c4ecc63aa6c542b46
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Oct 1 14:40:58 2020 -0400
Support for checking prereq modules.
---
.../idp/installer/plugin/impl/PluginInstaller.java | 41 ++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index ae06a1d37..3cbb8684e 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -33,11 +33,14 @@ import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
+import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
+import java.util.Set;
import java.util.ServiceLoader.Provider;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -65,6 +68,8 @@ import net.shibboleth.idp.installer.BuildWar;
import net.shibboleth.idp.installer.InstallerSupport;
import net.shibboleth.idp.installer.ProgressReportingOutputStream;
import net.shibboleth.idp.installer.plugin.impl.TrustStore.Signature;
+import net.shibboleth.idp.module.IdPModule;
+import net.shibboleth.idp.module.ModuleContext;
import net.shibboleth.idp.plugin.IdPPlugin;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
@@ -243,6 +248,8 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
LOG.info("Installing Plugin {} version {}.{}.{}", pluginId,
description.getMajorVersion(),description.getMinorVersion(), description.getPatchVersion());
+ checkRequiredModules();
+
final Path myWebApp = idpHome.resolve("dist").resolve("edit-webapp-" + pluginId);
InstallerSupport.setReadOnly(myWebApp, false);
@@ -352,6 +359,40 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
throw new BuildException(e);
}
}
+
+ /**
+ * Police that required modules for plugin installation are enabled.
+ *
+ * @throws BuildException if any required modules are missing or disabled
+ */
+ private void checkRequiredModules() throws BuildException {
+
+ // TODO: maybe this belongs in the CLI rather than the utility class?
+ // OTOH if the update process is recoverable then a failed update
+ // should rollback the uninstall of the original...
+
+ final ModuleContext moduleContext = new ModuleContext(idpHome);
+ final Set<String> requiredModules = new HashSet<>(description.getRequiredModules());
+
+ final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
+ while (modules.hasNext() && !requiredModules.isEmpty()) {
+ try {
+ final IdPModule module = modules.next();
+ if (requiredModules.contains(module.getId())) {
+ if (module.isEnabled(moduleContext)) {
+ requiredModules.remove(module.getId());
+ }
+ }
+ } catch (final ServiceConfigurationError e) {
+ LOG.error("Unable to instantiate IdPModule", e);
+ }
+ }
+
+ if (!requiredModules.isEmpty()) {
+ LOG.warn("Required modules are missing or disabled: {}", requiredModules);
+ throw new BuildException("One or more required modules are not enabled");
+ }
+ }
/** Copy the files the distribution tells us to.
* @throws BuildException if badness is happens.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list