Skip to content

Commit 7db4025

Browse files
committed
Add GetKey that supports the new protocol
1 parent 7b072c8 commit 7db4025

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

Cryptolens.Licensing/Cryptolens.Licensing.CrossPlatform.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<Company>Cryptolens AB</Company>
88
<Authors>Cryptolens AB</Authors>
9-
<Version>4.0.40</Version>
10-
<AssemblyVersion>4.0.40.1</AssemblyVersion>
11-
<FileVersion>4.0.40.1</FileVersion>
9+
<Version>4.0.41</Version>
10+
<AssemblyVersion>4.0.41.1</AssemblyVersion>
11+
<FileVersion>4.0.41.1</FileVersion>
1212
<Description>An API documentation can be found at https://help.cryptolens.io/api/dotnet/.
1313

1414
This is a client API that serves as an interface to Cryptolens Web API (app.cryptolens.io/docs/api/).

Cryptolens.Licensing/Cryptolens.Licensing.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<Company>Cryptolens AB</Company>
88
<Authors>Cryptolens AB</Authors>
9-
<Version>4.0.40</Version>
10-
<AssemblyVersion>4.0.40.1</AssemblyVersion>
11-
<FileVersion>4.0.40.1</FileVersion>
9+
<Version>4.0.41</Version>
10+
<AssemblyVersion>4.0.41.1</AssemblyVersion>
11+
<FileVersion>4.0.41.1</FileVersion>
1212
<Description>An API documentation can be found at https://help.cryptolens.io/api/dotnet/.
1313

1414
This is a client API that serves as an interface to Cryptolens Web API (app.cryptolens.io/docs/api/).

Cryptolens.Licensing/Models/WebAPIModels.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ public class KeyInfoModel : RequestModel
498498
public int FieldsToReturn { get; set; }
499499

500500
public bool Metadata { get; set; }
501+
502+
public SignMethod SignMethod { get; set; }
501503
}
502504

503505
public class CreateTrialKeyModel : RequestModel

Cryptolens.Licensing/SKMv3/Key.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ public static RawResponse Activate(string token, int productId, string key, stri
119119
return res;
120120
}
121121

122+
/// <summary>
123+
/// This method is similar to <see cref="Key.GetKey(string, KeyInfoModel)"/> with the only exception that it will return a license key signed with the new protocol.
124+
/// <b>Note:</b> it's better to use this method, especially if you target Mono/Unity.<br/>
125+
/// In order to get the license key, you can call <see cref="LicenseKey.FromResponse(string, RawResponse)"/>.
126+
/// </summary>
127+
public static RawResponse GetKey(string token, int productId, string key, bool metadata = false
128+
, string LicenseServerUrl = null)
129+
{
130+
131+
var parameters = new KeyInfoModel()
132+
{
133+
ProductId = productId,
134+
Key = key,
135+
Metadata = metadata,
136+
Sign = true,
137+
SignMethod = SignMethod.StringSign,
138+
LicenseServerUrl = LicenseServerUrl
139+
};
140+
141+
var res = HelperMethods.SendRequestToWebAPI3<RawResponse>(parameters, "/key/getkey/", token, modelVersion: 3);
142+
return res;
143+
}
144+
122145
/// <summary>
123146
///This method will 'undo' a key activation with a certain machine code.
124147
///The key should not be blocked, since otherwise this method will throw an error.

SKM Test/V3/TestKey.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ public void SignatureTest()
8888
Assert.Fail();
8989
}
9090

91+
[TestMethod]
92+
public void TestGetKey2()
93+
{
94+
var result = Key.GetKey(AccessToken.AccessToken.GetKey, key: "MTMPW-VZERP-JZVNZ-SCPZM", productId: 3349);
95+
96+
var rsa = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
97+
var res = LicenseKey.FromResponse(rsa, result);
98+
99+
Assert.IsTrue(res != null);
100+
101+
}
102+
91103
[TestMethod]
92104
public void SignatureTestNewMethod()
93105
{

0 commit comments

Comments
 (0)