afb-api-so: adds verbosity on dlopen error
[src/app-framework-binder.git] / doc / afb-overview.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta charset="utf-8">
5   <meta name="generator" content="pandoc">
6   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
7   <meta name="author" content="José Bollo">
8   <title>Overview of AFB-DAEMON</title>
9   <style type="text/css">code{white-space: pre;}</style>
10   <link rel="stylesheet" href="doc.css">
11   <!--[if lt IE 9]>
12     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
13   <![endif]-->
14 </head>
15 <body>
16 <header>
17 <h1 class="title">Overview of AFB-DAEMON</h1>
18 <h2 class="author">José Bollo</h2>
19 <h3 class="date">24 juin 2016</h3>
20 </header>
21 <nav id="TOC">
22 <ul>
23 <li><a href="#overview-of-afb-daemon">Overview of AFB-DAEMON</a><ul>
24 <li><a href="#roles-of-afb-daemon">Roles of afb-daemon</a></li>
25 <li><a href="#use-cases-of-the-binder-afb-daemon">Use cases of the binder afb-daemon</a><ul>
26 <li><a href="#remotely-running-application">Remotely running application</a></li>
27 <li><a href="#adding-native-features-to-html5qml-applications">Adding native features to HTML5/QML applications</a></li>
28 <li><a href="#offering-services-to-the-system">Offering services to the system</a></li>
29 </ul></li>
30 <li><a href="#the-bindings-of-the-binder-afb-daemon">The bindings of the binder afb-daemon</a></li>
31 <li><a href="#launching-the-binder-afb-daemon">Launching the binder afb-daemon</a></li>
32 <li><a href="#future-development-of-afb-daemon">Future development of afb-daemon</a></li>
33 </ul></li>
34 </ul>
35 </nav>
36 <h1 id="overview-of-afb-daemon">Overview of AFB-DAEMON</h1>
37 <h2 id="roles-of-afb-daemon">Roles of afb-daemon</h2>
38 <p>The name <strong>afb-daemon</strong> stands for <em>Application Framework Binder Daemon</em>. That is why afb-daemon is also named <strong><em>the binder</em></strong>.</p>
39 <p><strong>Afb-daemon</strong> is in charge to bind one instance of an application to the AGL framework and AGL system.</p>
40 <p>On the following figure, you can use a typical use of afb-daemon:</p>
41 <a id="binder-fig-basis">
42 <h4>
43 Figure: binder afb-daemon, basis
44 </h4>
45 <p></a></p>
46 <pre><code>. . . . . . . . . . . . . . . . . . . . . . . . . .
47 .        Isolated security context                .
48 .                                                 .
49 .        +------------------------------+         .
50 .        |                              |         .
51 .        |    A P P L I C A T I O N     |         .
52 .        |                              |         .
53 .        +--------------+---------------+         .
54 .                       |                         .
55 .                       |                         .
56 .   +-------------------+----------------------+  .
57 .   |                            :             |  .
58 .   |        b i n d e r         :             |  .
59 .   |    A F B - D A E M O N     :  BINDINGS   |  .
60 .   |                            :             |  .
61 .   +-------------------+----------------------+  .
62 .                       |                         .
63 . . . . . . . . . . . . | . . . . . . . . . . . . .
64                         |
65                         v
66                    AGL SYSTEM</code></pre>
67 <p>The application and its companion binder run in secured and isolated environment set for them. Applications are intended to access to AGL system through the binder.</p>
68 <p>The binder afb-daemon serves multiple purposes:</p>
69 <ol type="1">
70 <li><p>It acts as a gateway for the application to access the system;</p></li>
71 <li><p>It acts as an HTTP server for serving files to HTML5 applications;</p></li>
72 <li><p>It allows HTML5 applications to have native extensions subject to security enforcement for accessing hardware ressources or for speeding parts of algorithm.</p></li>
73 </ol>
74 <h2 id="use-cases-of-the-binder-afb-daemon">Use cases of the binder afb-daemon</h2>
75 <p>This section tries to give a better understanding of the binder usage through several use cases.</p>
76 <h3 id="remotely-running-application">Remotely running application</h3>
77 <p>One of the most interresting aspect of using the binder afb-daemon is the ability to run applications remotely. This feature is possible because the binder afb-daemon implements native web protocols.</p>
78 <p>So the <a href="#binder-fig-1">figure binder, basis</a> would become when the application is run remotely:</p>
79 <a id="binder-fig-remote">
80 <h4>
81 Figure: binder afb-daemon and remotely running application
82 </h4>
83 <p></a></p>
84 <pre><code>             +------------------------------+
85              |                              |
86              |    A P P L I C A T I O N     |
87              |                              |
88              +--------------+---------------+
89                             |
90                        ~ ~ ~ ~ ~ ~
91                       :  NETWORK  :
92                        ~ ~ ~ ~ ~ ~
93                             |
94 . . . . . . . . . . . . . . | . . . . . . . . . . . . . .
95 . Isolated security         |                           .
96 .   context                 |                           .
97 .                           |                           .
98 .     . . . . . . . . . . . . . . . . . . . . . . . .   .
99 .     .                                             .   .
100 .     .               F I R E W A L L               .   .
101 .     .                                             .   .
102 .     . . . . . . . . . . . . . . . . . . . . . . . .   .
103 .                           |                           .
104 .       +-------------------+----------------------+    .
105 .       |                            :             |    .
106 .       |    A F B - D A E M O N     :   BINDINGS  |    .
107 .       |                            :             |    .
108 .       +-------------------+----------------------+    .
109 .                           |                           .
110 . . . . . . . . . . . . . . | . . . . . . . . . . . . . .
111                             |
112                             v
113                        AGL SYSTEM</code></pre>
114 <h3 id="adding-native-features-to-html5qml-applications">Adding native features to HTML5/QML applications</h3>
115 <p>Applications can provide with their packaged delivery a binding. That binding will be instanciated for each application instance. The methods of the binding will be accessible by applications and will be excuted within the security context.</p>
116 <h3 id="offering-services-to-the-system">Offering services to the system</h3>
117 <p>It is possible to run the binder afb-daemon as a daemon that provides the API of its bindings.</p>
118 <p>This will be used for:</p>
119 <ol type="1">
120 <li><p>offering common APIs</p></li>
121 <li><p>provide application's services (services provided as application)</p></li>
122 </ol>
123 <p>In that case, the figure showing the whole aspects is</p>
124 <a id="binder-fig-remote">
125 <h4>
126 Figure: binder afb-daemon for services
127 </h4>
128 <p></a></p>
129 <pre><code>. . . . . . . . . . . . . . . . . . . . . . 
130 .  Isolated security context application  . 
131 .                                         . 
132 .    +------------------------------+     . 
133 .    |                              |     . 
134 .    |    A P P L I C A T I O N     |     . 
135 .    |                              |     . 
136 .    +--------------+---------------+     .     . . . . . . . . . . . . . . . . . . . . . .
137 .                   |                     .     .        Isolated security context A      .
138 .                   |                     .     .                                         .
139 . +-----------------+------------------+  .     . +------------------------------------+  .
140 . |                        :           |  .     . |                        :           |  .
141 . |      b i n d e r       :           |  .     . |      b i n d e r       :  service  |  .
142 . |  A F B - D A E M O N   : BINDINGS  |  .     . |  A F B - D A E M O N   : BINDINGS  |  .
143 . |                        :           |  .     . |                        :     A     |  .
144 . +-----------------+------------------+  .     . +-----------------+------------------+  .
145 .                   |                     .     .                   |                     .
146 . . . . . . . . . . | . . . . . . . . . . .     . . . . . . . . . . | . . . . . . . . . . .
147                     |                                               |
148                     v                                               v
149          ================================================================================
150                                      D - B U S   &amp;   C Y N A R A
151          ================================================================================
152                     ^                                               ^
153                     |                                               |
154 . . . . . . . . . . | . . . . . . . . . . .     . . . . . . . . . . | . . . . . . . . . . .
155 .                   |                     .     .                   |                     .
156 . +-----------------+------------------+  .     . +-----------------+------------------+  .
157 . |                        :           |  .     . |                        :           |  .
158 . |      b i n d e r       :  service  |  .     . |      b i n d e r       :  service  |  .
159 . |  A F B - D A E M O N   : BINDINGS  |  .     . |  A F B - D A E M O N   : BINDINGS  |  .
160 . |                        :     B     |  .     . |                        :     C     |  .
161 . +------------------------------------+  .     . +------------------------------------+  .
162 .                                         .     .                                         .
163 .        Isolated security context B      .     .        Isolated security context C      .
164 . . . . . . . . . . . . . . . . . . . . . .     . . . . . . . . . . . . . . . . . . . . . .</code></pre>
165 <p>For this case, the binder afb-daemon takes care to attribute one single session context to each client instance. It allows bindings to store and retrieve data associated to each of its client.</p>
166 <h2 id="the-bindings-of-the-binder-afb-daemon">The bindings of the binder afb-daemon</h2>
167 <p>The binder can instanciate bindings. The primary use of bindings is to add native methods that can be accessed by applications written with any language through web technologies ala JSON RPC.</p>
168 <p>This simple idea is declined to serves multiple purposes:</p>
169 <ol type="1">
170 <li><p>add native feature to applications</p></li>
171 <li><p>add common API available by any applications</p></li>
172 <li><p>provide customers services</p></li>
173 </ol>
174 <p>A specific document explains how to write an afb-daemon binder binding: <a href="afb-binding-writing.html">HOWTO WRITE a BINDING for AFB-DAEMON</a></p>
175 <h2 id="launching-the-binder-afb-daemon">Launching the binder afb-daemon</h2>
176 <p>The launch options for binder <strong>afb-daemon</strong> are:</p>
177 <pre><code>  --help
178
179     Prints help with available options
180
181   --version
182
183     Display version and copyright
184
185   --verbose
186
187     Increases the verbosity, can be repeated
188
189   --port=xxxx
190
191     HTTP listening TCP port  [default 1234]
192
193   --rootdir=xxxx
194
195     HTTP Root Directory [default $AFBDIR or else $HOME/.AFB]
196
197   --rootbase=xxxx
198
199     Angular Base Root URL [default /opa]
200
201     This is used for any application of kind OPA (one page application).
202     When set, any missing document whose url has the form /opa/zzz
203     is translated to /opa/#!zzz
204
205   --rootapi=xxxx
206
207     HTML Root API URL [default /api]
208
209     The bindings are available within that url.
210
211   --alias=xxxx
212
213     Maps a path located anywhere in the file system to the
214     a subdirectory. The syntax for mapping a PATH to the
215     subdirectory NAME is: --alias=/NAME:PATH.
216
217     Example: --alias=/icons:/usr/share/icons maps the
218     content of /usr/share/icons within the subpath /icons.
219
220     This option can be repeated.
221
222   --apitimeout=xxxx
223
224     binding API timeout in seconds [default 20]
225
226     Defines how many seconds maximum a method is allowed to run.
227     0 means no limit.
228
229   --cntxtimeout=xxxx
230
231     Client Session Timeout in seconds [default 3600]
232
233   --cache-eol=xxxx
234
235     Client cache end of live [default 100000 that is 27,7 hours]
236
237   --sessiondir=xxxx
238
239     Sessions file path [default rootdir/sessions]
240
241   --session-max=xxxx
242
243     Maximum count of simultaneous sessions [default 10]
244
245   --ldpaths=xxxx
246
247     Load bindings from given paths separated by colons
248     as for dir1:dir2:binding1.so:... [default = $libdir/afb]
249
250     You can mix path to directories and to bindings.
251     The sub-directories of the given directories are searched
252     recursively.
253
254     The bindings are the files terminated by &#39;.so&#39; (the extension
255     so denotes shared object) that contain the public entry symbol.
256
257   --binding=xxxx
258
259     Load the binding of given path.
260
261   --token=xxxx
262
263     Initial Secret token to authenticate.
264
265     If not set, no client can authenticate.
266
267     If set to the empty string, then any initial token is accepted.
268
269   --mode=xxxx
270
271     Set the mode: either local, remote or global.
272
273     The mode indicate if the application is run locally on the host
274     or remotely through network.
275
276   --readyfd=xxxx
277
278     Set the #fd to signal when ready
279
280     If set, the binder afb-daemon will write &quot;READY=1\n&quot; on the file
281     descriptor whose number if given (/proc/self/fd/xxx).
282
283   --dbus-client=xxxx
284
285     Transparent binding to a binder afb-daemon service through dbus.
286
287     It creates an API of name xxxx that is implemented remotely
288     and queried via DBUS.
289
290   --dbus-server=xxxx
291
292     Provides a binder afb-daemon service through dbus.
293
294     The name xxxx must be the name of an API defined by a binding.
295     This API is exported through DBUS.
296
297   --foreground
298
299     Get all in foreground mode (default)
300
301   --daemon
302
303     Get all in background mode</code></pre>
304 <h2 id="future-development-of-afb-daemon">Future development of afb-daemon</h2>
305 <ul>
306 <li><p>The binder afb-daemon would launch the applications directly.</p></li>
307 <li><p>The current setting of mode (local/remote/global) might be reworked to a mechanism for querying configuration variables.</p></li>
308 <li><p>Implements &quot;one-shot&quot; initial token. It means that after its first authenticated use, the initial token is removed and no client can connect anymore.</p></li>
309 <li><p>Creates some intrinsic APIs.</p></li>
310 <li><p>Make the service connection using WebSocket not DBUS.</p></li>
311 <li><p>Management of targetted events.</p></li>
312 <li><p>Securisation of LOA.</p></li>
313 <li><p>Integration of the protocol JSON-RPC for the websockets.</p></li>
314 </ul>
315 </body>
316 </html>