Project

General

Profile

Add-on System » History » Version 3

Dirk Petrautzki, 08/05/2013 03:59 PM

1 1 Dirk Petrautzki
h1. Add-on System
2
3
This section describes the add-on system from the perspective of a developer.
4
The implementation of the add-on system is located in the maven module with the group Id *org.openecard* and the artifact Id *addon*.
5
All classes are in a sub namespace of *org.openecard.addon*. The module is divided into the following five packages:
6
* *org.openecard.addon*
7
In this package are the main classes of the add-on system, for example the AddonManager or the different AddonRegistries.
8
* *org.openecard.addon.bind*
9
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.
10
* *org.openecard.addon.ifd*
11
In here are the classes that specify the interface for an IFD protocol and the factory to instantiate such a protocol.
12
* *org.openecard.addon.manifest*
13
This package accumulates all classes needed to convert (automatically) between the XML represantation of the add-on description and it's java object pendants.
14
* *org.openecard.addon.sal*
15
In here are the classes that specify the interface for an SAL protocol and the factory to instantiate such a protocol.
16
17
h1. Types of add-ons
18
19 2 Dirk Petrautzki
In the context of Open eCard App, the terms add-on, plug-in and extension are defined as follows.
20
21
Add-on is the generic term for a component that enhances the functionality of the Open eCard App.
22
23
Extensions are independent from the context. Moreover, they are included directly into
24
the user interface and can be executed by the user. For instance, an add-on that provides a
25
PIN change functionality for smart cards is classified as an extension.
26
27
Plug-ins depend on the context in which the user uses the application. Performing
28
an authentication to a service using a particular smart card, for instance, requires a plug-in
29
which is capable of providing such functionality. Subsequently, plug-ins require a communication
30
with bindings to interact with external applications and services. Furthermore,
31
we distinguish between IFD, SAL, and application plug-ins.
32
33 1 Dirk Petrautzki
h1. Add-on development
34
35
This section describes the steps to take when developing an add-on.
36
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.
37
An example file for a PIN Management addon could look like this:
38
<pre>
39
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40
<AddonBundleDescription>
41
	<ID>PIN-Plugin</ID>
42
	<Version>1.0</Version>
43
	<About />
44
	<License />
45
	<LocalizedName xml:lang="DE">PIN Verwaltung</LocalizedName>
46
	<LocalizedDescription xml:lang="DE">Verwaltung von PIN/ PUK und gegebenenfalls anderen Geheimnissen der Chipkarte.
47
	</LocalizedDescription>
48
	<LocalizedName xml:lang="EN">PIN Management</LocalizedName>
49
	<LocalizedDescription xml:lang="EN">Management of PIN/ PUK and possibly other secrets of the smart-card.</LocalizedDescription>
50
	<Logo>images/logo.png</Logo>
51
	<ConfigDescription />
52
	<BindingActions />
53
	<ApplicationActions />
54
	<IFDActions />
55
	<SALActions />
56
</AddonBundleDescription>
57
</pre>
58
As can be seen, some fields can be localized. That fields are: *LocalizedName*, *LocalizedDescription* and *About*
59
The next step is to think about what actions should be offerd by the add-on and of what type these actions are.
60
For the PIN management example there are two actions. An action to change a PIN and a second action to unblock a PIN.
61 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.
62
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.
63
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:
64
<pre>
65
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
66
<AddonBundleDescription>
67
	<ID>PIN-Plugin</ID>
68
	<Version>1.0</Version>
69
	<About />
70
	<License />
71
	<LocalizedName xml:lang="DE">PIN Verwaltung</LocalizedName>
72
	<LocalizedDescription xml:lang="DE">Verwaltung von PIN/ PUK und gegebenenfalls anderen Geheimnissen der Chipkarte.
73
	</LocalizedDescription>
74
	<LocalizedName xml:lang="EN">PIN Management</LocalizedName>
75
	<LocalizedDescription xml:lang="EN">Management of PIN/ PUK and possibly other secrets of the smart-card.</LocalizedDescription>
76
	<Logo>images/pin-management.png</Logo>
77
	<ConfigDescription />
78
	<BindingActions />
79
	<ApplicationActions>
80
		<AppExtensionActionDescription>
81
			<ID>ChangePINAction</ID>
82
			<ClassName>org.openecard.plugins.pinplugin.ChangePINAction</ClassName>
83
			<LocalizedName xml:lang="DE">PIN ändern</LocalizedName>
84
			<LocalizedDescription xml:lang="DE">Mit dieser Aktion können Sie ihre PIN ändern.</LocalizedDescription>
85
			<LocalizedName xml:lang="EN">Change PIN</LocalizedName>
86
			<LocalizedDescription xml:lang="EN">With this action you can change your PIN.</LocalizedDescription>
87
			<ConfigDescription />
88
		</AppExtensionActionDescription>
89
		<AppExtensionActionDescription>
90
			<ID>UnblockPINAction</ID>
91
			<ClassName>org.openecard.plugins.pinplugin.UnblockPINAction</ClassName>
92
			<LocalizedName xml:lang="DE">PIN entsperren</LocalizedName>
93
			<LocalizedDescription xml:lang="DE">Mit dieser Aktion können Sie ihre PIN entsperren.</LocalizedDescription>
94
			<LocalizedName xml:lang="EN">Unblock PIN</LocalizedName>
95
			<LocalizedDescription xml:lang="EN">With this action you can unblock your PIN.</LocalizedDescription>
96
			<ConfigDescription />
97
		</AppExtensionActionDescription>
98
	</ApplicationActions>
99
	<IFDActions />
100
	<SALActions />
101
</AddonBundleDescription>
102
</pre>
103 3 Dirk Petrautzki
104
For the actual implementation part of the add-on, the following has to be considered.
105
The actions need to implement the AppExtensionAction interface, which itself extends the FactoryBaseType interface. 
106
Altogether, three functions are to be implemented:
107
* void execute();
108
the actual logic of the action, in this case the PIN change, will take place here
109
* void init(Context context) throws FactoryInitializationException;
110
initialization of the action; the given Context allows access to components of the Open eCard App like UserConsent or Dispatcher
111
* void destroy();
112
closing resources and further cleanup.