Getting started guide for the Java SDK
cryptolens.jar
and cryptolens-android.jar
. If your application is cross platform or if you would like to have as few dependencies as possible (e.g., without slf4j
), we recommend to use cryptolens-android.jar
instead.
If you choose to use cryptolens-android.jar
, GetMachineCode
and IsOnRightMachine
need to be called with the version parameter set to 2. For example, Helpers.GetMachineCode(2)
or Helpers.IsOnRightMachine(license, 2)
. If your application will run on an Android device, we recommend to use a different way to obtain the machine code, which is described here.
cryptolens.jar
file, the code below should generate successful result. A working project with the code below can be found in the example-app folder.
RSAPubKey
- the RSA Public key, which can be found on this page.auth
- the access token (can be found here, in API Keys section).product_id
- the id of the product can be found on the product page (in the example above, it’s 3646).key
- the license key to be verified (above it’s MPDWY-PQAOW-FKSCH-SGAAU).machine_code
- the unique id of the device, which may require root access. Note, this value is not the same as the one generated by the .NET client.LicenseKey.LoadFromString
does not check the ProductId. In case you have multiple products, we recommend that you check that the ProductId corresponds to the product where the user tries to use the license file.ActivateModel
. Optionally, you can also allow customers to exceed the bound by specifying the maxOverdraft.
The code below has a floatingTimeInterval of 300 seconds and maxOverdraft set to 1. To support floating licenses with overdraft, the call to Helpers.IsOnRightMachine(license, true, true)
needs two boolean flags to be set to true.
Key.Deactivate
method, as shown below. Note, we need an access token with Deactivate permission, so the ones used in earlier examples cannot be used (unless they have this permission).
LicenseServerUrl
parameter. All API models expose this parameter.
For example, let’s suppose that your client runs the license server on http://10.1.1.6:8080
and you want to call Key.GetKey()
. In this case, we first define all parameters for the request and then modify the license server url:
LicenseServerUrl
parameter.
The entire code is shown below: