View previous topic :: View next topic |
Author |
Message |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Wed Feb 13, 2019 11:24 am Post subject: Authentication Data using Key Generator |
|
|
I am planning to integrate key generation with ShareIt either as a .NET app run by them or preferably hosted by us and ShareIt calling on it to get the license key.
We use Authenticated licenses and store some Authentication Data (support expiry date) when the license is generated. I know that this authentication data is stored on the authentication server and is fetched during license authentication. When keys are generated manually I can see that the License Tracker is updating the authentication server. However it's not clear to me how the authentication data is updated to the authentication server when a key generator is used. I could also use the existing "Expiry Date" to handle this but again how is this communicated to the authentication server when a standalone key generator is used? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Wed Feb 13, 2019 11:38 am Post subject: Follow on question |
|
|
One more question related to the above. We have variants of a product which differ on features (called editions) as well as number of activations allowed. We are using the Product Info property of the license to embed the edition so this can be enforced. For the number of allowed activations we are planning to set this when the license key is generated based on the variant purchased. When the license key is generated as a stand alone program (via a hosted key generator) the product info is embedded in the key so that works fine. However how does the number of allowed activations get updated to the authentication server? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Feb 15, 2019 3:22 am Post subject: |
|
|
If you are using the Infralution.Licensing.Data.Product.CreateLicenseKeys API (as shown in the CmdLineKeyGenerator sample project) then it will read the parameters from the LicenseDatabase and will (if necessary) contact the AuthenticationService to update the parameters. This requires that the key generator application has permissions to access the web and your authentication web site. Implementing a key generator using this API also requires that the key generator can access the License Tracker database (which may not be possible if you are hosting the key generator on ShareIt).
An alternative to consider may be to use the built in Expiry Date with the "Days after key first authenticated" option - as this does not require any communication with the authentication server when the key is first generated. This won't help your second scenario however. It is also possible to generate license keys without using the Infralution.Licensing.Data API using the AuthenticatedLicenseProvider.GenerateKey method directly. In this case you would have to call the AuthenticationService methods to set the limits and data. Below is the code from the Infralution.Licensing.Data.CreateLicenseKey method that does this:
Code: |
private LicenseKey CreateLicenseKey(Int32 distributorID,
CustomGeneratorData data,
int serialNo)
{
string key = null;
if (AuthenticatedLicenseParameters != null)
{
AuthenticatedLicenseProvider provider = new AuthenticatedLicenseProvider(AuthenticatedLicenseParameters, null);
key = provider.GenerateKey(data.ProductInfo, serialNo);
}
else if (LicenseParameters != null)
{
EncryptedLicenseProvider provider = new EncryptedLicenseProvider(LicenseParameters, null);
key = provider.GenerateKey(data.ProductInfo, serialNo);
}
LicenseKey licenseKey = new LicenseKey(_database);
licenseKey.Product_ID = ID;
licenseKey.Distributor_ID = distributorID;
licenseKey.ProductInfo = data.ProductInfo;
licenseKey.SerialNo = serialNo;
licenseKey.Key = key;
licenseKey.DateIssued = DateTime.UtcNow;
licenseKey.SetLicenseData(data);
licenseKey.Insert();
// if required contact the Authentication Service to set the max authentications and authentication data
// for the generated keys.
//
if (AuthenticatedLicenseParameters != null && _database.IsAuthenticationServerRemote())
{
if (data.AuthenticationLimitsSet)
{
AuthenticationService.SetAuthenticationLimits(AuthenticatedLicenseParameters, key,
data.MaxAuthentications,
data.MaxDeauthentications,
data.ExpiryDate,
data.ExpiryDays,
data.NumFloatingLicenses,
data.BlockTerminalServices,
data.DetectClonedComputers);
}
if (data.AuthenticationData != null)
{
AuthenticationService.SetAuthenticationData(AuthenticatedLicenseParameters, key, data.AuthenticationData);
}
}
return licenseKey;
}
|
_________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Fri Feb 15, 2019 3:45 am Post subject: |
|
|
Thank you for the response. Given that I plan to use Azure Functions for key generation access to the license DB would not be possible. However the option of using methods AuthenticatedLicenseProvider.GenerateKey and AuthenticationService.SetAuthenticationLimits may work. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Wed Feb 20, 2019 5:48 am Post subject: |
|
|
I am getting an exception "Object contains only the public half of a key pair. A private key must also be provided." when trying to call the method "SetAuthenticationLimits". The method "Infralution.Licensing.ASP.AuthenticatedLicenseParameters.SignData" throws the exception.
Below is the code I am using.
Code: |
var licenseProvider = new AuthenticatedLicenseProvider(LICENSE_PARAMETERS, null);
var authService = new AuthenticationService();
var serialNumber = 1000;
var maxAuthentications = 3;
var maxDeauthentications = 3;
var expiryDays = 366;
var productInfo = "F";
var licenseKey = licenseProvider.GenerateKey(productInfo, serialNumber);
authService.SetAuthenticationLimits(
licenseProvider.Parameters, licenseKey, maxAuthentications, maxDeauthentications, null, expiryDays, null, blockTerminalServices: false, detectClonedComputers: true);
|
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Wed Feb 20, 2019 6:39 am Post subject: |
|
|
I was able to overcome the previous issue after setting the authentication password in the parameters. Now the auth server is failing the request with an invalid signature error. I have checked and ensured the XML parameters matches the validation parameters generated by the License Tracker app.
Here is the full error being returned in the exception object:
Quote: | System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Invalid Signature
at AuthenticationServer.AuthenticationService.SetAuthenticationLimits(String productName, String sessionKey, Byte[] encryptedArgs, Byte[] signature)
--- End of inner exception stack trace --- |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 20, 2019 11:03 am Post subject: |
|
|
If you wish to generate license keys (and call methods on the AuthenticationService) then you need to initialize the AuthenticatedLicenseProvider with the FULL authentication parameters. The parameters that you normally paste into your code to validate licenses don't include the keys required to generate license keys and communicate with the AuthenticationService. You can get the full parameters by using the Export Settings button in the Product dialog in License Tracker. This will save them to a file which you can them copy them from into your code. _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Wed Feb 20, 2019 12:00 pm Post subject: |
|
|
Thanks - it works now.
I had a question about the two license expiry related parameters to the method SetAuthenticationLimits. It takes both expiryDate and expiryDays. I was under the impression that any one could be passed in. However I found that I need to pass in both. Any specific reason for that? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 20, 2019 8:51 pm Post subject: |
|
|
The parameters are Nullable. So if you don't want to set one you pass in null (Nothing in VB) _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Thu Feb 21, 2019 3:00 am Post subject: |
|
|
I assumed so since they were nullable. However if I pass null for expiryDate (and a valid expiry days parameter) then the license keys don't get added to the authentication server though the call to SetAuthenticationLimits completes successfully. Anyway it works fine if I pass a valid expiryDate. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Feb 21, 2019 3:19 am Post subject: |
|
|
The expiry days parameter is only valid if you have the Product Key Generation "Expiry Date - Days after key first authenticated" option selected (in License Tracker product dialog) _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Thu Feb 21, 2019 3:24 am Post subject: |
|
|
OK. The option selected under Product -> Key Generation tab is Expiry Date -> "Days after key generated". Doesn't it apply for this setting? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Feb 21, 2019 3:44 am Post subject: |
|
|
No. If you want the expiry date set based on when the key is generated this is calculated by License Tracker (or in your case your key generator) and then you set the ExpiryDate when calling SetAuthenticationLimits. The AuthenticationService only needs to kwow the ExpiryDays when you want it to set the ExpiryDate when the license key is first authenticated _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
santosh
Joined: 10 Jan 2019 Posts: 23
|
Posted: Thu Feb 21, 2019 1:41 pm Post subject: |
|
|
Thanks for the response. My key generator is all set now! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|