[java-identity-provider] 02/02: IDP-2125 Add new Command line qualifiers for common usage

Rod Widdowson rdw at steadingsoftware.com
Thu Jun 1 15:43:06 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=31735619488dfc023000f4f0e6f0eb57c80c0e80

commit 31735619488dfc023000f4f0e6f0eb57c80c0e80
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 1 16:17:55 2023 +0100

    IDP-2125 Add new Command line qualifiers for common usage
    
    https://shibboleth.atlassian.net/browse/IDP-2125
---
 .../idp/installer/impl/IdPInstallerArguments.java  | 57 +++++++++++++++++++++-
 .../idp/installer/impl/IdPInstallerCLI.java        | 28 +++++++----
 .../shibboleth/idp/installer/TestInstallerCLI.java | 22 +++++++++
 3 files changed, 97 insertions(+), 10 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java
index 2f4fb955e..e89c2d94d 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerArguments.java
@@ -51,6 +51,26 @@ public class IdPInstallerArguments extends AbstractCommandLineArguments {
     @Parameter(names= {"--noPrompt"})
     private boolean noPrompt;
 
+    /** DNS name of the IdP. */
+    @Parameter(names= {"-h", "--hostName"})
+    private String hostName;
+
+    /** Scope to assert. */
+    @Parameter(names= {"--scope"})
+    private String scope;
+
+    /** EntityID to install. */
+    @Parameter(names= {"-e", "--entityID"})
+    private String entityID;
+
+    /** Password for the keystore we will generate. */
+    @Parameter(names= {"-kp", "--keystorePassword"})
+    private String keystorePassword;
+
+    /** Password for the sealer we will generate. */
+    @Parameter(names= {"-sp", "--sealerPassword"})
+    private String sealerPassword;
+
     /** Import Property File. */
     @Parameter(names= {"--propertyFile"})
     private String propertyFile;
@@ -102,7 +122,42 @@ public class IdPInstallerArguments extends AbstractCommandLineArguments {
     @Nullable public String getPropertyFile() {
         return propertyFile;
     }
-    
+
+    /** Return the DNS name for the IdP
+     * @return Returns the DNS name.
+     */
+    @Nullable public String getHostName() {
+        return hostName;
+    }
+
+    /** Return the scope to assert.
+     * @return Returns the scope.
+     */
+    public String getScope() {
+        return scope;
+    }
+
+    /** The entityID to create.
+     * @return Returns the entityID.
+     */
+    public String getEntityID() {
+        return entityID;
+    }
+
+    /** The key store password.
+     * @return Returns the keystorePassword.
+     */
+    public String getKeystorePassword() {
+        return keystorePassword;
+    }
+
+    /** The sealer password.
+     * @return Returns the sealerPassword.
+     */
+    public String getSealerPassword() {
+        return sealerPassword;
+    }
+
     /**
      * Get bean name for the {@link org.apache.hc.client5.http.classic.HttpClient} (if specified).
      *
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
index bfcb4da7a..737213080 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/IdPInstallerCLI.java
@@ -121,15 +121,13 @@ public class IdPInstallerCLI extends AbstractCommandLine<IdPInstallerArguments>
             System.setProperty(InstallerProperties.NO_PROMPT, "true");
         }
 
-        final String propFile = args.getPropertyFile();
-        if (propFile!=null) {
-            System.setProperty(InstallerProperties.PROPERTY_SOURCE_FILE, propFile);
-        }
-
-        final String target = args.getTargetDirectory();
-        if (target!=null) {
-            System.setProperty(InstallerProperties.TARGET_DIR, target);
-        }
+        setIfNotNull(args.getPropertyFile(), InstallerProperties.PROPERTY_SOURCE_FILE);
+        setIfNotNull(args.getTargetDirectory(), InstallerProperties.TARGET_DIR);
+        setIfNotNull(args.getHostName(), InstallerProperties.HOST_NAME);
+        setIfNotNull(args.getScope(), InstallerProperties.SCOPE);
+        setIfNotNull(args.getEntityID(), InstallerProperties.ENTITY_ID);
+        setIfNotNull(args.getKeystorePassword(), InstallerProperties.KEY_STORE_PASSWORD);
+        setIfNotNull(args.getSealerPassword(), InstallerProperties.SEALER_PASSWORD);
 
         try {
             final InstallerProperties ip = new InstallerProperties(source);
@@ -156,6 +154,18 @@ public class IdPInstallerCLI extends AbstractCommandLine<IdPInstallerArguments>
         return RC_OK;
     }
     
+    /** Helper for translating arguments to properties.  Look at the value and if its nonnul
+     * set the associate property.
+     * @param propertyFile
+     * @param propertySourceFile
+     */
+    private void setIfNotNull(@Nullable String value, @Nonnull String propertyName) {
+        if (value == null) {
+            return;
+        }
+        System.setProperty(propertyName, value);
+    }
+
     /** Shim for CLI entry point: Allows the code to be run from a test.
     *
     * @return one of the predefines {@link AbstractCommandLine#RC_INIT},
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 9986cae9c..d441fec9d 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,6 +42,28 @@ public class TestInstallerCLI {
                 "-hc", "shibboleth.InternalHttpClient"
                });
     }
+
+    @Test(enabled = false)
+    public void silentInstall() {
+
+        System.setProperty(InstallerProperties.KEY_STORE_PASSWORD, "p1");
+        System.setProperty(InstallerProperties.SEALER_PASSWORD, "p1");
+        System.setProperty(InstallerProperties.HOST_NAME, "machine.org.uk");
+ //       System.setProperty(InstallerProperties.TARGET_DIR,  "h:\\downloads\\idp");
+//        System.setProperty(InstallerProperties.SEALER_KEYSIZE, "256");
+        IdPInstallerCLI.runMain(new String[] {
+                "-ks", "p1",
+                "--sealerPassword", "p1",
+                "-e", "https://test.example.org/id",
+                "-h", "machine.org",
+                "--scope", "machine.org",
+                "-t", "h:\\downloads\\idp",
+                "-s", "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT",
+                "-hc", "shibboleth.InternalHttpClient"
+               });
+    }
+
+
 /*
     @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