[java-identity-provider] branch main updated: IDP-1683 Check for IdP Version match on install (with override)
Rod Widdowson
rdw at steadingsoftware.com
Sat Nov 21 15:11:03 UTC 2020
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=285b053042731ab8ca3f56d106226ace1a359b94
The following commit(s) were added to refs/heads/main by this push:
new 285b05304 IDP-1683 Check for IdP Version match on install (with override)
285b05304 is described below
commit 285b053042731ab8ca3f56d106226ace1a359b94
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Nov 21 15:09:16 2020 +0000
IDP-1683 Check for IdP Version match on install (with override)
https://issues.shibboleth.net/jira/browse/IDP-1683
---
.../idp/installer/plugin/impl/PluginInstaller.java | 28 ++++++++++++++++++----
.../plugin/impl/PluginInstallerArguments.java | 12 ++++++++++
.../installer/plugin/impl/PluginInstallerCLI.java | 16 ++++++++-----
.../installer/plugin/impl/PluginInstallerTest.java | 6 ++---
4 files changed, 49 insertions(+), 13 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index 3176d507e..6f20f744a 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -65,6 +65,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Predicates;
import net.shibboleth.ext.spring.resource.HTTPResource;
+import net.shibboleth.idp.Version;
import net.shibboleth.idp.installer.BuildWar;
import net.shibboleth.idp.installer.InstallerSupport;
import net.shibboleth.idp.installer.ProgressReportingOutputStream;
@@ -202,15 +203,17 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
}
/** Install the plugin from the provided URL. Involves downloading
- * the file and then doing a {@link #installPlugin(Path, String)}.
+ * the file and then doing a {@link #installPlugin(Path, String, boolean)}.
* @param baseURL where we get the files from
* @param fileName the name
+ * @param checkVersion do we want to check vs the IdP Version?
* @throws BuildException if badness is detected.
*/
public void installPlugin(@Nonnull final URL baseURL,
- @Nonnull @NotEmpty final String fileName) throws BuildException {
+ @Nonnull @NotEmpty final String fileName,
+ final boolean checkVersion) throws BuildException {
download(baseURL, fileName);
- installPlugin(downloadDirectory, fileName);
+ installPlugin(downloadDirectory, fileName, checkVersion);
}
/** Install the plugin from a local path.
@@ -219,10 +222,12 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
* <li>Install from the folder</li></ul>
* @param base the directory where the files are
* @param fileName the name
+ * @param checkVersion do we want to check vs the IdP Version?
* @throws BuildException if badness is detected.
*/
public void installPlugin(@Nonnull final Path base,
- @Nonnull @NotEmpty final String fileName) throws BuildException {
+ @Nonnull @NotEmpty final String fileName,
+ final boolean checkVersion) throws BuildException {
if (!Files.exists(base.resolve(fileName))) {
LOG.error("Could not find distribution {}", base.resolve(fileName));
throw new BuildException("Could not find distribution");
@@ -236,6 +241,21 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
setupPluginId();
checkSignature(base, fileName);
setupDescriptionFromDistribution();
+ if (checkVersion) {
+ final PluginState state = new PluginState(description);
+ try {
+ state.initialize();
+ } catch (final ComponentInitializationException e) {
+ throw new BuildException(e);
+ }
+ final PluginVersion pluginVersion = new PluginVersion(description);
+ final PluginVersion idpVersion = new PluginVersion(Version.getVersion());
+ if (!state.isSupportedWithIdPVersion(pluginVersion, idpVersion)) {
+ LOG.error("Plugin {} version {} is not supported with IdP Version {}",
+ pluginId, pluginVersion, idpVersion);
+ throw new BuildException("Version Mismatch");
+ }
+ }
LOG.info("Installing Plugin {} version {}.{}.{}", pluginId,
description.getMajorVersion(),description.getMinorVersion(), description.getPatchVersion());
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
index 537e6700a..704cebad1 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
@@ -55,6 +55,10 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
@Parameter(names= {"-l", "--list"})
@Nullable private boolean list;
+ /** Override version check. */
+ @Parameter(names= {"--noCheck"})
+ @Nullable private boolean noCheck;
+
/** Detailed info about installed plugins. */
@Parameter(names= {"-fl", "--full-list"})
@Nullable private boolean fullList;
@@ -188,6 +192,13 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
return list;
}
+ /** Are we checking the version or not?
+ * @return noCheck.
+ */
+ public boolean isNoCheck() {
+ return noCheck;
+ }
+
/** Are we doing an unattended install?
* @return {@link #list}
*/
@@ -319,6 +330,7 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
out.println(String.format(" %-22s %s", "-fl, --full-list", "Full details of all installed plugins"));
out.println(String.format(" %-22s %s", "-cl, --contents-list", "Details of what was installed"));
out.println(String.format(" %-22s %s", "-i, --input <what>", "Install (file name or web address)"));
+ out.println(String.format(" %-22s %s", "--noCheck", "Do not check the version"));
out.println(String.format(" %-22s %s", "-u, --update <PluginId>", "update"));
out.println(String.format(" %-22s %s", "-fu, --force-update <version>",
"force version to update to (requires -u)"));
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 4be24fa06..33a1ba090 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
@@ -125,18 +125,18 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
if (args.getPluginId() != null) {
installer.setPluginId(args.getPluginId());
}
- installer.installPlugin(args.getInputDirectory(), args.getInputFileName());
+ installer.installPlugin(args.getInputDirectory(), args.getInputFileName(), !args.isNoCheck());
break;
case INSTALLREMOTE:
if (args.getPluginId() != null) {
installer.setPluginId(args.getPluginId());
}
- installer.installPlugin(args.getInputURL(), args.getInputFileName());
+ installer.installPlugin(args.getInputURL(), args.getInputFileName(), !args.isNoCheck());
break;
case UPDATE:
- doUpdate(args.getPluginId() , args.getUpdateVersion());
+ doUpdate(args.getPluginId() , args.getUpdateVersion(), !args.isNoCheck());
break;
case UNINSTALL:
@@ -329,7 +329,7 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
}
- /** Find the best update version. Helper function for {@linkplain #doUpdate(String, PluginVersion)}.
+ /** Find the best update version. Helper function for {@linkplain #doUpdate(String, PluginVersion, boolean)}.
* @param plugin The Plugin
* @param state all about the plugin
* @return the best version (or null)
@@ -379,8 +379,11 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
/** Update the plugin.
* @param pluginId the pluginId or null.
* @param pluginVersion (optionally) the version to update to.
+ * @param checkVersion are we checking the version.
*/
- private void doUpdate(@Nonnull final String pluginId, @Nullable final PluginVersion pluginVersion) {
+ private void doUpdate(@Nonnull final String pluginId,
+ @Nullable final PluginVersion pluginVersion,
+ final boolean checkVersion) {
final IdPPlugin plugin = installer.getInstalledPlugin(pluginId);
if (plugin == null) {
log.error("Plugin {} was not installed", pluginId);
@@ -415,7 +418,8 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
}
// just use the tgz version - its an update so it should be jar files only
installer.installPlugin(state.getUpdateURL(installVersion),
- state.getUpdateBaseName(installVersion) + ".tar.gz");
+ state.getUpdateBaseName(installVersion) + ".tar.gz",
+ checkVersion);
}
/** Shim for CLI entry point: Allows the code to be run from a test.
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
index 919de1ec6..394dfd122 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
@@ -95,7 +95,7 @@ public class PluginInstallerTest extends BasePluginTest {
inst.initialize();
final URL where = new URL("https://build.shibboleth.net/nexus/service/local/repositories/releases/content/net/shibboleth/idp/plugin/scripting/idp-plugin-nashorn-dist/0.1.0/");
inst.setPluginId("net.shibboleth.idp.plugin.nashorn");
- inst.installPlugin(where,"idp-plugin-nashorn-dist-0.1.0.zip");
+ inst.installPlugin(where,"idp-plugin-nashorn-dist-0.1.0.zip", false);
}
}
@@ -106,7 +106,7 @@ public class PluginInstallerTest extends BasePluginTest {
inst.setAcceptDownload(loggingAcceptDownLoad);
inst.initialize();
final Path dir = Path.of("H:\\Perforce\\Juno\\New\\plugins\\java-idp-plugin-scripting\\rhino-dist\\target");
- inst.installPlugin(dir,"shibboleth-idp-plugin-rhino-0.1.0-SNAPSHOT.zip");
+ inst.installPlugin(dir,"shibboleth-idp-plugin-rhino-0.1.4-SNAPSHOT.zip", true);
}
}
@@ -119,7 +119,7 @@ public class PluginInstallerTest extends BasePluginTest {
inst.setAcceptDownload(loggingAcceptDownLoad);
inst.initialize();
final URL where = new URL("https://build.shibboleth.net/nexus/service/local/repositories/releases/content/net/shibboleth/idp/plugin/scripting/idp-plugin-rhino-dist/0.1.0/");
- inst.installPlugin(where,"idp-plugin-rhino-dist-0.1.0.zip");
+ inst.installPlugin(where,"idp-plugin-rhino-dist-0.1.0.zip", true);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list