Class AddOnLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class AddOnLoader
    extends java.net.URLClassLoader
    This class is heavily based on the original Paros class org.parosproxy.paros.common.DynamicLoader However its been restructured and enhanced to support multiple directories or versioned ZAP addons. The constructor takes an array of directories. All of the generic jars in the directories are loaded. Only the latest ZAP addons are loaded, so if the following addons are found: zap-ext-test-alpha-1.zap zap-ext-test-beta-2.zap zap-ext-test-alpha-3.zap then only the latest one (zap-ext-test-alpha-3.zap) will be loaded - this is entirely based on the version number. The status (alpha/beta/release) is for informational purposes only.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ADDONS_BLOCK_LIST  
    • Constructor Summary

      Constructors 
      Constructor Description
      AddOnLoader​(java.io.File[] dirs)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addAddon​(AddOn ao)  
      java.util.List<AbstractPlugin> getActiveScanRules()
      Gets the active scan rules of all the loaded add-ons.
      AddOnCollection getAddOnCollection()  
      protected java.lang.Object getClassLoadingLock​(java.lang.String className)  
      java.util.List<Extension> getExtensions()
      Returns all the Extensions of all the installed add-ons.
      java.util.List<Extension> getExtensions​(AddOn addOn)
      Returns all Extensions of the given addOn.
      java.util.List<java.lang.String> getIdsAddOnsWithRunningIssuesSinceLastRun()
      Returns a list with the IDs of add-ons that have running issues since last run, either Java version was changed, or add-on dependencies are no longer met for the add-on or one of its extensions.
      <T> java.util.List<T> getImplementors​(java.lang.String packageName, java.lang.Class<T> classType)
      Deprecated.
      (2.8.0) The use of this method is discouraged (specially during ZAP startup, as it's delayed), it's preferable to provide means to register/declare the required classes instead of searching "everywhere".
      <T> java.util.List<T> getImplementors​(AddOn ao, java.lang.String packageName, java.lang.Class<T> classType)
      Deprecated.
      (2.8.0) The use of this method is discouraged (specially during ZAP startup, as it's delayed), it's preferable to provide means to register/declare the required classes instead of searching "everywhere".
      java.util.List<PluginPassiveScanner> getPassiveScanRules()
      Gets the passive scan rules of all the loaded add-ons.
      java.net.URL getResource​(java.lang.String name)  
      java.lang.Class<?> loadClass​(java.lang.String name)  
      boolean removeAddOn​(AddOn ao, boolean upgrading, AddOnUninstallationProgressCallback progressCallback)  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ADDONS_BLOCK_LIST

        public static final java.lang.String ADDONS_BLOCK_LIST
        See Also:
        Constant Field Values
    • Constructor Detail

      • AddOnLoader

        public AddOnLoader​(java.io.File[] dirs)
    • Method Detail

      • getIdsAddOnsWithRunningIssuesSinceLastRun

        public java.util.List<java.lang.String> getIdsAddOnsWithRunningIssuesSinceLastRun()
        Returns a list with the IDs of add-ons that have running issues since last run, either Java version was changed, or add-on dependencies are no longer met for the add-on or one of its extensions.
        Returns:
        a list with the add-ons that are not longer runnable
        Since:
        2.4.0
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Overrides:
        loadClass in class java.lang.ClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • getClassLoadingLock

        protected java.lang.Object getClassLoadingLock​(java.lang.String className)
        Overrides:
        getClassLoadingLock in class java.lang.ClassLoader
      • getResource

        public java.net.URL getResource​(java.lang.String name)
        Overrides:
        getResource in class java.lang.ClassLoader
      • addAddon

        public void addAddon​(AddOn ao)
      • getExtensions

        public java.util.List<Extension> getExtensions()
        Returns all the Extensions of all the installed add-ons.

        The discovery of Extensions is done by resorting to the manifest file bundled in the add-ons.

        Extensions with unfulfilled dependencies are not be returned.

        Returns:
        a list containing all Extensions of all installed add-ons
        Since:
        2.4.0
        See Also:
        Extension, getExtensions(AddOn)
      • getExtensions

        public java.util.List<Extension> getExtensions​(AddOn addOn)
        Returns all Extensions of the given addOn.

        The discovery of Extensions is done by resorting to manifest file bundled in the add-on.

        Extensions with unfulfilled dependencies are not be returned.

        Note: If the add-on is not installed the method returns an empty list.

        Parameters:
        addOn - the add-on whose extensions will be returned
        Returns:
        a list containing the Extensions of the given addOn
        Since:
        2.4.0
        See Also:
        Extension, getExtensions()
      • getActiveScanRules

        public java.util.List<AbstractPlugin> getActiveScanRules()
        Gets the active scan rules of all the loaded add-ons.

        The discovery of active scan rules is done by resorting to manifest file bundled in the add-ons.

        Returns:
        an unmodifiable List with all the active scan rules, never null
        Since:
        2.4.0
        See Also:
        AbstractPlugin
      • getPassiveScanRules

        public java.util.List<PluginPassiveScanner> getPassiveScanRules()
        Gets the passive scan rules of all the loaded add-ons.

        The discovery of passive scan rules is done by resorting to manifest file bundled in the add-ons.

        Returns:
        an unmodifiable List with all the passive scan rules, never null
        Since:
        2.4.0
        See Also:
        PluginPassiveScanner
      • getImplementors

        @Deprecated
        public <T> java.util.List<T> getImplementors​(java.lang.String packageName,
                                                     java.lang.Class<T> classType)
        Deprecated.
        (2.8.0) The use of this method is discouraged (specially during ZAP startup, as it's delayed), it's preferable to provide means to register/declare the required classes instead of searching "everywhere".
        Gets a list of classes that implement the given type in the given package.

        It searches in the dependencies, add-ons, and the ZAP JAR.

        Parameters:
        packageName - the name of the package that the classes must be in.
        classType - the type of the classes.
        Returns:
        a list with the classes that implement the given type, never null.
      • getImplementors

        @Deprecated
        public <T> java.util.List<T> getImplementors​(AddOn ao,
                                                     java.lang.String packageName,
                                                     java.lang.Class<T> classType)
        Deprecated.
        (2.8.0) The use of this method is discouraged (specially during ZAP startup, as it's delayed), it's preferable to provide means to register/declare the required classes instead of searching "everywhere".
        Gets a list of classes that implement the given type in the given package.

        It searches in the given add-on, if not null, otherwise it searches in the dependencies, add-ons, and the ZAP JAR.

        Parameters:
        ao - the add-on to search in, might be null.
        packageName - the name of the package that the classes must be in.
        classType - the type of the classes.
        Returns:
        a list with the classes that implement the given type, never null.