[java-identity-provider] branch main updated: Add a test option for probing module enabled status.
Scott Cantor
cantor.2 at osu.edu
Fri Oct 9 18:48:24 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=b582bf03e16e6486c46c9222223317482276f3e3
The following commit(s) were added to refs/heads/main by this push:
new b582bf03e Add a test option for probing module enabled status.
b582bf03e is described below
commit b582bf03e16e6486c46c9222223317482276f3e3
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Oct 9 14:47:41 2020 -0400
Add a test option for probing module enabled status.
---
.../idp/module/impl/ModuleManagerArguments.java | 27 ++++++++++++++-----
.../idp/module/impl/ModuleManagerCLI.java | 31 +++++++++++++++++-----
2 files changed, 46 insertions(+), 12 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 2e18e33e5..acb2dfd3f 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
@@ -53,11 +53,15 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
@Parameter(names= {"-i", "--info"})
@Nullable @NonnullElements private List<String> infoModuleIds = new ArrayList<>();
- /** ID of module to enable. */
+ /** Detailed info about installed module(s). */
+ @Parameter(names= {"-t", "--test"})
+ @Nullable @NonnullElements private List<String> testModuleIds = new ArrayList<>();
+
+ /** ID of module(s) to enable. */
@Parameter(names= {"-e", "--enable"})
@Nullable @NonnullElements private List<String> enableModuleIds = new ArrayList<>();
- /** ID of module to enable. */
+ /** ID of module(s) to enable. */
@Parameter(names= {"-d", "--disable"})
@Nullable @NonnullElements private List<String> disableModuleIds = new ArrayList<>();
@@ -83,16 +87,25 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
}
/**
- * Gets the module IDs to report on.
+ * Gets the module ID(s) to report on.
*
* @return {@link #infoModuleIds}
*/
@Nullable @NonnullElements @NotLive @Unmodifiable public Collection<String> getInfoModuleIds() {
return List.copyOf(StringSupport.normalizeStringCollection(infoModuleIds));
}
-
+
+ /**
+ * Gets the module ID(s) to test.
+ *
+ * @return {@link #testModuleIds}
+ */
+ @Nullable @NonnullElements @NotLive @Unmodifiable public Collection<String> getTestModuleIds() {
+ return List.copyOf(StringSupport.normalizeStringCollection(testModuleIds));
+ }
+
/**
- * Gets the module IDs to enable.
+ * Gets the module ID(s) to enable.
*
* @return {@link #enableModuleIds}
*/
@@ -101,7 +114,7 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
}
/**
- * Gets the module IDs to disable.
+ * Gets the module ID(s) to disable.
*
* @return {@link #disableModuleIds}
*/
@@ -148,6 +161,8 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
"Brief Information on all installed modules"));
out.println(String.format(" %-22s %s", "-i, --info <id>[,<id>]",
"Full details on specific module(s)"));
+ out.println(String.format(" %-22s %s", "-t, --test <id>[,<id>]",
+ "Test specific module(s) for enablement"));
out.println(String.format(" %-22s %s", "-e, --enable <id>[,<id>]",
"Enable module(s)"));
out.println(String.format(" %-22s %s", "-u, --disable <id>[,<id>]",
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 d56d169c8..da46da1af 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
@@ -100,17 +100,16 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
moduleContext.setLanguageRanges(args.getLanguageRanges());
if (args.getList() || !args.getInfoModuleIds().isEmpty()) {
- doList(moduleContext, args);
- } else {
- doManage(moduleContext, args);
+ return doList(moduleContext, args);
}
+
+ return doManage(moduleContext, args);
} catch (final ModuleException e) {
System.out.println(e.getMessage());
System.out.println(ANSIColors.ANSI_RED + "[FAILED]" + ANSIColors.ANSI_RESET);
System.out.println();
return RC_INIT;
}
- return ret;
}
/**
@@ -118,14 +117,25 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
*
* @param moduleContext context
* @param args arguments
+ *
+ * @return return code
*/
- private void doList(@Nonnull final ModuleContext moduleContext, @Nonnull final ModuleManagerArguments args) {
+ private int doList(@Nonnull final ModuleContext moduleContext, @Nonnull final ModuleManagerArguments args) {
+
+ int ret = RC_OK;
final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
while (modules.hasNext()) {
try {
final IdPModule module = modules.next();
+
+ if (args.getTestModuleIds().contains(module.getId())) {
+ if (!module.isEnabled(moduleContext)) {
+ ret = RC_UNKNOWN;
+ }
+ }
+
if (args.getInfoModuleIds().contains(module.getId())) {
System.out.println();
System.out.println("Module: " + module.getId());
@@ -156,6 +166,8 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
System.out.println("ServiceConfigurationError: " + e.getMessage());
}
}
+
+ return ret;
}
/**
@@ -164,11 +176,14 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
* @param moduleContext context
* @param args arguments
*
+ * @return return code
+ *
* @throws ModuleException to report module errors
*/
- private void doManage(@Nonnull final ModuleContext moduleContext, @Nonnull final ModuleManagerArguments args)
+ private int doManage(@Nonnull final ModuleContext moduleContext, @Nonnull final ModuleManagerArguments args)
throws ModuleException {
+ int ret = RC_OK;
final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
while (modules.hasNext()) {
@@ -203,11 +218,15 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
} catch (final IOException e) {
getLogger().error("I/O Error", e);
+ ret = RC_IO;
}
} catch (final ServiceConfigurationError e) {
System.out.println("ServiceConfigurationError: " + e.getMessage());
+ ret = RC_UNKNOWN;
}
}
+
+ return ret;
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list