Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can I generate license keys programmatically?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Licensing FAQ
View previous topic :: View next topic  
Author Message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Oct 26, 2009 9:50 pm    Post subject: Can I generate license keys programmatically? Reply with quote

Yes you can generate license keys from a ASP.NET or desktop application. There are two ways you can do this.

1. If you want to create customers, sales and license keys directly into the License Tracker database then you can use the Infralution.Licensing.Data assembly to interface with the database. The Command Line Key Generator sample project shows how to generate license keys using this interface. This is probably the simplest approach if your key generator has access to the License Tracker database.

2. If you want to generate license keys without accessing the License Tracker database then you can reference the Infralution.Licensing.ASP or Infralution.Licensing.Forms assembly and call the EncryptedLicenseProvider or AuthenticatedLicenseProvider GenerateKey method. See the notes below on implementing this method.

Licensing License Key Generators

Both methods of generating keys require that you have an ILS license installed to generate keys with a password other than "TEST". If your generator application is an ASP.NET application, then the ILS License must be installed in the ASP.NET App_Data directory and is authenticated against the web server domain name. To install the ILS license in the App_Data directory you must write a web page that allows you to enter your ILS license key and then calls the LicenseUtilities.InstallILSLicense method.

An alternative (if you are using method 2 and generating the keys directly without using the Infralution.Licensing.Data assembly) is to include the source code for the licensing classes directly in your application project (as described in the Redistributables and Source Code section of help). ILS uses compilation constants which (as they won't be defined in your project) mean that the ILS license check is not done when the classes are included directly in your project.

Notes on Implementing Method 2

You need to pass the GenerateKey method an EncryptedLicenseParameters or AuthenticationLicenseParameters object. Note that you cannot simply use the LICENSE_PARAMETERS that you include in your application code - since this doesn't contain the private parameters required to generate keys. Instead you should read the settings required to generate keys for your product from a Infralution License Settings (.ils) file that you have exported from LicenseTracker eg

Code:
AuthenticatedLicenseParameters parameters = new AuthenticatedLicenseParameters();
using (XmlTextReader reader = new XmlTextReader(fileName))
{
    parameters.Read(reader);
}

AuthenticatedLicenseProvider provider = new AuthenticatedLicenseProvider(parameters, null);
string key = provider.GenerateKey(productInfo, serialNo);


Alternatively you can copy the contents of the .ils file to a string in your code and use the ReadFromString method to initialize the parameters. Your program should increment the serial no that it passes to the GenerateKey method each time you generate a new key to ensure that keys are unique.

Note that this method does not insert the license keys into the License Tracker database. If you want to manage the license keys in License Tracker (which you probably will need to if you are using Authenticated Licenses) then you will need to import the license key and sale information using the License Tracker LicenseKey or Sales import mechanism.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Licensing FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group