[java-identity-provider] branch main updated: IDP-2073 Consider enabling the installer to download new versions

Rod Widdowson rdw at steadingsoftware.com
Thu Jun 8 12:34:34 UTC 2023


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=6c0a66402f5a4466708f5db39008ea18dd347e24

The following commit(s) were added to refs/heads/main by this push:
     new 6c0a66402 IDP-2073 Consider enabling the installer to download new versions
6c0a66402 is described below

commit 6c0a66402f5a4466708f5db39008ea18dd347e24
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 8 13:33:40 2023 +0100

    IDP-2073 Consider enabling the installer to download new versions
    
    https://shibboleth.atlassian.net/browse/IDP-2073
    
    Bug fixes to -fd, clean up help text
---
 .../idp/installer/impl/UpdateIdPArguments.java     | 38 +++++++++++++++-------
 .../idp/installer/impl/UpdateIdPCLI.java           | 15 +++++++--
 .../shibboleth/idp/installer/TestInstallerCLI.java | 12 ++++++-
 3 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPArguments.java
index 1e5819305..6758d5d6f 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPArguments.java
@@ -51,7 +51,7 @@ public class UpdateIdPArguments extends AbstractIdPHomeAwareCommandLineArguments
     private boolean list;
 
     /** Where to download. */
-    @Parameter(names= {"-d", "--dowloadDir"})
+    @Parameter(names= {"-d", "--downloadDir"})
     @Nullable private String downloadDir;
 
     /** Truststore to use for signing. */
@@ -59,7 +59,7 @@ public class UpdateIdPArguments extends AbstractIdPHomeAwareCommandLineArguments
     @Nullable private String truststore;
 
     /** Force download version. */
-    @Parameter(names= {"-fd", "--force-download"})
+    @Parameter(names= {"-fd", "--forceDownload"})
     @Nullable private String forceDownloadVersion;
  
     /** location to override the default update location. */
@@ -178,15 +178,29 @@ public class UpdateIdPArguments extends AbstractIdPHomeAwareCommandLineArguments
     public void validate() throws IllegalArgumentException {
         super.validate();
         
-        if (StringSupport.trimOrNull(pretendVersion) != null) {
-            fromVersion = new InstallableComponentVersion(pretendVersion);
-        } else {
-            final String currentVersion = Version.getVersion();
-            if (currentVersion == null) {
-                getLog().error("Could not determine current version.");
-                throw new IllegalArgumentException("Could not determine current version.");
+        try {
+            if (StringSupport.trimOrNull(pretendVersion) != null) {
+                fromVersion = new InstallableComponentVersion(pretendVersion);
+            } else {
+                final String currentVersion = Version.getVersion();
+                if (currentVersion == null) {
+                    getLog().error("Could not determine current version.");
+                    throw new IllegalArgumentException("Could not determine current version.");
+                }
+                fromVersion = new InstallableComponentVersion(currentVersion);
+            }
+
+            if (StringSupport.trimOrNull(forceDownloadVersion) != null) {
+                updateVersion = new InstallableComponentVersion(forceDownloadVersion);
+                if (downloadDir == null) {
+                    getLog().error("Must specify a downloadDir if forceDownload is specified.");
+                    throw new IllegalArgumentException("Must specify a downloadDir if forceDownload is specified.");
+                }
             }
-            fromVersion = new InstallableComponentVersion(currentVersion);
+
+        } catch (final NumberFormatException e) {
+            getLog().error("Error in version specifier");
+            throw new IllegalArgumentException("Error in version specifier", e);
         }
 
         if (list) {
@@ -222,8 +236,8 @@ public class UpdateIdPArguments extends AbstractIdPHomeAwareCommandLineArguments
         out.println();
         out.println("With no options displays the update status of the IdP");
         out.println();
-        out.println(String.format("  %-22s %s", "-d, --download <file>", "Download the distribution for an available update"));
-        out.println(String.format("  %-22s %s", "-fd, --force=download <file>", "Specify the version to be downloaded by -d"));
+        out.println(String.format("  %-22s %s", "-d, --downloadDir <directory>", "Download the distribution for an available update"));
+        out.println(String.format("  %-22s %s", "-fd, --force-download <file>", "Specify the version to be downloaded by -d"));
         out.println();
         out.println(String.format("  %-22s %s", "-l, --list", "list all available versions"));
         out.println();
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPCLI.java
index 1c3a5fd97..04ec8e049 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/UpdateIdPCLI.java
@@ -159,13 +159,20 @@ public class UpdateIdPCLI extends AbstractIdPHomeAwareCommandLine<UpdateIdPArgum
     private int checkUpdate(@Nonnull UpdateIdPArguments args, @Nonnull final InstallableComponentInfo info, boolean doDownload) {
         
         final InstallableComponentVersion from = args.getUpdateFromVersion();
-        final InstallableComponentVersion newIdPVersion =
-                InstallableComponentSupport.getBestVersion(from, from, info);
+        InstallableComponentVersion newIdPVersion = args.getUpdateToVersion();
+        boolean versionSpecified = newIdPVersion != null;
+        if (!versionSpecified) {
+            newIdPVersion = InstallableComponentSupport.getBestVersion(from, from, info);
+        }
         if (newIdPVersion == null) {
             getLogger().info("No Upgrade available from {}", from);
             return RC_OK;
         }
-        getLogger().info("Version {} can be upgraded to {}", from, newIdPVersion);
+        if (versionSpecified) {
+            getLogger().info("Download version {}", newIdPVersion);
+        } else {
+            getLogger().info("Version {} can be upgraded to {}", from, newIdPVersion);
+        }
         if (!doDownload) {
             return RC_OK;
         }
@@ -247,6 +254,8 @@ public class UpdateIdPCLI extends AbstractIdPHomeAwareCommandLine<UpdateIdPArgum
                 args.getDownloadLocation().resolve(fileName).toFile().deleteOnExit();
                 args.getDownloadLocation().resolve(fileName + ".asc").toFile().deleteOnExit();
             }
+        } else {
+            getLogger().info("Signature checked OK");
         }
         return result;
     }
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
index 7b8449d33..a122eec72 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/TestInstallerCLI.java
@@ -42,7 +42,7 @@ public class TestInstallerCLI {
                });
     }
 
-    @Test(enabled = true)
+    @Test(enabled = false)
     public void silentInstall() {
 
         IdPInstallerCLI.runMain(new String[] {
@@ -58,6 +58,16 @@ public class TestInstallerCLI {
                });
     }
 
+    @Test(enabled = false)
+    public void forceDownload() {
+
+        UpdateIdPCLI.runMain(new String[] {
+                "--pretendVersion","5.0.0",
+                "-d", "h:\\downloads",
+                "--home", "H:\\Downloads\\idp3",
+                "-fd", "4.3.0"});
+
+    }
 
     @Test(enabled = false)
     public void updateList430() {

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


More information about the commits mailing list