License File
Last updated
Last updated
License files are a versatile and flexible method for controlling software licenses in disconnected or protected environments where network connectivity to the Babel Licensing Service may not be available. With Babel Licensing, you can generate and utilize license files directly from the Babel User Interface without relying on the Babel Licensing Service for license management. In this introduction, we will explore how to create a license file using the Babel User Interface and how to integrate it into your .NET application for license validation.
To utilize license file functionality in Babel Licensing Service, you need to follow these prerequisites. First, make sure that the Babel Licensing Service is running on your server as per the instructions provided in the section. Then, create a test product and a corresponding template license by referring to the instructions below. This step is essential to establish the foundation for generating license files.
Next, you will need to download the license file client source code from GitHub. This client code enables the integration of license file capabilities into your .NET application. Use the following command to clone the repository:
For this example, the creation of a license file requires the creation of a corresponding license template.
The Babel User Interface provides a user-friendly interface for license management. Through this interface, you can easily create and configure licenses for your applications. When generating a license file, you can specify various details such as the product name, version, expiration date, allowed features, and any custom license fields or features required. The license file is digitally signed to ensure its integrity and authenticity.
To create a license file in the Babel User Interface, follow these steps:
Launch the Babel User Interface and navigate to the Data section.
Click on the "Licenses" link to display the list of existing licenses.
Click on the "New License" button on the grid header to create a new license.
The License fields will automatically populate with the information from the selected template.
In the "Licensing Mode" field, select "File" as the licensing model for the license. The User Key and Allowed Sites will be automatically disabled as they are typically used to interact with the Babel Licensing Service.
Enter the necessary details for the license, such as the licensee information, license fields, allowed features, and expiration date.
Press the Generate button to generate the license, and then save by clicking the "Save" button.
The newly registered license file will now appear in the licenses grid with a unique license key and other relevant information.
Export the license file by pressing the save button on the grid header. The license file should be named ClientFile.licenses or ClientFile.lic.
You can now distribute the license file to your customers or use it to deploy the license in disconnected or protected environments where the Babel Licensing Service is not accessible.
To enable license validation using a license file, you need to integrate the Babel Licensing library into your .NET application. The library provides a set of APIs and methods that facilitate the license validation process. By referencing the Babel Licensing library and incorporating the necessary code, you can ensure that your application validates the license file correctly.
To open the license file console sample project, follow these steps:
Navigate to the location where the license file sample project is stored.
Copy the license file ClientFile.licenses in the project folder.
Double-click on the ClientFile.sln solution file to open it in your preferred Integrated Development Environment (IDE), such as Visual Studio.
After ensuring the correct references, build the solution by selecting the "Build" or "Rebuild" option from the IDE's menu.
Once the solution is successfully built, you can run the application in debug configuration by pressing the "Start Debugging" button or using the keyboard shortcut specific to your IDE (e.g., F5 in Visual Studio).
The license file console sample application will launch, validating the license file and showing the licensee information.
Follow the client application source code:
Inside the static constructor of the Program
class, the file license provider is registered using the BabelFileLicenseProvider
. This provider is responsible for locating and validating the license file for the Program
class. By default, the license file should have the same name as the assembly with the extension .licenses
or .lic
.
In the provided code, the PublicKey
property is used to hold the public key required for validating the license signature. It is set to a specific value extracted from the Keys.snk
file.
To extract the public key from the Keys.snk
file, the code uses the RSASignature.CreateFromKeyFile
method, passing the file name as the parameter. This method creates an RSASignature
object that represents the key pair stored in the Keys.snk
file. Then, the ExportKeys
method is called on the RSASignature
object with the parameter true
to export the public key. This method returns a string representation of the public key.
The use of license files offers flexibility and convenience in scenarios where a network connection to the Babel Licensing Service is not feasible. It allows you to distribute licenses in offline or protected environments while still maintaining control over the licensing terms and compliance. License files can be easily deployed and transferred between systems, making them ideal for use in disconnected or restricted settings.
In conclusion, license files provide an alternative method for managing software licenses in disconnected or protected environments where network connectivity to the Babel Licensing Service is limited. By generating license files through the Babel User Interface and integrating them into your .NET application, you can ensure license compliance, protect your software's integrity, and facilitate licensing in offline or restricted scenarios.
In addition to the BabelFileLicenseProvider, Babel Licensing provides alternative methods for license validation using specific license manager classes. These classes, such as XmlLicenseManager and StringLicenseManager, offer flexibility in handling the loading and validation of license keys without relying on the BabelFileLicenseProvider for finding the license file.
The XmlLicenseManager class is designed to work with XML-based license files. It allows users to set the public key used for validating the license signature and provides methods to read the license key from an XML file, validate it, and retrieve the validated license object.
Here's an expanded explanation of the code snippet provided:
The StringLicenseManager class is another option that allows users to validate license keys directly from an encoded string. This can be useful when the license information is obtained from a different source, such as a database or an API response.
Both the XmlLicenseManager and StringLicenseManager classes provide alternative ways to handle license validation and offer flexibility in controlling the loading and validation process. They allow users to define their own logic for accessing the license key and provide a means to verify the license's authenticity and integrity using the specified public key.
In the License Template combo box, select the appropriate license template (see ).
Once the project is open, ensure that the Babel Licensing client library is referenced correctly. If the reference is missing, please refer to the paragraph to configure a local NuGet repository.