Search in sources :

Example 6 with AddonSpecification

use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.

the class AddonFileSystemMonitor method extractSpec.

private AddonSpecification extractSpec(Path file) throws WSMarshallerException, MultipleAddonRegistration {
    if (isJarFile(file, true)) {
        // now check if there is a manifest
        ManifestExtractor mfEx = new ManifestExtractor();
        AddonSpecification spec = mfEx.getAddonSpecificationFromFile(file.toFile());
        // return the manifest if a valid addon file was found
        if (spec != null) {
            Set<AddonSpecification> plugins = fileRegistry.listAddons();
            // TODO: this is in general a problem, because it may replace the addon on next start
            for (AddonSpecification desc : plugins) {
                if (desc.getId().equals(spec.getId())) {
                    String msg = String.format("The addon with id %s is already registered.", desc.getId());
                    logger.debug("Addon '{}' is already registered by another bundle.", file.toFile().getName());
                    throw new MultipleAddonRegistration(msg, spec);
                }
            }
            return spec;
        }
    }
    return null;
}
Also used : AddonSpecification(org.openecard.addon.manifest.AddonSpecification)

Example 7 with AddonSpecification

use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.

the class AddonFileSystemMonitor method addAddon.

private void addAddon(Path file) throws WSMarshallerException {
    logger.info("Trying to register addon {}.", file.getFileName());
    String fName = file.toFile().getName();
    try {
        AddonSpecification spec = extractSpec(file);
        if (spec != null) {
            fileRegistry.register(spec, file.toFile());
            manager.loadLoadOnStartupActions(spec);
            logger.info("Successfully registered {} as addon.", fName);
        } else {
            logger.error("The jar file {} does not seem to be an add-on.", fName);
        }
    } catch (MultipleAddonRegistration ex) {
        logger.error("The jar file {} is an already registered add-on.", fName);
    }
}
Also used : AddonSpecification(org.openecard.addon.manifest.AddonSpecification)

Example 8 with AddonSpecification

use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.

the class AddonFileSystemMonitor method removeAddon.

private void removeAddon(Path file) {
    logger.info("Trying to remove addon {}.", file.getFileName());
    // check if we are dealing with a registered jar file
    AddonSpecification spec = getCurrentSpec(file);
    if (spec != null) {
        // call the destroy method of all actions and protocols
        manager.unloadAddon(spec);
        // remove configuration file
        AddonProperties addonProps = new AddonProperties(spec);
        addonProps.removeConfiguration();
        // remove from file registry
        fileRegistry.unregister(file.toFile());
        logger.info("Succesfully removed add-on {}.", file.toFile().getName());
    }
}
Also used : AddonSpecification(org.openecard.addon.manifest.AddonSpecification)

Example 9 with AddonSpecification

use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.

the class AddonSelector method getIFDProtocol.

public IFDProtocol getIFDProtocol(@Nonnull String uri) throws AddonNotFoundException {
    Set<AddonSpecification> addons = manager.getRegistry().searchIFDProtocol(uri);
    if (addons.isEmpty()) {
        throw new AddonNotFoundException("No Add-on for IFD protocol '" + uri + "' found.");
    }
    AddonSpecification addon = strategy.select(addons);
    return manager.getIFDProtocol(addon, uri);
}
Also used : AddonSpecification(org.openecard.addon.manifest.AddonSpecification)

Example 10 with AddonSpecification

use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.

the class AddonSelector method getAppExtensionAction.

public AppExtensionAction getAppExtensionAction(@Nonnull String actionId) throws AddonNotFoundException {
    Set<AddonSpecification> addons = manager.getRegistry().searchByActionId(actionId);
    if (addons.isEmpty()) {
        throw new AddonNotFoundException("No Add-on for action ID '" + actionId + "' found.");
    }
    AddonSpecification addon = strategy.select(addons);
    return manager.getAppExtensionAction(addon, actionId);
}
Also used : AddonSpecification(org.openecard.addon.manifest.AddonSpecification)

Aggregations

AddonSpecification (org.openecard.addon.manifest.AddonSpecification)37 Test (org.testng.annotations.Test)21 AppPluginActionProxy (org.openecard.addon.bind.AppPluginActionProxy)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 AppExtensionAction (org.openecard.addon.bind.AppExtensionAction)4 AppExtensionActionProxy (org.openecard.addon.bind.AppExtensionActionProxy)3 AppPluginAction (org.openecard.addon.bind.AppPluginAction)3 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 JLabel (javax.swing.JLabel)2 JList (javax.swing.JList)2 AddonRegistry (org.openecard.addon.AddonRegistry)2 IFDProtocolProxy (org.openecard.addon.ifd.IFDProtocolProxy)2 ProtocolPluginSpecification (org.openecard.addon.manifest.ProtocolPluginSpecification)2 SALProtocolProxy (org.openecard.addon.sal.SALProtocolProxy)2 InitializeFramework (de.bund.bsi.ecard.api._1.InitializeFramework)1 ApplicationCapabilitiesType (iso.std.iso_iec._24727.tech.schema.ApplicationCapabilitiesType)1