public class Key
extends java.lang.Object
A collection of methods that operate on a license key. Please see a complete list here.
Note (for Android): it's important to run these methods asynchronously, as shown below:
Thread thread = new Thread(new Runnable() { @Override public void run() { // call eg. Key.Activate(...). } }); thread.start();
Moreover, the manifest file needs to have internet permission, which can be added as shown below:
<uses-permission android:name="android.permission.INTERNET"/> <application ....
Constructor and Description |
---|
Key() |
Modifier and Type | Method and Description |
---|---|
static LicenseKey |
Activate(java.lang.String token,
java.lang.String RSAPubKey,
ActivateModel model)
Calls the Activate method (https://app.cryptolens.io/docs/api/v3/Activate).
|
static LicenseKey |
Activate(java.lang.String token,
java.lang.String RSAPubKey,
ActivateModel model,
APIError error)
Calls the Activate method (https://app.cryptolens.io/docs/api/v3/Activate).
|
static CreateKeyResult |
CreateTrialKey(java.lang.String token,
CreateTrialKeyModel model)
This method creates a license key that is time-limited, node-locked
and with the "Time-Limited" and "Trial" features set to true (which can be set by editing the
feature definitions on the product page).
|
static CreateKeyResult |
CreateTrialKey(java.lang.String token,
CreateTrialKeyModel model,
APIError error)
This method creates a license key that is time-limited, node-locked
and with the "Time-Limited" and "Trial" features set to true (which can be set by editing the
feature definitions on the product page).
|
static boolean |
Deactivate(java.lang.String token,
DeactivateModel model)
This method will 'undo' a key activation with a certain machine code.
|
static boolean |
Deactivate(java.lang.String token,
DeactivateModel model,
APIError error)
This method will 'undo' a key activation with a certain machine code.
|
public static LicenseKey Activate(java.lang.String token, java.lang.String RSAPubKey, ActivateModel model)
token
- The access token with 'Activate' permission.RSAPubKey
- Your RSA Public Key, which can be found at https://app.cryptolens.io/docs/api/v3/QuickStart.model
- Method parameters.public static LicenseKey Activate(java.lang.String token, java.lang.String RSAPubKey, ActivateModel model, APIError error)
This method allows you to retrieve the error message from the Web API.
To retrieve the error message, you need to initialize an APIError object and pass it in into the "error" parameter. For example,
APIError error = new APIError();
LicenseKey license = Key.Activate(auth, RSAPubKey, new ActivateModel(3349, "ICVLD-VVSZR-ZTICT-YKGXL", Helpers.GetMachineCode()), error);
System.out.println(error.message);
token
- The access token with 'Activate' permission.RSAPubKey
- Your RSA Public Key, which can be found at https://app.cryptolens.io/docs/api/v3/QuickStart.model
- Method parameters.error
- The error object whose Message field will be populated if an error has occurred. Please initialize
this parameter, i.e. define APIError error = new APIError();
and then pass
error
into this parameter.public static boolean Deactivate(java.lang.String token, DeactivateModel model)
token
- The access token with 'Deactivate' permission.model
- Method parameters.public static boolean Deactivate(java.lang.String token, DeactivateModel model, APIError error)
token
- The access token with 'Deactivate' permission.model
- Method parameters.error
- The error object whose Message field will be populated if an error has occurred. Please initialize
this parameter, i.e. define APIError error = new APIError();
and then pass
error
into this parameter.public static CreateKeyResult CreateTrialKey(java.lang.String token, CreateTrialKeyModel model)
This method creates a license key that is time-limited, node-locked and with the "Time-Limited" and "Trial" features set to true (which can be set by editing the feature definitions on the product page). Note, by default, the trial will work for 15 days. To change this limit, you can set the Feature Lock to the desired value, when creating the access token.
If a trial key was already created for a certain machine code, this method will try to find the license key and return it instead. However, this will only occur if the license key is still a trial key (based on feature definitions) and is not blocked.
token
- The access token with 'CreateTrialKey' permission.model
- Method parameters.public static CreateKeyResult CreateTrialKey(java.lang.String token, CreateTrialKeyModel model, APIError error)
This method creates a license key that is time-limited, node-locked and with the "Time-Limited" and "Trial" features set to true (which can be set by editing the feature definitions on the product page). Note, by default, the trial will work for 15 days. To change this limit, you can set the Feature Lock to the desired value, when creating the access token.
If a trial key was already created for a certain machine code, this method will try to find the license key and return it instead. However, this will only occur if the license key is still a trial key (based on feature definitions) and is not blocked.
token
- The access token with 'CreateTrialKey' permission.model
- Method parameters.error
- The error object whose Message field will be populated if an error has occurred. Please initialize
this parameter, i.e. define APIError error = new APIError();
and then pass
error
into this parameter.