License Validation

This topic describes how to invoke the license validation process and explains how Agile.net searches for a valid license.

Overview

Agile.net Copy Protection protects your software by enforcing one or more locks on a license. The license retrieval process is initiated from within the protected software according to the business model defined. Agile.net doesn't restrict the validation process to occur at load time or at any other time, you may invoke a license request at any time you choose to so.

Invoking a license request

License request invocation is managed through Agile.net licensing API, therefore you must add a reference to AgileDotNet.Licensing assembly to your project. You will also need to add a reference to a file containing public key information used to validate licenses to ensure they have been created by an authorized user and haven't been tampered by a third party. If you develop C# or VB.NET projects you may seamlessly integrate your project with Agile.net Copy Protection using the project wizard, otherwise you would have to manually protect your project.

Once you have added licensing support to your project you should place a call to AgileDotNetLicenseProvider.Validate method, following is an example demonstrating how to do that:

    public class ProtectedComponent
    {
        public ProtectedComponent()
        {
            license = AgileDotNetLicenseProvider.Validate(this.GetType(), this) as AgileDotNetLicense;
        }
 
        public void ProtectedMethod()
        {
            if (license.IsTrial)
            {
               TimeLock tl = license.GetLocks<TimeLock>()[0];
               string message = string.Format("Your evaluation copy will expire in {0} days.", tl.DaysToExpire);
               MessageBox.Show(message);
            }
            else
            {
               MessageBox.Show("This is a commercial copy of a the protected software.");
            }
        }
 
        private AgileDotNetLicense license;
 
    }

Searching for a Valid License

When the AgileDotNetLicenseProvider.Validate method is called, Agile.net start searching for a valid license on the local machine. Licenses are stored as .LIC files which contain one or more license restrictions.

While searching for a license each license is validated to determine if it meets all the required locks defined in the license. Each license can contain one or more locks that define the rights and rules granted to the user. If any of the requirements imposed by a lock are not met then the license is considered invalid and Agile.net will continue looking for another license.

The signature on a license is used to ensure that the license has not been modified and was created using the same keys used to protect the software

Search Folders

Agile.net will search and validate trial licenses only after it didn't find any valid non-trial license. When searching for a license Agile.net checks the following locations and returns the first valid license that it finds:

To specify a folder to search at runtime:

    public class ProtectedComponent
    {
        public ProtectedComponent()
        {
            string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string protectedSoftwareAppDataFolder = Path.Combine(appDataFolder, "ProtectedSoftware");
 
            AgileDotNetLicenseProvider.AddSearchDirectory(protectedSoftwareAppDataFolder);
 
            license = AgileDotNetLicenseProvider.Validate(this.GetType(), this) as AgileDotNetLicense;
        }
 
        private AgileDotNetLicense license;
 
    }

If the license passes all validation checks then a valid license is returned, if a valid license cannot be found then Agile.net throws LicenseNotFoundException exception which can be caught and processed by the protected software. Passing a false value to the allowExceptions parameter will cause the method to return a null value instead of throwing an exception in this case.