-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-guide.html
More file actions
553 lines (533 loc) · 23.6 KB
/
dev-guide.html
File metadata and controls
553 lines (533 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<link rel="icon" href="i/common/glyph.png">
<title>Passage Developer Guide</title>
<script type="text/javascript" src="js/sh_main.min.js"
language="JavaScript"></script>
<script type="text/javascript" src="js/lang/sh_java.min.js"
language="JavaScript"></script>
<script type="text/javascript" src="js/lang/sh_xml.min.js"
language="JavaScript"></script>
<script type="text/javascript" src="js/lang/sh_properties.min.js"
language="JavaScript"></script>
<link href="css/sh_whitengrey.min.css" rel="stylesheet" type="text/css"
media="all" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat&family=Quicksand&display=swap"
rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/bl.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/dev.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/documentation.css" rel="stylesheet" type="text/css"
media="all" />
</head>
<body onload="sh_highlightDocument();" class="dev-doc">
<div class="navigation container-fluid">
<div class="row header">
<div class="col-sm nav-ref home">
<a class="anchor" href="index.html">Home</a>
</div>
<div class="col-sm nav-ref features">
<a class="anchor" href="index.html#features">Features</a>
</div>
<div class="col-sm nav-ref products">
<a class="anchor" href="index.html#products">Products</a>
</div>
<div class="col-sm nav-ref components">
<a class="anchor" href="index.html#components">Components</a>
</div>
<div class="col-sm nav-ref documentation">
<a class="anchor" href="index.html#docs">Documentation</a>
</div>
<div class="col-sm nav-ref support">
<a class="anchor" href="index.html#support">Support</a>
</div>
<div class="col-sm nav-ref services">
<a class="anchor" href="index.html#services">Services</a>
</div>
<div class="col-sm nav-ref contact">
<a class="anchor" href="index.html#contact">Contact</a>
</div>
<div class="col-sm nav-ref contribute">
<a class="anchor" href="index.html#contribute">Contribute</a>
</div>
</div>
</div>
<div class="titling container-fluid">
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm">
<img src="i/common/glyph.png" width="256">
</div>
<div class="col-sm">
<div class="titling-brief">
<p>Passage Developer Guide</p>
<br />
<p>
Integrate Passage<br />in your product's code base
</p>
</div>
</div>
<div class="col-sm-2"></div>
</div>
</div>
<div class="separable documentation info-section container">
<div class="row">
<div class="step-name col-sm">
<div class="section-header">Step 1: Tell Passage, what it must
protect: declare licensing requirements</div>
</div>
</div>
<div class="row">
<div class="step-impl col-sm-12">
<ul>
<li>Highlight <span class="term">features</span> in your
product that you want to be used under licensing protection.
<p class="note">
If the product itself must be protected - this is the first
feature named after the product.<br />If there are other
functionality, like, say, especially clever graphical editor or <span
class="sample">contact support team</span> function, these are
features too.
</p>
</li>
<li>Specify a feature for Passage.
<ul>
<li><span class="term">Name</span> each feature in a
product-wide unique way.</li>
<li>A feature, most probably, is going to evolve, so
pinpoint a particular <span class="term">version</span> for each
feature in its closest to release state.
</li>
<li>Decide, how badly you want this feature to be protected
by license. We call it <span class="term">restriction
level</span>. It describes class of actions to be taken in case there
is no proper license for the feature. Currently four of them are
supported:
<ul>
<li><span class="term">error</span>: lack of license
coverage prevents feature from running: no one must use you
feature without proper license</li>
<li><span class="term">fatal</span>: the whole product is
to be stopped, if this particular feature is not covered by a
license</li>
<li><span class="term">warn</span>: feature execution is
to be paused and a user is forced to take an action to proceed
(see an ad, press any key, etc.)</li>
<li><span class="term">info</span>: light, not blocking
informative action is to be taken, like log entry <span
class="sample">the feature is not licensed</span>.</li>
</ul>
<p class="note">Almost each of these actions are to be
implemented on the product side.</p>
</li>
</ul>
</li>
<li>Demand licensing: declare <span class="term">licensing
requirements</span> using <span class="term">Provide-Capability</span>
header in a bundle's <span class="term">MANIFEST.MF</span>: <pre
class="sh_properties">
Provide-Capability: licensing.feature;licensing.feature="my.company.product.support";version="1.4.8";name="Contact Support Team";level="error";provider="The Company"
</pre> Here is an example taken from <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.api/META-INF/MANIFEST.MF">Passage
Operator</a> licensing declaration: <pre class="sh_properties">
Provide-Capability: licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.personal";version="2.0.0";name="Issue Personal License";level="warn";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.floating";version="2.0.0";name="Issue Floating License";level="warn";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.personal.full";version="2.0.0";name="Issue full functioning Personal License";level="error";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.floating.full";version="2.0.0";name="Issue full functioning Floating License";level="error";provider="Eclipse Passage"
</pre>
<p class="note">
Passage does not make any difference between your bundles, your
licensing requirements will be located anyway.<br />But it's a
good practice to declare licensing requirements as a part of
functionality contract, in a sort of <span class="sample">API</span>
bundle for the corresponding functionality.
</p>
</li>
</ul>
<p>Now Passage knows exactly what parts of your product is to be
protected and which licenses are proper.</p>
</div>
</div>
</div>
<div class="separable documentation info-section container">
<div class="row">
<div class="step-name col-sm">
<div class="section-header">Step 2: Tell Passage, which
services it has: configure Access Cycle</div>
</div>
</div>
<div class="row">
<div class="step-explanation col-sm-12">
<p>
<a href="access-cycle.html"><span class="term">Access
Cycle</span></a> is an invisible part of Passage that facilitates license
checks on your product's runtime.
</p>
</div>
</div>
<div class="row">
<div class="step-impl col-sm-12">
<p>
It is highly configurable, though the configuration is quite
simple: your product's code base just need to supply an instance of
<a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/Framework.java">Framework</a>
interface available through OSGi-component implementing <a
target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/FrameworkSupplier.java">FrameworkSupplier</a>
interface.
</p>
<p class="note">
We have <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.seal.demo/src/org/eclipse/passage/seal/internal/demo/DemoFramework.java">Demo
Framework</a>, which is configured with all the services
implementations we have out of the box. You can also consult with
the <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator.seal/src/org/eclipse/passage/loc/operator/seal/OperatorFramework.java">Operator
Framework</a>, which configures Access Cycle for our <a
target="_blank"
href="https://download.eclipse.org/passage/downloads/release/1.2.1/operator/">Passage
Operator</a> product.
</p>
<p>
There must be exactly one <span class="term">Framework</span>
supplied on runtime, other configurations are treated by Passage as
sabotage.
</p>
</div>
</div>
</div>
<div class="separable documentation info-section container">
<div class="row">
<div class="step-name col-sm">
<div class="section-header">Step 3: Implant license checks</div>
</div>
</div>
<div class="row">
<div class="step-explanation col-sm-12">
<p>Now in all key places in the product's code base you should
check if there is sufficient license coverage and take proper
actions it there isn't.</p>
<p>
Each feature, been used, must <span class="term">acquire a
license grant</span> and then <span class="term">release</span> it after
the work is done.
</p>
<p>
The only piece of data you need to convey to <span
class="term">Passage Access Cycle</span> is identifier of a <span
class="term">feature</span> you demanded to protect.
</p>
<p>
There are two main interfaces, which facilitate license checks for
client code: <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/Passage.java">Passage</a>
and <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/PassageUI.java">Passage
UI</a> with <span class="term">Equinox</span>-based implementations <a
target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/EquinoxPassage.java">Equinox
Passage</a> and <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/EquinoxPassageUI.java">Equinox
Passage UI</a>.
</p>
</div>
</div>
<div class="row">
<div class="step-impl col-sm-12">
<p>
Simply put, the you should cover the feature invocation into <span
class="term">acquire-release</span> pair of appeals to Passage
Access Cycle. Generally it looks like this:
</p>
<pre class="sh_java">
String feature = "my.feature.identifier";
...
public void protectedFunctionalityIsRequested(){
ServiceInvocationResult<GrantLockAttempt> grant = new EquinoxPassage().acquireLicense(feature);
if(grantIsNotAcquired(grant)) {
handleFailure(grant.diagnostic());
return;
}
keepGrant(grant.data());
invokeProtectedFunctionality();
}
...
void protectedFunctionalityCompletedOrFailed() {
grant.ifPresent(new EquinoxPassage()::releaseLicense);
}
</pre>
<p>To avoid boilerplating this template among client's code,
Passage supplies couple of handy units:</p>
<ul>
<li><a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/LicensedRunnable.java">Licensed
Runnable</a> - use it's <span class="term">Default</span>
implementation or extend to cover usage of a headless feature
under licensing protection.</li>
<li><a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/actions/LicensedRunnableUI.java">License
Runnable UI</a> or <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/actions/LicensedAction.java">Licensed
Action</a> - for the same purpose, but for features that can afford
GUI invocation.</li>
</ul>
</div>
</div>
</div>
<div class="separable documentation info-section container">
<div class="row">
<div class="step-name col-sm">
<div class="section-header">Solve practical tasks</div>
</div>
</div>
<div class="row">
<div class="step-explanation note col-sm-12">
<p>
<span class="term">Passage Operator</span> itself is a product licensed by Passage. <br />Consult
its source code:
</p>
<ul>
<li><a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator/META-INF/MANIFEST.MF">
MANIFEST.MF of LOC branding plug-in </a> declares licensing
requirement for the main product feature.<br />Feature identifier
equals to the Operator product name <a
href="https://github.com/eclipse-passage/passage/blob/master/products/org.eclipse.passage.loc.operator.product/org.eclipse.passage.loc.operator.product.product">
declared </a> in the corresponding LOC product bundle.</li>
<li><a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator/plugin.xml">
Extension for <span class="term">org.eclipse.e4.workbench.model</span>
point
</a> enables license check on the product startup.</li>
<li><a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.api/META-INF/MANIFEST.MF">
LOC API MANIFEST.MF </a> declares licensing requirement for 4
internal features.</li>
<li><a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/handlers/DashboardIssueLicenseHandler.java">
An action handler </a> appeals to Passage for one of the protected
internal features invocation.<br /> License coverage for another
protected internal feature is checked inside the <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/issue/PersonalLicenseIssuingProtection.java">implementation
code</a>.</li>
<li><a
href="https://github.com/eclipse-passage/passage/tree/master/bundles/org.eclipse.passage.loc.operator.seal">
Operator Seal</a> bundle <a
class="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator.seal/src/org/eclipse/passage/loc/operator/seal/OperatorAccessCycleConfiguration.java">configures
Access Cycle</a> and <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator.seal/src/org/eclipse/passage/loc/operator/seal/OperatorFrameworkSupplier.java">supplies</a>
an instance of <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.loc.operator.seal/src/org/eclipse/passage/loc/operator/seal/OperatorFramework.java">Passage
Framework</a>.</li>
</ul>
</div>
</div>
<div class="row task-solution">
<div class="task col-sm-3">
<p>check license on start of a product built on top of Eclipse
Workbench</p>
</div>
<div class="solution col-sm-9">
<p>
Having you've declared a licensing requirement for feature named
after the product, use <a target="_blank"
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/internal/e4/ui/addons/E4LicensingAddon.java">Passage
Licensing Addon</a>. It can be activated with the use of extension:
</p>
<pre class="sh_xml">
<extension
id="licensing"
point="org.eclipse.e4.workbench.model">
<processor
apply="always"
beforefragment="false"
class="org.eclipse.passage.lic.internal.e4.ui.addons.E4LicensingProcessor">
</processor>
</extension>
</pre>
<p>
In case of insufficient license it'll expose standard Passage <span
class="term">Licensing status dialog</span> like it does for
Passage Operator:
</p>
<p class="illustration">
<img src="i/dev/passage-ui-product-startup.PNG" width="380px" />
</p>
</div>
</div>
<div class="row task-solution">
<div class="task col-sm-3">
<p>enable/disable GUI item depending on whether it's
functionality is covered by a license or not</p>
</div>
<div class="solution col-sm-9">
<p>
You can <span class="sample">just aks</span> Passage if the feature
can potentially be used: no grant is to be acquired, so do not use
the check for the final functionality protection.
</p>
<pre class="sh_java">
public final class ProtectedAction extends org.eclipse.jface.action.Action {
private final String feature = "my.protected.feature.identifier";
...
@Override
public boolean isEnabled() {
return new EquinoxPassage().canUse(feature);
}
...
}
</pre>
</div>
</div>
<div class="row task-solution">
<div class="task col-sm-3">
<p>
protect headless implementation of a <span class="term">feature</span>
</p>
</div>
<div class="solution col-sm-9">
<p>
Use <span class="term">LicensedRunnable</span> to let us do all the
license checks.<br /> Just configure it's <span class="term">Default</span>
with
</p>
<ul>
<li>the feature identifier,</li>
<li><span class="term">Runnable</span> that implements a
business-function of the feature,</li>
<li>handle for all not-successful responses.</li>
</ul>
<pre class="sh_java">
public final class Invoke {
private final String feature = "a.feature.under.license.protection";
private final Logger log = LogManager.getLogger(getClass());
public void userCallsProtectedFunctionality() {
new LicensedRunnable.Default(feature, this::doTheWork, this::handleError);
}
private void doTheWork() {
// protected functionality here
}
private void handleError(ServiceInvocationResult<GrantLockAttempt> response) {
log.error(new DiagnosticExplained(response.diagnostic()));
}
}
</pre>
<p>
<span class="term">Access Cycle</span> is asked ones, and if access
to the feature is granted, then the protected business-code is
called, otherwise failure handle is invoked.
</p>
</div>
</div>
<div class="row task-solution">
<div class="task col-sm-3">
<p>protect action with GUI available</p>
</div>
<div class="solution col-sm-9">
<p>
Use <span class="term">LicensedRunnableUI</span> extension of <span
class="term">LicensedRunnable</span>.
</p>
<pre>
new LicensedRunnableUI(this::shell, feature, this::openWizard).run();
</pre>
<p>
It gains either default <span class="term">Shell</span> or the one
from your particular gui context, and uses it <span
class="emphasis">to interact with the product's user</span>.
</p>
<p>If the feature is covered by a license properly, no
interaction GUI elements are exposed.</p>
<p>
If license coverage is not sufficient, then <span class="term">Licensing
status dialog</span> opens. It offers the user an opportunity to <span
class="emphasis">alter</span> license coverage (import proper
license) and rechecks it each time when the user does so.
</p>
<p>Finally, either Passage is satisfied (the last of imported
licenses worked) and your protected code is allowed to run, or, if
license coverage has not been improved, configured denial handing
code is invoked.</p>
</div>
</div>
<div class="row task-solution">
<div class="task col-sm-3">
<p>
handle <span class="sample">feature cannot be executed as it
is not covered by a license</span> case
</p>
</div>
<div class="solution col-sm-9">
<p>
Most appeals to <span class="term">Passage</span> return an
instance of <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/ServiceInvocationResult.java">
Service Invocation Result</a>. It offers rich <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/diagnostic/Diagnostic.java">Diagnostic</a>.
</p>
<p>
You can expose it widely to the user with <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticDialog.java">
Diagnostic Dialog </a>, if you can afford GUI, or log in some way
using <a
href="https://github.com/eclipse-passage/passage/blob/master/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/diagnostic/DiagnosticExplained.java">
Diagnostic Explained </a> string supplier.
</p>
<p>
These facilities gives the user enough information to find out the
reason of denial.<br /> There are also sufficient data to trace
the logic and intermediate decisions.<br /> If, for some
particular case, the diagnostic is not enough, please <a
href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Passage">file
an issue</a> for us to extend it.
</p>
</div>
</div>
</div>
<div class="footer legal container-fluid">
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-7">
<div>© Copyright 2018 - 2025 ArSysOp</div>
</div>
<div class="col-sm">
<a href="https://projects.eclipse.org/projects/technology.passage"
target="_blank">About</a>
</div>
<div class="col-sm">
<a href="https://spdx.org/licenses/EPL-2.0.html" target="_blank">Terms
of use</a>
</div>
</div>
</div>
<div class="footer refs container-fluid">
<div class="row">
<div class="col-sm-6"></div>
<div class="col-sm">
Site is constructed with <a
href="https://github.com/twbs/bootstrap/">Bootstrap</a>.
</div>
<div class="col-sm">
<a
href="https://fonts.google.com/specimen/Quicksand?query=Quicksand"
target="_blank">Quicksand</a> and <a
href="https://fonts.google.com/specimen/Open+Sans?query=Montserrat"
target="_blank">Montserrat</a> fonts are used.
</div>
<div class="col-sm">
<a href="http://shjs.sourceforge.net/" target="_blank">SHJS</a> is
used to highlight syntaxes.
</div>
</div>
</div>
</body>
</html>