[java-identity-provider] branch main updated: IDP-1595 Prompt user to download externals

Rod Widdowson rdw at steadingsoftware.com
Mon Aug 24 15:14:26 UTC 2020


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

The following commit(s) were added to refs/heads/main by this push:
       new  a612e75c5 IDP-1595 Prompt user to download externals
a612e75c5 is described below

commit a612e75c5acd88b4b9aa26546ab5818212ff89f3
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Aug 24 15:53:20 2020 +0100

    IDP-1595 Prompt user to download externals
    
    https://issues.shibboleth.net/jira/browse/IDP-1595
    
    Again the deafult is "no".  Requires some API rejigging.
---
 .../idp/installer/plugin/PluginInstallerCLI.java   | 22 ++++++++++++++++++----
 .../idp/installer/plugin/impl/PluginInstaller.java |  6 +++---
 .../installer/plugin/impl/PluginInstallerTest.java |  8 ++++----
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginInstallerCLI.java
index f4b1c088f..8e7809229 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginInstallerCLI.java
@@ -45,6 +45,7 @@ import net.shibboleth.idp.plugin.PluginVersion;
 import net.shibboleth.idp.plugin.impl.PluginState;
 import net.shibboleth.idp.plugin.impl.PluginState.VersionInfo;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 /**
@@ -161,7 +162,8 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
     private void constructPluginInstaller() throws ComponentInitializationException {
         installer= new PluginInstaller();
         installer.setIdpHome(getIdpHome());
-        installer.setAcceptCert(new TrustStoreQuery());
+        installer.setAcceptCert(new InstallerQuery("Accept this Certificate"));
+        installer.setAcceptDownload(new InstallerQuery("Download from"));
         if (httpClient!= null) {
             installer.setHttpClient(httpClient);
         }
@@ -244,15 +246,27 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
     public static void main(@Nonnull final String[] args) {
         System.exit(runMain(args));
     }
-    
+
     /** Predicate to ask the user if they want to install the trust store provided. */
-    private class TrustStoreQuery implements Predicate<String> {
+    private static class InstallerQuery implements Predicate<String> {
+
+        /** What to say. */
+        @Nonnull
+        private final String promptText;
+
+        /**
+         * Constructor.
+         * @param text What to say before the prompt information
+         */
+        public InstallerQuery(@Nonnull final String text) {
+            promptText = Constraint.isNotNull(text, "Text should not be null");
+        }
 
         /** {@inheritDoc} */
         public boolean test(final String certString) {
             String result = null;
             while (result == null) {
-                System.console().printf("Accept this Certificate:\n%s [yN]", certString);
+                System.console().printf("%s:\n%s [yN] ", promptText, certString);
                 System.console().flush();
                 result  = StringSupport.trimOrNull(System.console().readLine());
             }
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 f42befe84..bc1b713a2 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
@@ -106,7 +106,7 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
     @Nonnull private Predicate<String> acceptCert = Predicates.alwaysFalse();
 
     /** The callback before we download a file. */
-    @Nonnull private Predicate<Pair<URL,Path>> acceptDownload = Predicates.alwaysFalse();
+    @Nonnull private Predicate<String> acceptDownload = Predicates.alwaysFalse();
     
     /** The actual distribution. */
     private Path distribution;
@@ -138,7 +138,7 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
     /** Set the acceptCert predicate.
      * @param what what to set.
      */
-    public void setAcceptDownload(@Nonnull final Predicate<Pair<URL,Path>> what) {
+    public void setAcceptDownload(@Nonnull final Predicate<String> what) {
         acceptDownload  = Constraint.isNotNull(what, "Accept Download Predicate should be non-null");
     }
 
@@ -222,7 +222,7 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
                     LOG.warn("{} exists, not copied", to);
                     continue;
                 }
-                if (!acceptDownload.test(new Pair<>(pair.getFirst(), to))) {
+                if (!acceptDownload.test(pair.getFirst().toExternalForm())) {
                     LOG.info("Did not download {} to {}", pair.getFirst(), to);
                     continue;
                 }
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
index 16d6a33e1..4f2281d21 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
@@ -38,7 +38,6 @@ import org.testng.annotations.Test;
 import net.shibboleth.idp.installer.plugin.BasePluginTest;
 import net.shibboleth.idp.plugin.AbstractPluginDescription;
 import net.shibboleth.idp.plugin.PluginDescription;
-import net.shibboleth.utilities.java.support.collection.Pair;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 
 @SuppressWarnings("javadoc")
@@ -53,9 +52,9 @@ public class PluginInstallerTest extends BasePluginTest {
         }
     };
 
-    private final Predicate<Pair<URL, Path>> loggingAcceptDownLoad = new  Predicate<>() {
-        public boolean test(Pair<URL, Path> what) {
-            log.debug("Accepting the download from {} to {}", what.getFirst(), what.getSecond());
+    private final Predicate<String> loggingAcceptDownLoad = new  Predicate<>() {
+        public boolean test(String what) {
+            log.debug("Accepting the download from {} ", what);
             return true;
         }
     };
@@ -86,6 +85,7 @@ public class PluginInstallerTest extends BasePluginTest {
             inst.setAcceptDownload(loggingAcceptDownLoad);
             inst.initialize();
             final URL where = new URL("https://build.shibboleth.net/nexus/service/local/repositories/releases/content/net/shibboleth/idp/plugin/scripting/idp-plugin-nashorn-dist/0.1.0/");
+            inst.setPluginId("net.shibboleth.idp.plugin.nashorn");
             inst.installPlugin(where,"idp-plugin-nashorn-dist-0.1.0.zip");
         }
     }

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


More information about the commits mailing list