- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Disclaimer
The goal is to provide an application that is able to implement a basic licensing mechanism to be able to integrate an app with the ctrlX AUTOMATION licensing system. This guide is covering just the case with the ctrlX COREvirtual. It is the DevelopR that has to adapt this to his needs with the real license code and so on.
This guide is not intended to be a substitution of the official documentation which can be found here: Licensing Documentation. It's meant to be a help for the people who have a similar setup and might want to start from a demo.
Requirements
- ctrlX COREvirtual
- SDK Environment
- Service2Service authentication Link To How-to the guide will start from this 😃
Step 1: Add the license info in the Package Manifest
This step is not the actual technical license check but will improve the usability of the app. Inserting these info in the Package Manifest we enhance our app with the graphical info, in the app install page, with the needed licenses to run the app.
Step 2: Add the right plugs and slot in the snapcraft.yaml
There is the possibility to use a unix socket to bind our process directly there. In this example I have used the standard rest API. Anyway to implement this feature we need to add the following plug.
The Picture shows also the "datalayer" plug which is needed to interact with the datalayer. The licensing-service plug allows the system to create a socketfile there.
Step 3: Implement the algorithm
The important APIs to take into consideration are the following and are listed in the official documentation, can be tested directly on the core with swagger and plus we have a dedicated section here: Swagger online.
The workflow is the following:
- Whenever we boot the device the app should ask for the license with the "acquire license" API. The answer will contain an ID that should be kept to release the license in a second time. In this case we can start the app normally otherwise we block the app.
- If the app is removed we need to use the Release License API to release the license.
- When the app is restarted we don't know if it's a fresh boot of the device, the app crashed or whatsoever so better to repeat point 2 and then point 1 anytime.
In this demo I save the ID in a file located in $SNAP_DATA and I create a file named "licensed" just to register that the app is correctly licensed. This process is achieved using a python script:
I remove the proxy setting for this script, in this way I am avoiding to use the proxy for local host and I can't have problems with such configurations. The script to unlicense the app is the following:
If we find the "licensed" file we read the ID contained and we release the license. We then remove also the file itself.
In case the app is removed we take advantage of the "remove hook" functionality which is a script called automatically when the app starts. Here is the documentation Hooks Explaination.
The hook just calls the "unlicense.py" script. The app is normally started with a launch.wrapper script which unlicenses the app and license it again, checking the file with the id presence.
Step 4: go productive
Convert the pervious algorithm to "requests-unixsocket" in order to communicate without HTTP rest api but binding directly to the license file.
As stated this is just an example on how someone can implement this functionality. The example is just a demo and it is not complete.
Have Fun 😎
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.