Add-on System » History » Version 4
Hans-Martin Haase, 08/13/2015 11:33 AM
Start of rewritting.
| 1 | 4 | Hans-Martin Haase | {{toc}} |
|---|---|---|---|
| 2 | |||
| 3 | 1 | Dirk Petrautzki | h1. Add-on System |
| 4 | 4 | Hans-Martin Haase | |
| 5 | On this wiki page you'll find detailed information about the add-on development like the different kinds of add-ons and how they are enabled to communicate with core application. |
||
| 6 | |||
| 7 | h2. Definition of Add-on in the Open eCard context |
||
| 8 | |||
| 9 | _Add-on_ is the generic term for a component that enhances the functionality of the Open eCard App. |
||
| 10 | |||
| 11 | _Extensions_ are independent from the context. Moreover, they are included directly into the user interface and can be executed by the user. For instance, an add-on that provides a PIN change functionality for smart cards is classified as an _extension_. |
||
| 12 | |||
| 13 | _Plug-ins_ depend on the context in which the user uses the application. Performing an authentication to a service using a particular smart card, for instance, requires a _plug-in_ which is capable of providing such functionality. Subsequently, _plug-ins_ require a communication with bindings to interact with external applications and services. Furthermore, we distinguish between IFD, SAL, and application plug-ins. |
||
| 14 | |||
| 15 | h2. Add-on Types |
||
| 16 | |||
| 17 | h3. IFD Plug-ins |
||
| 18 | |||
| 19 | h3. SAL Plug-ins |
||
| 20 | |||
| 21 | h3. Application Plug-ins |
||
| 22 | |||
| 23 | h3. Application Extensions |
||
| 24 | |||
| 25 | h2. Architecture of an Add-on package |
||
| 26 | |||
| 27 | h3. General architecture |
||
| 28 | |||
| 29 | h3. The Add-on Manifest |
||
| 30 | |||
| 31 | h3. Types available in the configuration |
||
| 32 | |||
| 33 | h3. Configuration of an Add-on in the client |
||
| 34 | |||
| 35 | h2. Add-on Implementation |
||
| 36 | 1 | Dirk Petrautzki | |
| 37 | This section describes the add-on system from the perspective of a developer. |
||
| 38 | The implementation of the add-on system is located in the maven module with the group Id *org.openecard* and the artifact Id *addon*. |
||
| 39 | All classes are in a sub namespace of *org.openecard.addon*. The module is divided into the following five packages: |
||
| 40 | * *org.openecard.addon* |
||
| 41 | In this package are the main classes of the add-on system, for example the AddonManager or the different AddonRegistries. |
||
| 42 | * *org.openecard.addon.bind* |
||
| 43 | This package includes all classes representing the interface between an addon and a specific binding. That is to say, here are the classes needed to convert a specific request, for example a HTTP request that arrives via the localhost binding, into a generic request, which is independent from binding and vice versa for the response. |
||
| 44 | * *org.openecard.addon.ifd* |
||
| 45 | In here are the classes that specify the interface for an IFD protocol and the factory to instantiate such a protocol. |
||
| 46 | * *org.openecard.addon.manifest* |
||
| 47 | This package accumulates all classes needed to convert (automatically) between the XML represantation of the add-on description and it's java object pendants. |
||
| 48 | * *org.openecard.addon.sal* |
||
| 49 | In here are the classes that specify the interface for an SAL protocol and the factory to instantiate such a protocol. |
||
| 50 | |||
| 51 | h1. Types of add-ons |
||
| 52 | |||
| 53 | 2 | Dirk Petrautzki | In the context of Open eCard App, the terms add-on, plug-in and extension are defined as follows. |
| 54 | |||
| 55 | Add-on is the generic term for a component that enhances the functionality of the Open eCard App. |
||
| 56 | |||
| 57 | Extensions are independent from the context. Moreover, they are included directly into |
||
| 58 | the user interface and can be executed by the user. For instance, an add-on that provides a |
||
| 59 | PIN change functionality for smart cards is classified as an extension. |
||
| 60 | |||
| 61 | Plug-ins depend on the context in which the user uses the application. Performing |
||
| 62 | an authentication to a service using a particular smart card, for instance, requires a plug-in |
||
| 63 | which is capable of providing such functionality. Subsequently, plug-ins require a communication |
||
| 64 | with bindings to interact with external applications and services. Furthermore, |
||
| 65 | we distinguish between IFD, SAL, and application plug-ins. |
||
| 66 | |||
| 67 | 1 | Dirk Petrautzki | h1. Add-on development |
| 68 | |||
| 69 | This section describes the steps to take when developing an add-on. |
||
| 70 | As first step a new XML file called *Addon.xml* in the *META-INF* directory of the project should be created and the fields that describe the general part of the add-ons can already be filled. |
||
| 71 | An example file for a PIN Management addon could look like this: |
||
| 72 | <pre> |
||
| 73 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||
| 74 | <AddonBundleDescription> |
||
| 75 | <ID>PIN-Plugin</ID> |
||
| 76 | <Version>1.0</Version> |
||
| 77 | <About /> |
||
| 78 | <License /> |
||
| 79 | <LocalizedName xml:lang="DE">PIN Verwaltung</LocalizedName> |
||
| 80 | <LocalizedDescription xml:lang="DE">Verwaltung von PIN/ PUK und gegebenenfalls anderen Geheimnissen der Chipkarte. |
||
| 81 | </LocalizedDescription> |
||
| 82 | <LocalizedName xml:lang="EN">PIN Management</LocalizedName> |
||
| 83 | <LocalizedDescription xml:lang="EN">Management of PIN/ PUK and possibly other secrets of the smart-card.</LocalizedDescription> |
||
| 84 | <Logo>images/logo.png</Logo> |
||
| 85 | <ConfigDescription /> |
||
| 86 | <BindingActions /> |
||
| 87 | <ApplicationActions /> |
||
| 88 | <IFDActions /> |
||
| 89 | <SALActions /> |
||
| 90 | </AddonBundleDescription> |
||
| 91 | </pre> |
||
| 92 | As can be seen, some fields can be localized. That fields are: *LocalizedName*, *LocalizedDescription* and *About* |
||
| 93 | The next step is to think about what actions should be offerd by the add-on and of what type these actions are. |
||
| 94 | For the PIN management example there are two actions. An action to change a PIN and a second action to unblock a PIN. |
||
| 95 | 2 | Dirk Petrautzki | These actions are not of type *ProtocolPlugin* nor *AppPluginAction*, but of type *AppExtensionAction*, as they expand the function of the Open eCard App independent from a context. |
| 96 | This means two classes implementing the *AppExtensionAction* interface need to be added to the project and the two AppExtensionActionDescription that belong to them need to be added to the XML description. |
||
| 97 | Assume we are working in the org.openecard.plugins.pinplugin namespace and the two actions are called ChangePINAction and UnblockPINAction, the resulting XML would now look similar to this: |
||
| 98 | <pre> |
||
| 99 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||
| 100 | <AddonBundleDescription> |
||
| 101 | <ID>PIN-Plugin</ID> |
||
| 102 | <Version>1.0</Version> |
||
| 103 | <About /> |
||
| 104 | <License /> |
||
| 105 | <LocalizedName xml:lang="DE">PIN Verwaltung</LocalizedName> |
||
| 106 | <LocalizedDescription xml:lang="DE">Verwaltung von PIN/ PUK und gegebenenfalls anderen Geheimnissen der Chipkarte. |
||
| 107 | </LocalizedDescription> |
||
| 108 | <LocalizedName xml:lang="EN">PIN Management</LocalizedName> |
||
| 109 | <LocalizedDescription xml:lang="EN">Management of PIN/ PUK and possibly other secrets of the smart-card.</LocalizedDescription> |
||
| 110 | <Logo>images/pin-management.png</Logo> |
||
| 111 | <ConfigDescription /> |
||
| 112 | <BindingActions /> |
||
| 113 | <ApplicationActions> |
||
| 114 | <AppExtensionActionDescription> |
||
| 115 | <ID>ChangePINAction</ID> |
||
| 116 | <ClassName>org.openecard.plugins.pinplugin.ChangePINAction</ClassName> |
||
| 117 | <LocalizedName xml:lang="DE">PIN ändern</LocalizedName> |
||
| 118 | <LocalizedDescription xml:lang="DE">Mit dieser Aktion können Sie ihre PIN ändern.</LocalizedDescription> |
||
| 119 | <LocalizedName xml:lang="EN">Change PIN</LocalizedName> |
||
| 120 | <LocalizedDescription xml:lang="EN">With this action you can change your PIN.</LocalizedDescription> |
||
| 121 | <ConfigDescription /> |
||
| 122 | </AppExtensionActionDescription> |
||
| 123 | <AppExtensionActionDescription> |
||
| 124 | <ID>UnblockPINAction</ID> |
||
| 125 | <ClassName>org.openecard.plugins.pinplugin.UnblockPINAction</ClassName> |
||
| 126 | <LocalizedName xml:lang="DE">PIN entsperren</LocalizedName> |
||
| 127 | <LocalizedDescription xml:lang="DE">Mit dieser Aktion können Sie ihre PIN entsperren.</LocalizedDescription> |
||
| 128 | <LocalizedName xml:lang="EN">Unblock PIN</LocalizedName> |
||
| 129 | <LocalizedDescription xml:lang="EN">With this action you can unblock your PIN.</LocalizedDescription> |
||
| 130 | <ConfigDescription /> |
||
| 131 | </AppExtensionActionDescription> |
||
| 132 | </ApplicationActions> |
||
| 133 | <IFDActions /> |
||
| 134 | <SALActions /> |
||
| 135 | </AddonBundleDescription> |
||
| 136 | </pre> |
||
| 137 | 3 | Dirk Petrautzki | |
| 138 | For the actual implementation part of the add-on, the following has to be considered. |
||
| 139 | The actions need to implement the AppExtensionAction interface, which itself extends the FactoryBaseType interface. |
||
| 140 | Altogether, three functions are to be implemented: |
||
| 141 | * void execute(); |
||
| 142 | the actual logic of the action, in this case the PIN change, will take place here |
||
| 143 | * void init(Context context) throws FactoryInitializationException; |
||
| 144 | initialization of the action; the given Context allows access to components of the Open eCard App like UserConsent or Dispatcher |
||
| 145 | * void destroy(); |
||
| 146 | closing resources and further cleanup. |