use of org.openecard.addon.manifest.ProtocolPluginSpecification in project open-ecard by ecsec.
the class AndroidMarshaller method parseProtocolPluginSpecification.
private ProtocolPluginSpecification parseProtocolPluginSpecification(XmlPullParser parser) throws XmlPullParserException, IOException {
ProtocolPluginSpecification protocolPluginDescription = new ProtocolPluginSpecification();
int eventType;
do {
parser.next();
eventType = parser.getEventType();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("ClassName")) {
protocolPluginDescription.setClassName(parser.nextText());
} else if (parser.getName().equals("LocalizedName")) {
LocalizedString localizedString = new LocalizedString();
localizedString.setLang(parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang"));
localizedString.setValue(parser.nextText());
protocolPluginDescription.getLocalizedName().add(localizedString);
} else if (parser.getName().equals("LocalizedDescription")) {
LocalizedString localizedString = new LocalizedString();
localizedString.setLang(parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang"));
localizedString.setValue(parser.nextText());
protocolPluginDescription.getLocalizedDescription().add(localizedString);
} else if (parser.getName().equals("URI")) {
protocolPluginDescription.setUri(parser.nextText());
} else if (parser.getName().equals("ConfigDescription")) {
protocolPluginDescription.setConfigDescription(parseConfigDescription(parser));
} else {
throw new IllegalArgumentException("Unexpected Tag found: " + parser.getName());
}
}
} while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("ProtocolPluginSpecification")));
return protocolPluginDescription;
}
use of org.openecard.addon.manifest.ProtocolPluginSpecification in project open-ecard by ecsec.
the class AddonManager method getSALProtocol.
/**
* Get a specific SALProtocol.
*
* @param addonSpec {@link AddonSpecification} which contains the description of the {@link SALProtocol}.
* @param uri The {@link ProtocolPluginSpecification#uri} to identify the requested SALProtocol.
* @return The requested SALProtocol object or NULL if no such object was found.
*/
public SALProtocol getSALProtocol(@Nonnull AddonSpecification addonSpec, @Nonnull String uri) {
SALProtocol salProt = cache.getSALProtocol(addonSpec, uri);
// TODO: find a better way to deal with the reuse of protocol plugins
// if (salProt != null) {
// // protocol cached so return it
// return salProt;
// }
ProtocolPluginSpecification protoSpec = addonSpec.searchSALActionByURI(uri);
if (protoSpec == null) {
LOG.error("Requested SAL Protocol {} does not exist in Add-on {}.", uri, addonSpec.getId());
} else {
String className = protoSpec.getClassName();
try {
ClassLoader cl = registry.downloadAddon(addonSpec);
SALProtocolProxy protoFactory = new SALProtocolProxy(className, cl);
Context aCtx = createContext(addonSpec);
protoFactory.init(aCtx);
cache.addSALProtocol(addonSpec, uri, protoFactory);
return protoFactory;
} catch (ActionInitializationException e) {
LOG.error("Initialization of SAL Protocol failed", e);
} catch (AddonException ex) {
LOG.error("Failed to download Add-on.", ex);
}
}
return null;
}
use of org.openecard.addon.manifest.ProtocolPluginSpecification in project open-ecard by ecsec.
the class ManagementDialog method createAddonPaneFromAddonSpec.
private void createAddonPaneFromAddonSpec(AddonSpecification desc, AddonSelectionModel model, boolean coreAddon) {
String description = desc.getLocalizedDescription(LANGUAGE_CODE);
String name = desc.getLocalizedName(LANGUAGE_CODE);
Image logo;
if (coreAddon) {
logo = loadLogo(null, desc.getLogo());
} else {
try {
ClassLoader loader = manager.getRegistry().downloadAddon(desc);
logo = loadLogo(loader, "META-INF/" + desc.getLogo());
} catch (AddonException ex) {
logger.error("Failed to load logo from Add-on bundle.");
logo = null;
}
}
// setup about panel but just if we don't have a core addon
String about = desc.getAbout(LANGUAGE_CODE);
String licenseText = desc.getLicenseText(LANGUAGE_CODE);
AboutPanel aboutPanel = null;
if ((!about.equals("") || !licenseText.equals("")) && !coreAddon) {
aboutPanel = new AboutPanel(desc, coreAddon, manager, this);
}
// inital setup of settings panel if the addon has general settings in the non protocol/action specific
// declaration
DefaultSettingsPanel settingsPanel = null;
ArrayList<DefaultSettingsGroup> settingsGroups = new ArrayList<>();
AddonProperties addonProps = new AddonProperties(desc);
Settings settings = SettingsFactory.getInstance(addonProps);
if (desc.getConfigDescription() != null && !desc.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(lang.translationForKey("addon.settings.general"), settings, desc.getConfigDescription().getEntries());
settingsGroups.add(group);
}
// AppExtensionActions
if (!desc.getApplicationActions().isEmpty()) {
for (AppExtensionSpecification appExtSpec : desc.getApplicationActions()) {
if (appExtSpec.getConfigDescription() != null && !appExtSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(appExtSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, appExtSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// Binding actions
if (!desc.getBindingActions().isEmpty()) {
for (AppPluginSpecification appPluginSpec : desc.getBindingActions()) {
if (appPluginSpec.getConfigDescription() != null && !appPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(appPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, appPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// IFD Actions
if (!desc.getIfdActions().isEmpty()) {
for (ProtocolPluginSpecification protPluginSpec : desc.getIfdActions()) {
if (protPluginSpec.getConfigDescription() != null && !protPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(protPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, protPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// SAL Actions
if (!desc.getSalActions().isEmpty()) {
for (ProtocolPluginSpecification protPluginSpec : desc.getSalActions()) {
if (protPluginSpec.getConfigDescription() != null && !protPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(protPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, protPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
if (!settingsGroups.isEmpty()) {
settingsPanel = new DefaultSettingsPanel(settingsGroups.toArray(new DefaultSettingsGroup[settingsGroups.size()]));
}
// create the actions panel
ActionPanel actionPanel = null;
if (!desc.getApplicationActions().isEmpty()) {
actionPanel = new ActionPanel();
for (AppExtensionSpecification appExtSpec : desc.getApplicationActions()) {
ActionEntryPanel entry = new ActionEntryPanel(desc, appExtSpec, manager);
actionPanel.addActionEntry(entry);
}
}
AddonPanel nextPanel = null;
// check whether to use a tabbed pane or not
if (actionPanel != null && settingsPanel == null && aboutPanel == null) {
nextPanel = new AddonPanel(actionPanel, name, description, logo);
} else if (actionPanel == null && settingsPanel != null && aboutPanel == null) {
nextPanel = new AddonPanel(settingsPanel, name, description, logo);
} else if (actionPanel == null && settingsPanel == null && aboutPanel != null) {
nextPanel = new AddonPanel(aboutPanel, name, description, logo);
} else if (actionPanel != null || settingsPanel != null || aboutPanel != null) {
nextPanel = new AddonPanel(actionPanel, settingsPanel, aboutPanel, name, description, logo);
}
if (nextPanel != null) {
model.addElement(name, nextPanel);
}
}
use of org.openecard.addon.manifest.ProtocolPluginSpecification in project open-ecard by ecsec.
the class AddonManager method getIFDProtocol.
/**
* Get a specific IFDProtocol.
*
* @param addonSpec {@link AddonSpecification} which contains the description of the {@link IFDProtocol}.
* @param uri The {@link ProtocolPluginSpecification#uri} to identify the requested IFDProtocol.
* @return The requested IFDProtocol object or NULL if no such object was found.
*/
public IFDProtocol getIFDProtocol(@Nonnull AddonSpecification addonSpec, @Nonnull String uri) {
IFDProtocol ifdProt = cache.getIFDProtocol(addonSpec, uri);
// TODO: find a better way to deal with the reuse of protocol plugins
// if (ifdProt != null) {
// // protocol cached so return it
// return ifdProt;
// }
ProtocolPluginSpecification protoSpec = addonSpec.searchIFDActionByURI(uri);
if (protoSpec == null) {
LOG.error("Requested IFD Protocol {} does not exist in Add-on {}.", uri, addonSpec.getId());
} else {
String className = protoSpec.getClassName();
try {
ClassLoader cl = registry.downloadAddon(addonSpec);
IFDProtocolProxy protoFactory = new IFDProtocolProxy(className, cl);
Context aCtx = createContext(addonSpec);
protoFactory.init(aCtx);
cache.addIFDProtocol(addonSpec, uri, protoFactory);
return protoFactory;
} catch (ActionInitializationException e) {
LOG.error("Initialization of IFD Protocol failed", e);
} catch (AddonException ex) {
LOG.error("Failed to download Add-on.", ex);
}
}
return null;
}
use of org.openecard.addon.manifest.ProtocolPluginSpecification in project open-ecard by ecsec.
the class TCTokenHandler method getSupportedDIDs.
private List<String> getSupportedDIDs() {
TreeSet<String> result = new TreeSet<>();
// check all sal protocols in the
AddonRegistry registry = manager.getRegistry();
Set<AddonSpecification> addons = registry.listAddons();
for (AddonSpecification addon : addons) {
for (ProtocolPluginSpecification proto : addon.getSalActions()) {
result.add(proto.getUri());
}
}
return new ArrayList<>(result);
}
Aggregations