[java-identity-provider] branch main updated: IDP-2311 Discuss ways of mitigating the plugin/module dependency issues

Rod Widdowson rdw at steadingsoftware.com
Tue Sep 10 18:23:38 UTC 2024


This is an automated email from the git hooks/post-receive script.

rdw 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=57b517dcc107cf29db4e90d038db3ee5d2202217

The following commit(s) were added to refs/heads/main by this push:
     new 57b517dcc IDP-2311 Discuss ways of mitigating the plugin/module dependency issues
57b517dcc is described below

commit 57b517dcc107cf29db4e90d038db3ee5d2202217
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Sep 10 19:07:36 2024 +0100

    IDP-2311 Discuss ways of mitigating the plugin/module dependency issues
    
    https://shibboleth.atlassian.net/browse/IDP-2311
    
    1) Wire up the new Plugin APIs into our FirstPartyIdPPlugin
    2) Add the code to spit out the extra information
    3) Widen the (supressed) tests to make this easier to test inside eclipse
---
 .../idp/plugin/impl/FirstPartyIdPPlugin.java       | 12 +++++
 .../idp/installer/plugin/impl/PluginInstaller.java | 51 +++++++++++++++++++++-
 .../idp/installer/plugin/impl/PluginCLITest.java   | 28 +++++++-----
 3 files changed, 78 insertions(+), 13 deletions(-)

diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/FirstPartyIdPPlugin.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/FirstPartyIdPPlugin.java
index f9b961f4a..56eaef7f7 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/FirstPartyIdPPlugin.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/FirstPartyIdPPlugin.java
@@ -60,4 +60,16 @@ public class FirstPartyIdPPlugin extends PropertyDrivenIdPPlugin {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override
+    @Nonnull @Unmodifiable @NotLive public List<URL> getDefaultModuleInfoSources() throws PluginException {
+        try {
+            // The second location is a backup CNAME pointing into AWS S3 at present.
+            return CollectionSupport.listOf(
+                    new URL("https://shibboleth.net/downloads/identity-provider/plugins/modules.properties"),
+                    new URL("http://plugins.shibboleth.net/modules.properties"));
+        } catch (final MalformedURLException e) {
+            throw new PluginException(e);
+        }
+    }
 }
\ No newline at end of file
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 c8acf7795..82aa0803c 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
@@ -69,15 +69,16 @@ import net.shibboleth.idp.installer.impl.BuildWar;
 import net.shibboleth.idp.installer.plugin.impl.TrustStore.Signature;
 import net.shibboleth.idp.module.IdPModule;
 import net.shibboleth.idp.plugin.IdPPlugin;
+import net.shibboleth.profile.installablecomponent.InstallableComponentVersion;
 import net.shibboleth.profile.module.Module.ModuleResource;
 import net.shibboleth.profile.module.Module.ResourceResult;
-import net.shibboleth.profile.installablecomponent.InstallableComponentVersion;
 import net.shibboleth.profile.module.ModuleContext;
 import net.shibboleth.profile.module.ModuleException;
 import net.shibboleth.profile.plugin.Plugin.Package;
 import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.collection.Pair;
 import net.shibboleth.shared.component.AbstractInitializableComponent;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.Constraint;
@@ -483,11 +484,59 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
         for (final String moduleId: getDescription().getRequiredModules()) {
             if (!loadedModules.contains(moduleId)) {
                 LOG.warn("Required module {} is missing or not enabled ", moduleId);
+                final Pair<String, String> pluginInfo = getModulePluginInfo(moduleId);
+                if (pluginInfo != null) {
+                    LOG.warn("Module {} provided by plugin {} version {}", moduleId, pluginInfo.getFirst(), pluginInfo.getSecond());
+                }
                 throw new BuildException("One or more required modules are not enabled");
             }
         }
     }
 
+    /** If we have the information, get the Plugin Id and version which supplies the module id.
+     * @param moduleId The module ID
+     * @return a Pair of string the first being the plugin ID and the second its version
+     */
+    private Pair<String, String> getModulePluginInfo(final String moduleId) throws BuildException {
+        try {
+            final List<URL> sources = description.getModuleInfoSources();
+            Properties props = null;
+            for (final URL url : sources) {
+                LOG.debug("Loading info from {}", url);
+                if (url == null) {
+                    continue;
+                }
+                try {
+                    final HTTPResource httpResource = new HTTPResource(httpClient, url);
+                    final HttpClientSecurityContextHandler handler = new HttpClientSecurityContextHandler();
+                    handler.setHttpClientSecurityParameters(securityParams);
+                    handler.initialize();
+                    httpResource.setHttpClientContextHandler(handler);
+                    props = new Properties();
+                    props.load(httpResource.getInputStream());
+                    LOG.debug("Loaded {} properties", props.size());
+                    break;
+                } catch (final IOException e) {
+                    LOG.error("Could not open Module Resource at {} :", url, e);
+                    continue;
+                }
+            }
+            //
+            // We got properties or we didn't
+            //
+            if (props == null || props.isEmpty()) {
+                return null;
+            }
+            final String version = props.getProperty(moduleId + ".version");
+            final String plugin =  props.getProperty(moduleId + ".plugin");
+            LOG.debug("Looked up {}, found {}, {}", moduleId, version, plugin);
+            return new Pair<>(plugin, version);
+        } catch (final IOException | ComponentInitializationException  e) {
+            LOG.error("Could not lookup up infomationa about {}, continuing", moduleId, e);
+            return null;
+        }
+    }
+
     /** Re-enabled the listed modules iff then are implemented by the plugin we just installed.
      * @param loadedModules the modules to enable
      * @throws BuildException on errors finding or enabling the modules
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
index d42a6089a..5ffd47118 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
@@ -40,22 +40,26 @@ public class PluginCLITest extends BasePluginTest {
     private final static boolean RunInstallTests = false;
     
     private final String PLUGIN_DISTRO = "http://test.shibboleth.net/downloads/identity-provider/plugins/oidc-common/3.1.0/oidc-common-dist-3.1.0.tar.gz";
-    
-    private final String PLUGIN_ID = "net.shibboleth.oidc.common";
+
+    private final String PLUGIN_IDS[] = { "net.shibboleth.oidc.common", "net.shibboleth.idp.plugin.jettybase","net.shibboleth.idp.plugin.authn.oidc.rp"};
+
+    private final String PLUGIN_ID = PLUGIN_IDS[1];
 
     @BeforeSuite public void setUp() throws IOException
     {
         System.setProperty("idp.home",getIdpHome().toString());
-        final Path credentials = getIdpHome().resolve("credentials").resolve(PLUGIN_ID);
-        Files.createDirectories(credentials);
-        //
-        // Populate the new key store
-        //
-        final Path trustStorePath = credentials.resolve("truststore.asc");
-        final Resource from = new ClassPathResource("credentials/truststore.asc");
-        try (final InputStream in = from.getInputStream();
-             final OutputStream out = new ProgressReportingOutputStream(new FileOutputStream(trustStorePath.toFile(), true))) {
-            in.transferTo(out);
+        for (final String id :PLUGIN_IDS) {
+            final Path credentials = getIdpHome().resolve("credentials").resolve(id);
+            Files.createDirectories(credentials);
+            //
+            // Populate the new key store
+            //
+            final Path trustStorePath = credentials.resolve("truststore.asc");
+            final Resource from = new ClassPathResource("credentials/truststore.asc");
+            try (final InputStream in = from.getInputStream();
+                 final OutputStream out = new ProgressReportingOutputStream(new FileOutputStream(trustStorePath.toFile(), true))) {
+                in.transferTo(out);
+            }
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list