Commit f5ae89d4 authored by Richard Midwinter's avatar Richard Midwinter Committed by Guus der Kinderen

OF-1020: Admin Console Remote File Inclusion

parent 0c4f5865
...@@ -81,7 +81,7 @@ public class UpdateManager extends BasicModule { ...@@ -81,7 +81,7 @@ public class UpdateManager extends BasicModule {
/** /**
* URL of the servlet (JSP) that provides the "check for update" service. * URL of the servlet (JSP) that provides the "check for update" service.
*/ */
private static String updateServiceURL = "http://www.igniterealtime.org/projects/openfire/versions.jsp"; private static String updateServiceURL = "https://www.igniterealtime.org/projects/openfire/versions.jsp";
/** /**
* Information about the available server update. * Information about the available server update.
...@@ -275,34 +275,57 @@ public class UpdateManager extends BasicModule { ...@@ -275,34 +275,57 @@ public class UpdateManager extends BasicModule {
hc.setProxy(getProxyHost(), getProxyPort()); hc.setProxy(getProxyHost(), getProxyPort());
httpClient.setHostConfiguration(hc); httpClient.setHostConfiguration(hc);
} }
GetMethod getMethod = new GetMethod(url);
//execute the method if (isKnownPlugin(url)) {
try { GetMethod getMethod = new GetMethod(url);
int statusCode = httpClient.executeMethod(getMethod); //execute the method
if (statusCode == 200) { try {
//get the resonse as an InputStream int statusCode = httpClient.executeMethod(getMethod);
try (InputStream in = getMethod.getResponseBodyAsStream()) { if (statusCode == 200) {
String pluginFilename = url.substring(url.lastIndexOf("/") + 1); //get the resonse as an InputStream
installed = XMPPServer.getInstance().getPluginManager() try (InputStream in = getMethod.getResponseBodyAsStream()) {
.installPlugin(in, pluginFilename); String pluginFilename = url.substring(url.lastIndexOf("/") + 1);
} installed = XMPPServer.getInstance().getPluginManager()
if (installed) { .installPlugin(in, pluginFilename);
// Remove the plugin from the list of plugins to update }
for (Update update : pluginUpdates) { if (installed) {
if (update.getURL().equals(url)) { // Remove the plugin from the list of plugins to update
update.setDownloaded(true); for (Update update : pluginUpdates) {
} if (update.getURL().equals(url)) {
} update.setDownloaded(true);
// Save response in a file for later retrieval }
saveLatestServerInfo(); }
} // Save response in a file for later retrieval
} saveLatestServerInfo();
} }
catch (IOException e) { }
Log.warn("Error downloading new plugin version", e); }
catch (IOException e) {
Log.warn("Error downloading new plugin version", e);
}
} else {
Log.error("Invalid plugin download URL: " +url);
} }
return installed; return installed;
} }
/**
* Check if the plugin URL is in the known list of available plugins.
*
* i.e. that it's an approved download source.
*
* @param url The URL of the plugin to download.
* @return true if the URL is in the list. Otherwise false.
*/
private boolean isKnownPlugin(String url) {
for (String pluginName : availablePlugins.keySet()) {
if (availablePlugins.get(pluginName).getDownloadURL().toString().equals(url)) {
return true;
}
}
return false;
}
/** /**
* Returns true if the plugin downloaded from the specified URL has been downloaded. Plugins * Returns true if the plugin downloaded from the specified URL has been downloaded. Plugins
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment