Class Key
Methods that perform operations on a license key. A complete list can be found here: https://app.cryptolens.io/docs/api/v3/Key
Inherited Members
Namespace: SKMV3Methods
Assembly: Cryptolens.Licensing.CrossPlatform.dll
Syntax
public static class Key
Methods
| Improve this Doc View SourceActivate(string, ActivateModel)
This method will perform a key activation, similar to Activate [Web API 2]. In contrast to key validation, key activation is not read only since it can change license key data depending on configurations such as trial activation, etc. If trial activation is enabled, a key can be altered. Information that is retrieved can be signed by the server to be able to keep validate keys without Internet connection. Please keep in mind that the Feature lock can be used to restrict the fields that can be shown in the result (fieldsToReturn). More about this in Remarks. https://app.cryptolens.io/docs/api/v3/Activate
Declaration
public static KeyInfoResult Activate(string token, ActivateModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token. Read more at https://app.cryptolens.io/docs/api/v3/Auth |
ActivateModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
KeyInfoResult | A BasicResult or null. |
Remarks
The feature lock value is used to store the filedsToReturn value. If you set a certain value in the feature lock, it will be prioritized higher than the fieldsToReturn parameter.
• To compute the value of the feature lock, please use the Hide column, for those fields that you want to omit in the result above.
• If the ActivatedMachines is hidden, only the current machine code will be included(used during this particular activation). Otherwise, all machine codes will be included.
Examples
Assuming that you've created a key in the SKM platform that has maximum number of machines set to anything greater than zero, we can run the following code:
var auth = "{access token with permission to access the activate method}"
var result = Key.Activate(token: auth, parameters: new ActivateModel()
{
Key = "GEBNC-WZZJD-VJIHG-GCMVD",
ProductId = 3349,
Sign = true,
MachineCode = SKGL.SKM.getMachineCode(SKGL.SKM.getSHA1);
});
if(result == null || result.Result == ResultType.Error)
{
// an error occured or the key is invalid or it cannot be activated
// (eg. the limit of activated devices was achieved)
}
// everything went fine if we are here!
|
Improve this Doc
View Source
Activate(string, int, string, string, bool, int, int, string, string, string)
This method is similar to Activate(string, ActivateModel) with the only exception that it will return a license key signed with the new protocol.
Note: it's better to use this method, especially if you target Mono/Unity.
In order to get the license key, you can call FromResponse(string, RawResponse).
Declaration
public static RawResponse Activate(string token, int productId, string key, string machineCode = "", bool metadata = false, int floatingTimeInterval = 0, int maxOverdraft = 0, string OSInfo = null, string friendlyName = "", string LicenseServerUrl = null)
Parameters
Type | Name | Description |
---|---|---|
string | token | |
int | productId | |
string | key | |
string | machineCode | |
bool | metadata | |
int | floatingTimeInterval | |
int | maxOverdraft | |
string | OSInfo | |
string | friendlyName | |
string | LicenseServerUrl |
Returns
Type | Description |
---|---|
RawResponse |
AddFeature(string, FeatureModel)
This method will change a given feature to be true (in a license). If the key algorithm in the product is SKGL, the key string will be changed if necessary. Otherwise, if SKM15 is used, the key will stay the same. If the key is changed, the new key will be stored in the message.
Declaration
public static BasicResult AddFeature(string token, FeatureModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token. Read more at https://app.cryptolens.io/docs/api/v3/Auth |
FeatureModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.
Examples
Here is an example that demonstrates the use of the method.
public void AddFeatureTest()
{
var keydata = new FeatureModel() { Key = "LXWVI-HSJDU-CADTC-BAJGW", Feature = 2, ProductId = 3349 };
var auth = new AuthDetails() { Token = "WyI2Iiwib3lFQjFGYk5pTHYrelhIK2pveWdReDdEMXd4ZDlQUFB3aGpCdTRxZiJd" };
var result = SKM.AddFeature(auth, keydata);
if (result != null && result.Result == ResultType.Success)
{
// feature 2 is set to true.
}
else
{
Assert.Fail();
}
}
|
Improve this Doc
View Source
BlockKey(string, KeyLockModel)
This method will block a specific license key to ensure that the key cannot be accessible by most of the methods in the Web API (activation, validation, optional field, and deactivation).Note, blocking the key will still allow you to access the key in Web API 3, unless otherwise stated for a given Web API 3 method. To do the reverse, please see UnblockKey(string, KeyLockModel).
Declaration
public static BasicResult BlockKey(string token, KeyLockModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token (https://app.cryptolens.io/User/AccessToken#/) with Block key permission. |
KeyLockModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.
ChangeCustomer(string, ChangeCustomerModel)
This method will change the customer associated with a license. If the customer is not specified (for example, if CustomerId=0) or the customer with the provided ID does not exist, any customer that was previously associated with the license will be dissociated.
Declaration
public static BasicResult ChangeCustomer(string token, ChangeCustomerModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token (https://app.cryptolens.io/User/AccessToken#/) with Change Customer permission. |
ChangeCustomerModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
ChangeNotes(string, ChangeNotesModel)
This method will change the content of the notes field of a given license key.
Declaration
public static BasicResult ChangeNotes(string token, ChangeNotesModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token (https://app.cryptolens.io/User/AccessToken#/) with Change Notes permission. |
ChangeNotesModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
ChangeReseller(string, ChangeResellerModel)
This method will change the reseller of a license. If the reseller is not specified (for example, if ResellerId=0) or the reseller with the provided ID does not exist, any reseller that was previously associated with the license will be dissociated.
Declaration
public static BasicResult ChangeReseller(string token, ChangeResellerModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token (https://app.cryptolens.io/User/AccessToken#/) with Change Reseller permission. |
ChangeResellerModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
CreateKey(string, CreateKeyModel)
This method will create a new license key, which is the same as GenerateKey in Web API 2.
Declaration
public static CreateKeyResult CreateKey(string token, CreateKeyModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | Details such as Token and Version. |
CreateKeyModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
CreateKeyResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.
Examples
Private Sub CreateKey()
Dim parameters = New CreateKeyModel() With {
.ProductId = 3,
.F1 = 1,
.Period = 30
}
Dim auth = "{access token with CreateKey permission and optional product lock}"
Dim result = Key.CreateKey(token:=auth, parameters:=parameters)
If (result IsNot Nothing AndAlso result.Result = ResultType.Success) Then
' successful
Console.WriteLine(result.Key)
End If
End Sub
|
Improve this Doc
View Source
CreateTrialKey(string, CreateTrialKeyModel)
Declaration
public static CreateKeyResult CreateTrialKey(string token, CreateTrialKeyModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | |
CreateTrialKeyModel | parameters |
Returns
Type | Description |
---|---|
CreateKeyResult |
Deactivate(string, DeactivateModel)
This method will 'undo' a key activation with a certain machine code. The key should not be blocked, since otherwise this method will throw an error. https://app.cryptolens.io/docs/api/v3/Deactivate
Declaration
public static BasicResult Deactivate(string token, DeactivateModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token. Read more at https://app.cryptolens.io/docs/api/v3/Auth |
DeactivateModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult or null. |
Examples
var auth = "{access token with permission to access the deactivate method}"
var result = Key.Deactivate(token: auth, parameters: new DeactivateModel()
{
Key = "GEBNC-WZZJD-VJIHG-GCMVD",
ProductId = 3349,
MachineCode = SKGL.SKM.getMachineCode(SKGL.SKM.getSHA1);
});
if(result == null || result.Result == ResultType.Error)
{
// could not deactivate. maybe it has already been deactivated.
// more information can be found in the message.
}
// everything went fine if we are here!
|
Improve this Doc
View Source
ExtendLicense(string, ExtendLicenseModel)
Declaration
public static BasicResult ExtendLicense(string token, ExtendLicenseModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | |
ExtendLicenseModel | parameters |
Returns
Type | Description |
---|---|
BasicResult |
GetKey(string, KeyInfoModel)
This method will return information about a license key, similar to Validate [Web API 2]. In contrast to activation, this method (aka Key Validation) will be in read only mode. That is, it will not add a device to the license nor use trial activation. More about this in Remarks.
Declaration
public static KeyInfoResult GetKey(string token, KeyInfoModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | Details such as Token and Version. |
KeyInfoModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
KeyInfoResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.
GetKey(string, int, string, bool, string)
This method is similar to GetKey(string, KeyInfoModel) with the only exception that it will return a license key signed with the new protocol.
Note: it's better to use this method, especially if you target Mono/Unity.
In order to get the license key, you can call FromResponse(string, RawResponse).
Declaration
public static RawResponse GetKey(string token, int productId, string key, bool metadata = false, string LicenseServerUrl = null)
Parameters
Type | Name | Description |
---|---|---|
string | token | |
int | productId | |
string | key | |
bool | metadata | |
string | LicenseServerUrl |
Returns
Type | Description |
---|---|
RawResponse |
MachineLockLimit(string, MachineLockLimit)
This method will change the maximum number of machine codes that a license key can have.
Declaration
public static BasicResult MachineLockLimit(string token, MachineLockLimit parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | Details such as Token and Version. |
MachineLockLimit | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.
RemoveFeature(string, FeatureModel)
Declaration
public static BasicResult RemoveFeature(string token, FeatureModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | |
FeatureModel | parameters |
Returns
Type | Description |
---|---|
BasicResult |
UnblockKey(string, KeyLockModel)
This method will unblock a specific license key to ensure that the key can be accessible by most of the methods in the Web API (activation, validation, optional field, and deactivation). To do the reverse, please see BlockKey(string, KeyLockModel).
Declaration
public static BasicResult UnblockKey(string token, KeyLockModel parameters)
Parameters
Type | Name | Description |
---|---|---|
string | token | The access token (https://app.cryptolens.io/User/AccessToken#/) with Unblock key permission. |
KeyLockModel | parameters | The parameters that the method needs. |
Returns
Type | Description |
---|---|
BasicResult | A BasicResult object or null. |
Remarks
This method may, in rare cases, return null if an error has occurred. Null should be seen as an unsuccessful result.