[java-identity-provider] branch main updated: CLI adjustments.

Scott Cantor cantor.2 at osu.edu
Wed Sep 16 18:46:00 UTC 2020


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

scantor 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=4f14a944306458c7fb4664a3eafabbc9187b718c

The following commit(s) were added to refs/heads/main by this push:
       new  4f14a9443 CLI adjustments.
4f14a9443 is described below

commit 4f14a944306458c7fb4664a3eafabbc9187b718c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Sep 16 14:45:51 2020 -0400

    CLI adjustments.
---
 .../idp/module/impl/ModuleManagerArguments.java    | 38 ++++++++++++----------
 .../idp/module/impl/ModuleManagerCLI.java          | 14 ++++----
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
index d104da316..2e18e33e5 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
@@ -35,6 +35,7 @@ import net.shibboleth.idp.module.IdPModule;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
 import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 /**
  * Arguments for {@link IdPModule} management CLI.
@@ -48,9 +49,9 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
     @Parameter(names= {"-l", "--list"})
     @Nullable private boolean list;
 
-    /** Detailed info about installed modules. */
-    @Parameter(names= {"-al", "--full-list"})
-    @Nullable private boolean fullList;
+    /** Detailed info about an installed module. */
+    @Parameter(names= {"-i", "--info"})
+    @Nullable @NonnullElements private List<String> infoModuleIds = new ArrayList<>();
 
     /** ID of module to enable. */
     @Parameter(names= {"-e", "--enable"})
@@ -82,12 +83,12 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
     }
 
     /**
-     * Are we doing a full list?
+     * Gets the module IDs to report on.
      * 
-     * @return {@link #fullList}
+     * @return {@link #infoModuleIds}
      */
-    public boolean getFullList() {
-        return fullList;
+    @Nullable @NonnullElements @NotLive @Unmodifiable public Collection<String> getInfoModuleIds() {
+        return List.copyOf(StringSupport.normalizeStringCollection(infoModuleIds));
     }
     
     /**
@@ -96,7 +97,7 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
      * @return {@link #enableModuleIds}
      */
     @Nullable @NonnullElements @NotLive @Unmodifiable public Collection<String> getEnableModuleIds() {
-        return List.copyOf(enableModuleIds);
+        return List.copyOf(StringSupport.normalizeStringCollection(enableModuleIds));
     }
     
     /**
@@ -105,7 +106,7 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
      * @return {@link #disableModuleIds}
      */
     @Nullable @NonnullElements @NotLive @Unmodifiable public Collection<String> getDisableModuleIds() {
-        return List.copyOf(disableModuleIds);
+        return List.copyOf(StringSupport.normalizeStringCollection(disableModuleIds));
     }
 
     /**
@@ -122,13 +123,13 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
     public void validate() throws IllegalArgumentException {
         super.validate();
 
-        if (enableModuleIds.isEmpty() && disableModuleIds.isEmpty()) {
-            if (!list && !fullList) {
+        if (getEnableModuleIds().isEmpty() && getDisableModuleIds().isEmpty()) {
+            if (getInfoModuleIds().isEmpty()) {
                 list = true;
             }
-        } else if (list || fullList) {
-            getLog().error("Cannot list and enable/disable in the same operation");
-            throw new IllegalArgumentException("Cannot list and enable/disable in the same operation.");
+        } else if (list || !getInfoModuleIds().isEmpty()) {
+            getLog().error("Cannot query and enable/disable in the same operation");
+            throw new IllegalArgumentException("Cannot query and enable/disable in the same operation.");
         }
     }
 
@@ -145,14 +146,15 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
         out.println();
         out.println(String.format("  %-22s %s", "-l, --list",
                 "Brief Information on all installed modules"));
-        out.println(String.format("  %-22s %s", "-al, --full-list",
-                "Full details on all installed modules"));
-        out.println(String.format("  %-22s %s", "-e, --enable <id>",
+        out.println(String.format("  %-22s %s", "-i, --info <id>[,<id>]",
+                "Full details on specific module(s)"));
+        out.println(String.format("  %-22s %s", "-e, --enable <id>[,<id>]",
                 "Enable module(s)"));
-        out.println(String.format("  %-22s %s", "-u, --disable <id>",
+        out.println(String.format("  %-22s %s", "-u, --disable <id>[,<id>]",
                 "Disable module(s)"));
         out.println(String.format("  %-22s %s", "-f, --clean",
                 "Clean disabled files instead of preserving them"));
         out.println();
     }
+
 }
\ No newline at end of file
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
index 0714eb3ac..bded70ffe 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
@@ -96,8 +96,8 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
             moduleContext.setHttpClient(getHttpClient());
             moduleContext.setHttpClientSecurityParameters(getHttpClientSecurityParameters());
             
-            if (args.getList() || args.getFullList()) {
-                doList(moduleContext, args.getFullList());
+            if (args.getList() || !args.getInfoModuleIds().isEmpty()) {
+                doList(moduleContext, args);
             } else {
                 doManage(moduleContext, args);
             }
@@ -110,15 +110,15 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
     }
 
     /**
-     * List all modules.
+     * List/report on modules.
      * 
      * @param moduleContext context
-     * @param full whether to do a long list
+     * @param args arguments
      */
-    private void doList(@Nonnull final ModuleContext moduleContext, final boolean full) {
+    private void doList(@Nonnull final ModuleContext moduleContext, @Nonnull final ModuleManagerArguments args) {
         
         for (final IdPModule module : ServiceLoader.load(IdPModule.class)) {
-            if (full) {
+            if (args.getInfoModuleIds().contains(module.getId())) {
                 System.out.println();
                 System.out.println("Module: " + module.getId());
                 System.out.println("\tName: " + module.getName());
@@ -135,7 +135,7 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
                             r.getDestination());
                 });
                 System.out.println();
-            } else {
+            } else if (args.getInfoModuleIds().isEmpty()) {
                 if (module.isEnabled(moduleContext)) {
                     System.out.println("Module: " + module.getId() +
                             ANSIColors.ANSI_GREEN + " [ENABLED]" + ANSIColors.ANSI_RESET);

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


More information about the commits mailing list