use of org.parosproxy.paros.extension.Extension in project zaproxy by zaproxy.
the class OptionsExtensionPanel method initParam.
@Override
public void initParam(Object obj) {
OptionsParam optionsParam = (OptionsParam) obj;
ExtensionParam extParam = optionsParam.getExtensionParam();
List<Extension> exts = extensionModel.getExtensions();
for (Extension ext : exts) {
ext.setEnabled(extParam.isExtensionEnabled(ext.getName()));
}
extensionModel.fireTableRowsUpdated(0, extensionModel.getRowCount());
}
use of org.parosproxy.paros.extension.Extension in project zaproxy by zaproxy.
the class AddOn method isExtensionLoaded.
/**
* Tells whether or not the extension with the given {@code classname} is loaded.
*
* @param classname the classname of the extension
* @return {@code true} if the extension is loaded, {@code false} otherwise
* @since 2.4.0
*/
public boolean isExtensionLoaded(String classname) {
List<Extension> allExtensions = new ArrayList<>(getLoadedExtensions().size() + getLoadedExtensionsWithDeps().size());
allExtensions.addAll(getLoadedExtensions());
allExtensions.addAll(getLoadedExtensionsWithDeps());
for (Extension extension : getLoadedExtensions()) {
if (classname.equals(extension.getClass().getCanonicalName())) {
return true;
}
}
return false;
}
use of org.parosproxy.paros.extension.Extension in project zaproxy by zaproxy.
the class AddOnLoader method getExtensions.
/**
* Returns all {@code Extension}s of the given {@code addOn}.
* <p>
* The discovery of {@code Extension}s is done by resorting to {@link AddOn#MANIFEST_FILE_NAME manifest file} bundled in the
* add-on.
* <p>
* Extensions with unfulfilled dependencies are not be returned.
* <p>
* <strong>Note:</strong> If the add-on is not installed the method returns an empty list.
*
* @param addOn the add-on whose extensions will be returned
* @return a list containing the {@code Extension}s of the given {@code addOn}
* @since 2.4.0
* @see Extension
* @see #getExtensions()
*/
public List<Extension> getExtensions(AddOn addOn) {
AddOnClassLoader addOnClassLoader = this.addOnLoaders.get(addOn.getId());
if (addOnClassLoader == null) {
return Collections.emptyList();
}
List<Extension> extensions = new ArrayList<>();
extensions.addAll(loadAddOnExtensions(addOn, addOn.getExtensions(), addOnClassLoader));
if (addOn.hasExtensionsWithDeps()) {
AddOn.AddOnRunRequirements reqs = addOn.calculateRunRequirements(aoc.getInstalledAddOns());
for (ExtensionRunRequirements extReqs : reqs.getExtensionRequirements()) {
if (extReqs.isRunnable()) {
List<AddOnClassLoader> dependencies = new ArrayList<>(extReqs.getDependencies().size());
for (AddOn addOnDep : extReqs.getDependencies()) {
dependencies.add(addOnLoaders.get(addOnDep.getId()));
}
AddOnClassLoader extAddOnClassLoader = new AddOnClassLoader(addOnClassLoader, dependencies, addOn.getExtensionAddOnClassnames(extReqs.getClassname()));
Extension ext = loadAddOnExtension(addOn, extReqs.getClassname(), extAddOnClassLoader);
if (ext != null) {
extensions.add(ext);
}
} else if (logger.isDebugEnabled()) {
logger.debug("Can't run extension '" + extReqs.getClassname() + "' of add-on '" + addOn.getName() + "' because of missing requirements: " + AddOnRunIssuesUtils.getRunningIssues(extReqs));
}
}
}
return extensions;
}
use of org.parosproxy.paros.extension.Extension in project zaproxy by zaproxy.
the class AddOnLoader method checkAndLoadDependentExtensions.
/**
* Checks and loads all the extensions that have (now) all required dependencies fulfilled.
* <p>
* Should be called after an installation of an add-on.
*
* @see #addAddOnImpl(AddOn)
* @since 2.4.0
*/
private void checkAndLoadDependentExtensions() {
boolean changed = false;
for (Entry<String, AddOnClassLoader> entry : new HashMap<>(addOnLoaders).entrySet()) {
AddOn runningAddOn = aoc.getAddOn(entry.getKey());
for (String extClassName : runningAddOn.getExtensionsWithDeps()) {
if (!runningAddOn.isExtensionLoaded(extClassName)) {
AddOn.AddOnRunRequirements reqs = runningAddOn.calculateExtensionRunRequirements(extClassName, aoc.getInstalledAddOns());
ExtensionRunRequirements extReqs = reqs.getExtensionRequirements().get(0);
if (extReqs.isRunnable()) {
List<AddOnClassLoader> dependencies = new ArrayList<>(extReqs.getDependencies().size());
for (AddOn addOnDep : extReqs.getDependencies()) {
dependencies.add(addOnLoaders.get(addOnDep.getId()));
}
AddOnClassLoader extAddOnClassLoader = new AddOnClassLoader(entry.getValue(), dependencies, runningAddOn.getExtensionAddOnClassnames(extClassName));
Extension ext = loadAddOnExtension(runningAddOn, extReqs.getClassname(), extAddOnClassLoader);
AddOnInstaller.installAddOnExtension(runningAddOn, ext);
runnableAddOns.get(runningAddOn).add(extReqs.getClassname());
changed = true;
}
}
}
}
if (changed) {
saveAddOnsRunState(runnableAddOns);
}
}
use of org.parosproxy.paros.extension.Extension in project zaproxy by zaproxy.
the class AddOnInstaller method installAddOnExtensions.
private static List<Extension> installAddOnExtensions(AddOn addOn) {
ExtensionLoader extensionLoader = Control.getSingleton().getExtensionLoader();
List<Extension> listExts = ExtensionFactory.loadAddOnExtensions(extensionLoader, Model.getSingleton().getOptionsParam().getConfig(), addOn);
for (Extension ext : listExts) {
installAddOnExtensionImpl(addOn, ext, extensionLoader);
}
return listExts;
}
Aggregations