[java-identity-provider] branch main updated: IDP-2046 Plugin URL resolver does not fall through to backup URLS correctly

Rod Widdowson rdw at steadingsoftware.com
Mon Dec 5 10:37:25 UTC 2022


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=cadfe36da8be05b9c3b0db056a985b316e34f2ce

The following commit(s) were added to refs/heads/main by this push:
     new cadfe36da IDP-2046 Plugin URL resolver does not fall through to backup URLS correctly
cadfe36da is described below

commit cadfe36da8be05b9c3b0db056a985b316e34f2ce
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Dec 5 10:35:16 2022 +0000

    IDP-2046 Plugin URL resolver does not fall through to backup URLS correctly
    
    https://shibboleth.atlassian.net/browse/IDP-2046
    
    Recast loops so that the try is inside the iteration, allowing us to look
    at the next URL if we get an exception (like some sort of funkly TLS issue)
---
 .../installer/plugin/impl/PluginInstallerCLI.java  | 26 ++++++-----
 .../idp/installer/plugin/impl/PluginState.java     | 52 +++++++++++-----------
 2 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
index 2323eb76d..3230a1dd6 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
@@ -422,31 +422,35 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
             } else {
                 urls = updateURLs;
             }
-            for (final URL url: urls) {
-                final Resource propertyResource;
+        } catch (final IOException e) {
+            log.error("Could not load update URLs", e);
+            return null;
+        }
+        for (final URL url: urls) {
+            final Resource propertyResource;
+            try {
                 if ("file".equals(url.getProtocol())) {
                     propertyResource = new FileSystemResource(url.getPath());
                 } else if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
-                    propertyResource = new HTTPResource(getHttpClient(), url);
+                        propertyResource = new HTTPResource(getHttpClient(), url);
                 } else {
                     log.error("Only file and http[s] URLs are allowed");
-                    return null;
+                    continue;
                 }
-
                 log.debug("Plugin Listing: Looking for update at {}", propertyResource.getDescription());
                 if (!propertyResource.exists()) {
                     log.info("{} could not be located", propertyResource.getDescription());
                     continue;
                 }
                 props.load(propertyResource.getInputStream());
-                break;
+                return props;
+            } catch (final IOException e) {
+                log.error("Could not open Update URL {} :", url, e);
+                continue;
             }
-
-        } catch (final IOException e) {
-            log.error("Could not load update URL", e);
-            return null;
         }
-        return props;
+        log.error("Could not locate any active update servers");
+        return null;
     }
 
     /** Given the pluginId find the best version and install.
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
index 51557ae37..6b8f2830f 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
@@ -131,38 +131,40 @@ public class PluginState extends AbstractInitializableComponent {
             }
             for (final URL url: urls) {
                 final Resource propertyResource;
-                if ("file".equals(url.getProtocol())) {
-                    propertyResource = new FileSystemResource(url.getPath());
-                } else if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
-                    propertyResource = new HTTPResource(httpClient, url);
-                } else {
-                    throw new ComponentInitializationException("Only file and http[s] URLs are allowed");
-                }
-
-                log.debug("Plugin {}: Looking for update at {}", plugin.getPluginId(),
-                        propertyResource.getDescription());
-                if (!propertyResource.exists()) {
-                    log.info("Plugin {}: {} could not be located", plugin.getPluginId(),
+                try {
+                    if ("file".equals(url.getProtocol())) {
+                        propertyResource = new FileSystemResource(url.getPath());
+                    } else if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
+                            propertyResource = new HTTPResource(httpClient, url);
+                    } else {
+                        log.error("Plugin {}: Only file and http[s] URLs are allowed: '{}'", plugin.getPluginId(), url);
+                        continue;
+                    }
+                    log.debug("Plugin {}: Looking for update at {}", plugin.getPluginId(),
                             propertyResource.getDescription());
-                    continue;
-                }
-                
-                if (populate(propertyResource)) {
-                    log.debug("Plugin {}: PluginState populated from {}",
-                            plugin.getPluginId(), propertyResource.getDescription());
-                    if (myPluginInfo.getAvailableVersions().get(myPluginVersion) == null) {
-                        log.error("Plugin {} : Could not find version {} in descriptions at {}",
-                                plugin.getPluginId(), myPluginVersion, propertyResource.getDescription());
+                    if (!propertyResource.exists()) {
+                        log.info("Plugin {}: {} could not be located", plugin.getPluginId(),
+                                propertyResource.getDescription());
+                        continue;
                     }
-                    return;
+                    if (populate(propertyResource)) {
+                        log.debug("Plugin {}: PluginState populated from {}",
+                                plugin.getPluginId(), propertyResource.getDescription());
+                        if (myPluginInfo.getAvailableVersions().get(myPluginVersion) == null) {
+                            log.error("Plugin {} : Could not find version {} in descriptions at {}",
+                                    plugin.getPluginId(), myPluginVersion, propertyResource.getDescription());
+                        }
+                        return;
+                    }
+                }
+                catch (final IOException e) {
+                    log.error("Could not open Update Resource for {} :", plugin.getPluginId(), e);
+                    continue;
                 }
             }
             log.error("Plugin {}: No available servers found.", plugin.getPluginId());
             throw new ComponentInitializationException("Could not locate information for " + plugin.getPluginId());
 
-        } catch (final IOException e) {
-            throw new ComponentInitializationException("Could not locate Update Resource for "
-                        + plugin.getPluginId(), e);
         } catch (final ComponentInitializationException e) {
             throw e;
         } catch (final Exception e) {

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


More information about the commits mailing list