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 

Clone detection and reauthenticate
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Sat Apr 25, 2015 8:03 pm    Post subject: Clone detection and reauthenticate Reply with quote

How reauthentication (with data) should be done when clone detection has been enabled?

I have tried to StopBackgroundReauthentication(waitForThreadEnd=true) before calling ReauthenticateWithData, but apparently it still causes exceptions with message "The license is no longer authenticated for use on this computer. It has been deactivated or transferred to another computer. Reinstall a license to continue using the software on this computer."

Despite the message, authentication works fine with next start.
Back to top
View user's profile Send private message
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Sun Apr 26, 2015 10:03 pm    Post subject: Reply with quote

Sorry, I found the reason for the exception. I was doing the Reauthenticate for wrong License instance.

I did not yet try to override GetApplicationData for LicenseProvider, I assume that would be better way to send the application data on background?

Though, if application data changes during application runtime, it requires saving/loading the ApplicationData via disk since the data cannot be put to license because it's signature will not be valid? Is there any other way to do this than saving the data to disk?

Thanks in advance.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sun Apr 26, 2015 11:48 pm    Post subject: Reply with quote

If you are using clone detection then you should call the AtomicReauthenticateAndInstallLicense method. This ensures that the license is reauthenticated and saved to file an a single mutex protected indivisible operation. If you just reauthenticate without saving (installing) the license then the Authentication count will be incremented on the server and will no longer match what is saved in the client computer license file - so you will get an error next time the software reauthenticates. If you don't use an atomic operation then there is a (small) possibility that if two instances of your application are run simultaneously that the first instance will update the license file after the second has read it - causing the second instance to get a clone detection error.

If you wish to pass ApplicationData in this scenario then you currently need to override GetApplicationData - since there is not currently a variant of the AtomicReauthenticateAndInstallLicense method that takes application data as a parameter.

If you override GetApplicationData and use background reauthentication then this will automatically update the application data each time the background reauthentication is done (ie you wont actually have to call the AtomicReauthenticateAndInstallLicense method yourself).
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Mon Apr 27, 2015 7:15 am    Post subject: Reply with quote

Infralution wrote:
If you are using clone detection then you should call the AtomicReauthenticateAndInstallLicense method. This ensures that the license is reauthenticated and saved to file an a single mutex protected indivisible operation. If you just reauthenticate without saving (installing) the license then the Authentication count will be incremented on the server and will no longer match what is saved in the client computer license file - so you will get an error next time the software reauthenticates. If you don't use an atomic operation then there is a (small) possibility that if two instances of your application are run simultaneously that the first instance will update the license file after the second has read it - causing the second instance to get a clone detection error.


So - isn't this achieved by stopping the backgroung authentication and then reauthenticating + installing the license? The applicationdata can be sent also. Of course, AtomicReauthenticateAndInstallLicense(WithApplicationData) would be better option. Or even better, somehow indicate backgroundauthentication that it needs to reauthenticate as soon as it can since calling reauthentication might not work due to internet connection etc.

Infralution wrote:
If you override GetApplicationData and use background reauthentication then this will automatically update the application data each time the background reauthentication is done (ie you wont actually have to call the AtomicReauthenticateAndInstallLicense method yourself).


The issue is that if the data is changing over application runtime, it needs to be saved to disk and loaded each time GetApplicationData is run. Otherwise closing the application will delete the data - I did not figure out any way to put the data directly to license ApplicationData property for later reauthentication.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Apr 27, 2015 7:57 am    Post subject: Reply with quote

Quote:
So - isn't this achieved by stopping the backgroung authentication and then reauthenticating + installing the license?


This will work if you can ensure that there is only a single instance of your application running at any given time. Otherwise if there is the possibility of the user starting two instances on the same machine then you run the risk of the second instance getting a false clone detection and disabling the license.

Quote:
The issue is that if the data is changing over application runtime, it needs to be saved to disk and loaded each time GetApplicationData is run. Otherwise closing the application will delete the data - I did not figure out any way to put the data directly to license ApplicationData property for later reauthentication.


I don't quite follow what you are trying to do. Is the ApplicationData something that the user enters? If so you can save the user entered value into a static (shared) property/variable and have the GetApplicationData method return the content of this variable. You can also override GetLicense so that when your code reads the installed license it sets the ApplicationData. For instance:

Code:
using Infralution.Licensing.Forms;
namespace AuthenticatedApp_CS
{
    class MyLicenseProvider : AuthenticatedLicenseProvider
    {
        /// <summary>
        /// The user defined application data
        /// </summary>
        public static string ApplicationData;

        /// <summary>
        /// Return the user set application data
        /// </summary>
        public override string GetApplicationData()
        {
            return ApplicationData;
        }

        /// <summary>
        /// Return the installed license setting the ApplicationData
        /// </summary>
        public override AuthenticatedLicense GetLicense()
        {
            AuthenticatedLicense result = base.GetLicense();
            if (result != null)
            {
                ApplicationData = result.ApplicationData;
            }
            return result;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param>The XML license parameters</param>
        /// <param>The location of the license file</param>
        public MyLicenseProvider(string xmlParameters, string licenseFile)
            : base(xmlParameters, licenseFile)
        {
        }
    }
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Mon Apr 27, 2015 8:17 am    Post subject: Reply with quote

Infralution wrote:
Is the ApplicationData something that the user enters? If so you can save the user entered value into a static (shared) property/variable and have the GetApplicationData method return the content of this variable. You can also override GetLicense so that when your code reads the installed license it sets the ApplicationData.


Yes, the data could be something user can enter. So, when user changes the data, it will be sent on next time background authentication is doing the authentication (e.g. it gets the data via GetApplicationData). However, background authentication is done with certain time interval (once a day by default), which means that closing and starting the application between reauthentication will erase the data (in your example the ApplicationData field). So this scenario needs either ReauthenticateWithData to save the data to license or saving the data to disk for sending it next time background reauthentication is done?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Apr 27, 2015 12:16 pm    Post subject: Reply with quote

With the implementation I gave below you can just set the MyLicenseProvider.ApplicationData property and then call the AtomicReauthenticateAndInstallLicense method. This will pass the changed ApplicationData to the server and install the license with the new ApplicationData.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Mon Apr 27, 2015 12:30 pm    Post subject: Reply with quote

Yes, that would do it. If the internet connection is available. If it's not, I assume that license will not get installed and applicationdata is not updated?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Apr 27, 2015 10:32 pm    Post subject: Reply with quote

Yes that is correct.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Tue Nov 01, 2016 9:51 pm    Post subject: Reply with quote

Infralution wrote:
If you override GetApplicationData and use background reauthentication then this will automatically update the application data each time the background reauthentication is done (ie you wont actually have to call the AtomicReauthenticateAndInstallLicense method yourself).


Old topic, but maybe this is related somehow. We've had now and then mystic license authentication failures - it is coming from BackgroundReauthenticationThread where AtomicBackgroundReauthenticate throws Authenticationexception in Reauthenticate method.

Anyway, this happens with single process so mutex acquiring should not be the fail.

And the error is The license is no longer authenticated for use on this computer. It has been deactivated or transferred to another computer. Reinstall a license to continue using the software on this computer.

Clone detection is on and GetApplicationData is overwritten.

Would you say that by turning off clone detection should cure this or is there possibility that the given error happens for some other reason?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Nov 02, 2016 7:46 am    Post subject: Reply with quote

Clone detection is the most likely reason. The other possible causes of this error are:

1. You have deactivated or deleted the authentication for the computer using License Tracker
2. The customer has deactivated the license themselves (to move the license to a new computer) and then tried to restored the original license on the computer (by restoring to a restore point, resetting a virtual machine back to a checkpoint or by manually copying the license file)

Clone detection can be accidentally triggered by a user if they reset their computer (or virtual machine) to a previous restore point or checkpoint.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Wed Nov 02, 2016 8:05 am    Post subject: Reply with quote

Neither one of the options are valid in my case. The authentication exception was thrown this time on my own computer - while I was not using License Tracker.

Though, in case this might do difference - I was debugging other stuff at the time. I don't know would the background authentication thread have been doing reauthentication at the exact time the debugger interrupted execution. Still, I would not expect that exception be thrown..
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Nov 02, 2016 10:19 am    Post subject: Reply with quote

If your application code is calling one of the non-atomic authentication or reauthentication methods (as described earlier in this thread) while the background reauthentication thread is running then it is possible that you could get this issue. This could be exacerbated if you are debugging. This issue would be due to Clone detection.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
mutex



Joined: 22 Apr 2015
Posts: 19

PostPosted: Wed Nov 02, 2016 2:22 pm    Post subject: Reply with quote

Infralution wrote:
If your application code is calling one of the non-atomic authentication or reauthentication methods (as described earlier in this thread) while the background reauthentication thread is running then it is possible that you could get this issue. This could be exacerbated if you are debugging. This issue would be due to Clone detection.


I have only AtomicReauthenticateAndInstallLicense besides StartBackgroundReauthentication thread which does authentication.

Can you think of any other reason what could cause service to throw this exception or is disabling of clone detection the only option?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Nov 02, 2016 9:56 pm    Post subject: Reply with quote

I can't think of any other cause - but it is a bit difficult because I don't know exactly what you were doing. Can you replicate the issue?
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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