diff --git a/src/java/org/jivesoftware/resource/Default.java b/src/java/org/jivesoftware/resource/Default.java index a0f13d52..b72a749e 100644 --- a/src/java/org/jivesoftware/resource/Default.java +++ b/src/java/org/jivesoftware/resource/Default.java @@ -24,11 +24,14 @@ import org.jivesoftware.spark.util.log.Log; import javax.swing.ImageIcon; import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; +import java.util.StringTokenizer; public class Default { private static PropertyResourceBundle prb; @@ -143,6 +146,32 @@ public class Default { return null; } + /** + * Returns a Collection of Plugins on the Blacklist
+ * Containing the Name and also if specified the entrypoint-class + * @return Collection + */ + public static Collection getPluginBlacklist() { + String pluginlist = getString("PLUGIN_BLACKLIST").replace(" ", "") + .toLowerCase(); + StringTokenizer tokenizer = new StringTokenizer(pluginlist, ","); + ArrayList list = new ArrayList(); + + while (tokenizer.hasMoreTokens()) { + list.add(tokenizer.nextToken()); + } + + StringTokenizer clazztokenz = new StringTokenizer( + getString("PLUGIN_BLACKLIST_CLASS").replace(" ", ""), ","); + + while (clazztokenz.hasMoreTokens()) { + list.add(clazztokenz.nextToken()); + } + + return list; + + } + /** * Returns all Keys stored in the default.properties file * @return {@link Enumeration}<{@link String}> diff --git a/src/java/org/jivesoftware/resource/default.properties b/src/java/org/jivesoftware/resource/default.properties index 200a1970..c2a22711 100644 --- a/src/java/org/jivesoftware/resource/default.properties +++ b/src/java/org/jivesoftware/resource/default.properties @@ -121,6 +121,16 @@ INSTALL_PLUGINS_DISABLED = # Disable deleting of Plugins # set true if you want to disable deinstalling of Plugins DEINSTALL_PLUGINS_DISABLED = +# Put plugins here that you dont want enabled +# comma separated +# names of plugins can be found in the plugin.xml +# example: Fastpath,Jingle Client,Phone Client,Window Flashing Plugin +# default is empty +PLUGIN_BLACKLIST = +# Disable Plugins by entrypoint Class +# Comma seperated +# example org.jivesoftware.fastpath.FastpathPlugin +PLUGIN_BLACKLIST_CLASS = ################################################# diff --git a/src/java/org/jivesoftware/spark/PluginManager.java b/src/java/org/jivesoftware/spark/PluginManager.java index 94500de0..4c6fe8b5 100644 --- a/src/java/org/jivesoftware/spark/PluginManager.java +++ b/src/java/org/jivesoftware/spark/PluginManager.java @@ -49,6 +49,7 @@ import org.dom4j.Node; import org.dom4j.io.SAXReader; import org.jivesoftware.MainWindowListener; import org.jivesoftware.Spark; +import org.jivesoftware.resource.Default; import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane; import org.jivesoftware.spark.plugin.Plugin; import org.jivesoftware.spark.plugin.PluginClassLoader; @@ -78,6 +79,7 @@ public class PluginManager implements MainWindowListener { private Plugin pluginClass; private PluginClassLoader classLoader; + private Collection _blacklistPlugins; /** * Returns the singleton instance of PluginManager, @@ -117,6 +119,8 @@ public class PluginManager implements MainWindowListener { if (!PLUGINS_DIRECTORY.exists()) { PLUGINS_DIRECTORY.mkdirs(); } + + _blacklistPlugins = Default.getPluginBlacklist(); } private void movePlugins() { @@ -260,6 +264,7 @@ public class PluginManager implements MainWindowListener { * @return the new Plugin model for the Public Plugin. */ private Plugin loadPublicPlugin(File pluginDir) { + File pluginFile = new File(pluginDir, "plugin.xml"); SAXReader saxReader = new SAXReader(); Document pluginXML = null; @@ -284,6 +289,18 @@ public class PluginManager implements MainWindowListener { name = plugin1.selectSingleNode("name").getText(); clazz = plugin1.selectSingleNode("class").getText(); + + try { + String lower = name.replace(" ","").toLowerCase(); + // Dont load the plugin if its on the Blacklist + if(_blacklistPlugins.contains(lower) || _blacklistPlugins.contains(clazz)) + { + return null; + } + } catch (Exception e) { + // Whatever^^ + return null; + } // Check for minimum Spark version try {