View previous topic :: View next topic |
Author |
Message |
hakanbondesson
Joined: 09 Aug 2011 Posts: 3
|
Posted: Sat Oct 31, 2015 8:59 am Post subject: Manipulation in license file |
|
|
Hi all,
When attempting to change i.e. the expiry date in the license file, this is detected and throws the below error messge:
Invalid License
the license file contents have been modified and the license is no longer valid. You may need to reinstall the license using the original License Key provided to you when you purchased the product.
I have tried to "catch" this exception so that I could display a different message to the end user, but I'm not able to somehow find this. Is this possible?
When the user is connected to the internet, this is not a problem as we are using the "authenticate" method, so the license is authenticated with the server and the license file is update with correct data, but when ever I simulate that the user is "offline" and have changed the expiry date, the message is displayed but then still allows me to login.
What could be done to prohibit the manipulation with the license file?
Regards,
Hakan |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Nov 01, 2015 10:34 pm Post subject: |
|
|
Are you saying that if the license has expired and you run your application that (although it displays the message) it still allows your application to run?
I think this probably means there is an error in the way you have code your application logic. In the case where the license has expired the LicenseProvider.GetLicense will still return a license object - so it isn't sufficient just to check whether the license is null. Instead you should call LicenseProvider.IsValid(license) to check whether the returned license is valid. Here is what the application logic should look like (from the sample project):
Code: |
_license = _licenseProvider.GetLicense();
// if there is no installed license then display the evaluation dialog until
// the user installs a license or selects Exit or Continue
//
while (!_licenseProvider.IsValid(_license))
{
EvaluationMonitor evaluationMonitor = new RegistryEvaluationMonitor("MyEvaluationPassword");
EvaluationDialog evaluationDialog = new EvaluationDialog();
EvaluationDialogResult dialogResult = evaluationDialog.ShowDialog(evaluationMonitor);
if (dialogResult == EvaluationDialogResult.Exit) return; // exit the app
if (dialogResult == EvaluationDialogResult.Continue) break; // exit the loop
if (dialogResult == EvaluationDialogResult.InstallLicense)
{
AuthenticatedLicenseInstallForm licenseForm = new AuthenticatedLicenseInstallForm();
_license = licenseForm.ShowDialog(_licenseProvider, _license);
}
}
|
This did change in Version 5.8 when expiry dates were introduced. So if your code was written prior to 5.8 and you did not update it to handle expiry dates that may be the problem. _________________ Infralution Support |
|
Back to top |
|
|
hakanbondesson
Joined: 09 Aug 2011 Posts: 3
|
Posted: Mon Nov 02, 2015 8:33 am Post subject: |
|
|
Hi,
I have been testing by going offline (from internet) and modifying the local license file by changing the "Expiry Date" in the file to a future date (even if the license is still valid).
But during this scenario, there is no way to authenticate with our server, so it reads the local file.
So, the program displays the error message :
Invalid License
the license file contents have been modified and the license is no longer valid. You may need to reinstall the license using the original License Key provided to you when you purchased the product.
This is perfect, but we would somehow like to "catch" this exception/message and display our own. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Nov 02, 2015 10:54 am Post subject: |
|
|
If you just want to change the message you can derive your own class from AuthenticatedLicenseProvider and override the ShowInvalidStatusMessage method to handle the case when license.Status is InvalidSignature (call the base class method for all other cases) eg
Code: | public overrides void ShowInvalidStatusMessage(AuthenticatedLicense license)
{
if (license != null && license.Status == AuthenticatedLicenseStatus.InvalidSignature)
{
ShowError(LicenseResources.InvalidLicenseTitle, "My Message");
}
else
{
base.ShowInvalidStatusMessage(license);
}
}
|
_________________ Infralution Support |
|
Back to top |
|
|
|