[java-identity-provider] 03/04: IDP-1854 Add a discovery option to the plugin command
Rod Widdowson
rdw at steadingsoftware.com
Sun Aug 29 15:08:33 UTC 2021
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=297e8b0a85ea359356be958aa7d059b31aba4e9a
commit 297e8b0a85ea359356be958aa7d059b31aba4e9a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Aug 29 15:41:44 2021 +0100
IDP-1854 Add a discovery option to the plugin command
https://shibboleth.atlassian.net/browse/IDP-1854
Phase 4 - add the -I <pluginId> Install from ID qualifier
---
.../installer/plugin/impl/PluginInstallerCLI.java | 43 +++++++++++++++++++---
.../idp/installer/plugin/impl/PluginCLITest.java | 4 ++
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
index 12cdf9d8d..2ded29e91 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
@@ -157,14 +157,13 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
installer.setPluginId(args.getPluginId());
}
if (args.isInstallId()) {
- //autoInstallPlugin();
- } else {
- installer.installPlugin(args.getInputURL(), args.getInputFileName(), !args.isNoCheck());
+ return autoPluginFromId(args.getPluginId(), !args.isNoCheck());
}
+ installer.installPlugin(args.getInputURL(), args.getInputFileName(), !args.isNoCheck());
break;
case UPDATE:
- doUpdate(args.getPluginId() , args.getUpdateVersion(), !args.isNoCheck());
+ doUpdate(args.getPluginId(), args.getUpdateVersion(), !args.isNoCheck());
break;
case UNINSTALL:
@@ -374,7 +373,10 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
final String key = (String)en.nextElement();
if (key.endsWith(".versions")) {
final String pluginId = key.substring(0, key.length()-9);
- plugins.put(pluginId, new PluginInfo(pluginId, props));
+ final PluginInfo info = new PluginInfo(pluginId, props);
+ if (info.isInfoComplete()) {
+ plugins.put(pluginId, info);
+ }
}
}
@@ -447,6 +449,37 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
return props;
}
+ /** Given the pluginId find the best version and install.
+ * If already installed whine
+ * @param pluginId what to install
+ * @param checkVersion are we checking the version.
+ * @return installation status
+ */
+ private int autoPluginFromId(final String pluginId, final boolean checkVersion) {
+ final IdPPlugin existing = installer.getInstalledPlugin(pluginId);
+ if (existing != null) {
+ log.error("Plugin {} is already installed");
+ return RC_INIT;
+ }
+ final Properties props = loadPluginInfo();
+ final PluginInfo info = new PluginInfo(pluginId, props);
+ if (!info.isInfoComplete()) {
+ log.error("Plugin {}: Information not found");
+ return RC_INIT;
+ }
+ final PluginVersion versionToInstall = getBestVersion(new PluginVersion(0,0,0), info);
+ if (versionToInstall == null) {
+ log.error("Plugin {}: No version available to install");
+ return RC_INIT;
+ }
+ installer.installPlugin(info.getUpdateURL(versionToInstall),
+ info.getUpdateBaseName(versionToInstall) + ".tar.gz",
+ checkVersion);
+ return RC_IO;
+ }
+
+
+
/** Find the best update version. Helper function for {@linkplain #doUpdate(String, PluginVersion, boolean)}.
* @param pluginVersion The Plugin version
* @param pluginInfo all about the plugin
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
index 969d0d8be..ff27426d5 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
@@ -72,6 +72,10 @@ public class PluginCLITest extends BasePluginTest {
assertEquals(PluginInstallerCLI.runMain(new String[] { "-L", } ), AbstractCommandLine.RC_OK);
}
+ @Test(enabled = true) public void testInstallById() throws IOException {
+ assertEquals(PluginInstallerCLI.runMain(new String[] { "-I", "net.shibboleth.idp.plugin.authn.totp"} ), AbstractCommandLine.RC_OK);
+ }
+
@Test(enabled = true,dependsOnMethods = {/*"testWeb"*/}) public void testListWithOverride() throws IOException {
ClassPathResource resource = new ClassPathResource("/net/shibboleth/idp/plugin/allPlugins.props");
String url = resource.getURL().toString();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list