private PluginOperationResult executeInstallFromApiHost(String pluginId) throws Exception { checkPluginNotInstalled(pluginId); PluginInfo pluginInfo = getRemotePluginInfo(pluginId); if (pluginInfo == null) { throw new Exception("Plugin with ID '" + pluginId + "' not found"); } checkPluginCompatibility(pluginInfo); eventBus.post(new PluginInstallExternalEvent(pluginInfo.getDownloadUrl())); File tempPluginJarFile = downloadPluginJar(pluginInfo.getDownloadUrl()); String expectedChecksum = pluginInfo.getSha256sum(); String actualChecksum = calculateChecksum(tempPluginJarFile); if (expectedChecksum == null || !expectedChecksum.equals(actualChecksum)) { throw new Exception("Checksum mismatch. Expected: " + expectedChecksum + ", but was: " + actualChecksum); } logger.log(Level.INFO, "Plugin JAR checksum verified: " + actualChecksum); File targetPluginJarFile = installPlugin(tempPluginJarFile, pluginInfo); result.setSourcePluginPath(pluginInfo.getDownloadUrl()); result.setTargetPluginPath(targetPluginJarFile.getAbsolutePath()); result.setAffectedPluginInfo(pluginInfo); result.setResultCode(PluginResultCode.OK); return result; }
private PluginOperationResult executeInstallFromUrl(String downloadJarUrl) throws Exception { eventBus.post(new PluginInstallExternalEvent(downloadJarUrl)); File tempPluginJarFile = downloadPluginJar(downloadJarUrl); PluginInfo pluginInfo = readPluginInfoFromJar(tempPluginJarFile); checkPluginNotInstalled(pluginInfo.getPluginId()); checkPluginCompatibility(pluginInfo); File targetPluginJarFile = installPlugin(tempPluginJarFile, pluginInfo); result.setSourcePluginPath(downloadJarUrl); result.setTargetPluginPath(targetPluginJarFile.getPath()); result.setAffectedPluginInfo(pluginInfo); result.setResultCode(PluginResultCode.OK); return result; }