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 

Reauthenticate license with data
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
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Thu Dec 04, 2014 6:54 am    Post subject: Reauthenticate license with data Reply with quote

I have a business situation where solution need to provide us some data after the license has been authenticated. I am thinking to use the AuthenticatedData property so we can monitor data in License Tracker.

I am trying to use the ReauthenticateWithData() method, unfortunately the data not sent to the server when I re-authenticate. Here is my sample code:

Code:

var authenticatedLicense = licenseProvider.ReauthenticateWithData(licenseProvider.GetLicense(), "some data", true);
licenseProvider.InstallLicense(authenticatedLicense);
licenseProvider.WriteLicense(@"c:\temp\test.lic", authenticatedLicense );


Any suggestions or do you have any sample code?

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



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Dec 04, 2014 9:45 pm    Post subject: Reply with quote

I think you might be looking for the data in the wrong place. The data you pass to the ReauthenticateWithData method is ApplicationData (not AuthenticationData). I've just tested the following code in one of the sample projects and it is working without problem:


Code:
_license = _licenseProvider.GetLicense();
if (_license != null)
{
    try
    {
        _licenseProvider.ReauthenticateWithData(_license, "Test Data", false);
    }
    catch (Exception e)
    {
        // do something with the exception
    }
}


The ApplicationData is displayed for the Authentication - so in License Tracker you need to expand the license key and select the Authentication to see the App Data column.

Note that you should add an exception handler around the call to cope with possible web exceptions (due to no internet). Also note that this will block you application running for potentially up to 15 seconds if there is an issue with the internet connection - so it is probably worth considering doing this on a background thread.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Thu Dec 04, 2014 11:00 pm    Post subject: Reply with quote

Thanks for your response. Yes, I can see the App Data in License Tracker when I select a authenticated machine.

Actually, Application data will not be useful in our business logic, we need to set the "Authentication Data". We have a solution which need to be locked to specific accounts name, already using your license system in another product.

Our customer will need to:

- Authenticate key
- Our solution will read "Authentication Data" if any exists
- Customer will enter new accounts name, our solution will update the "Authentication Data" and upload.

Can we update the "Authentication Data" after key authenticated?

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



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Dec 05, 2014 7:04 am    Post subject: Reply with quote

Yes you can update the AuthenticationData using the License Tracker Authentication > Set Authentication Data menu.

If you want to save the reauthenticated license (with updated data) to the license file then you would do something like:

Code:
if (_license != null)
{
    try
    {
        _license = _licenseProvider.ReauthenticateWithData(_license, "Test Data", false);
        if (_license != null)
        {
            _licenseProvider.InstallLicense(_license);
        }
    }
    catch (Exception e)
    {
        // do something with the exception
    }
}

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



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Sun Dec 07, 2014 10:37 pm    Post subject: Reply with quote

Thanks again for your response.

Quote:

Customer will enter new accounts name, our solution will update the "Authentication Data" and upload.


We would like to update the "Authentication Data" from the solution. Is it possible?

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



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sun Dec 07, 2014 10:57 pm    Post subject: Reply with quote

Do you mean you want your application to update the Authentication Data stored in the license?

The license file (including the Authentication Data) is signed by the Authentication Server using a public key signature. This means it can't be changed by the application (or anyone else) without invalidating the signature. If you want to update the Authentication Data then you have to get the server to Reauthenticate the license.

There is a "Include ApplicationData in license" option in License Tracker. If this option is selected then when you Authenticate or Reauthenticate the license and pass ApplicationData then this ApplicationData is included in the signed license returned to the application.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Sun Dec 07, 2014 11:54 pm    Post subject: Reply with quote

Quote:

Do you mean you want your application to update the Authentication Data stored in the license?


Yes

Quote:

There is a "Include ApplicationData in license" option in License Tracker. If this option is selected then when you Authenticate or Reauthenticate the license and pass ApplicationData then this ApplicationData is included in the signed license returned to the application.


Does the ApplicationData specific to machine? For example, Machine1 sets some ApplicationData. When key installed in Machine2, does the Machine1 ApplicationData transmitted to Machine2?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Dec 08, 2014 12:00 am    Post subject: Reply with quote

The application data is specific to each machine - it won't get transmitted from one machine to another using the same key. If you want that then you could purchase the source code for the Authentication Server and modify the source code so that the Application Data provided by the application is used to set the Authentication Data for the license key - and so would be returned when the key is subsequently authenticated on another machine.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Mon Dec 08, 2014 12:14 am    Post subject: Reply with quote

Thanks.

Let me clarify what we trying to achieve, in case you have any recommendations.

We have a product which customer able to purchase for specific accounts, they can install the products to any number of machines but will only operate to specific accounts. We are using in-house developed license file where we hard code the accounts name (customer has to provide account names during purchase process). We are reviewing to use your product so our process can be automated and provide more controls to customer.

Please see below our idea of using your product:

- When we will generate license key, we will only add accounts number customer have purchased in Product Info, for example 3 (3 accounts)
- Customer can use same key to any number of machines but we will only allow to operate accounts number specified in product info.
- Our solution will have option to enter accounts name, it will check how many accounts they have purchased by reading the product information. We may provide options to enter accounts name during or after key authenticated.

Basically we need customer entered accounts name to transmitted to us. Any new machine customer install the key, we will read these accounts name and compare with accounts number in product info. The idea is to give customer more controls to enter accounts name, they won't be able to modify which can be done by us using the License Tracker.

Hope this make sense, thanks
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Dec 08, 2014 1:31 am    Post subject: Reply with quote

Quote:
We are using in-house developed license file where we hard code the accounts name (customer has to provide account names during purchase process).


I assume this is your current process (with a different licensing system). Is that correct? You could implement this same scheme with ILS. You could automatically generate license keys (via our API) and set the Account name in the AuthenticationData or ProductInfo.

Is each installation on a PC for a single account? If so then a simple solution may be to override the GetComputerID function to return the Account name that is configured for that computer. This would let the software be installed multiple machines with that account name but you could limit the number of different accounts that could be installed on different computers.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Mon Dec 08, 2014 4:48 am    Post subject: Reply with quote

Quote:
I assume this is your current process (with a different licensing system). Is that correct?


Yes

Quote:
Is each installation on a PC for a single account? If so then a simple solution may be to override the GetComputerID function to return the Account name that is configured for that computer. This would let the software be installed multiple machines with that account name but you could limit the number of different accounts that could be installed on different computers.


No, one PC can be used for more than one accounts.

For example, in an exchange server have hundreds of accounts. Customer purchase limited accounts license, lets say 3 accounts. Currently customer provide us the 3 accounts name (i.e. Abbott, Rudd, Gillard), we include in license file. Customer can use this license file to any machines and solution will only operate on these specific accounts.


In ILS we can include these accounts name in Product info or Authentication data and the key can be used in any machines.

However, we are considering using ILS to take it a step further where customer don't have to provide us accounts name in advance.

It appear we can only use the product info or authentication data between machines and authentication. Based on your earlier reply, we can only update the product info or authentication data by modifying the Authentication Server server code?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Dec 08, 2014 5:54 am    Post subject: Reply with quote

Quote:
In ILS we can include these accounts name in Product info or Authentication data and the key can be used in any machines.


You should use AuthenticationData not ProductInfo. ProductInfo is encoded into the actual key and will potentially make the key very large. The ProductInfo also can't be changed after a key is generated (whereas authentication data can be).

If you want to automate the changing of the Authentication Data (so that a customer can change which accounts their license is for - without your intervention) then you have two choices:

  • Implement your own web service that allows the user to enter their license key and the accounts they wish to use then the web service uses our Infralution.Licensing.Data API to update the AuthenticationData
  • Use the ApplicationData to transfer the accounts information back to the Authentication Server and modify the Authentication Server source code to update the Authentication Data based on this.


In both cases you will need to validate that the number of accounts is less than that allowed for the key. The second option would be simpler to implement but has the disadvantage that each time we release a software update that you wish to use you will need to reintegrate your modifications.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Mon Dec 08, 2014 7:36 pm    Post subject: Reply with quote

Thanks, we will review your suggestions.
Back to top
View user's profile Send private message
Happs



Joined: 13 Jul 2011
Posts: 62
Location: Sydney, Australia

PostPosted: Tue Dec 09, 2014 12:23 am    Post subject: Reply with quote

Quote:

Use the ApplicationData to transfer the accounts information back to the Authentication Server and modify the Authentication Server source code to update the Authentication Data based on this.


I have access to Authentication Server source and decided to use this approach. Source code looks simple to follow, I have added an overload ReauthenticateWithData() method which takes application data and authentication data. Please see below updated code, thought to ask the expert Smile, do you foresee any issues?

Code:

/// <summary>
/// reauthenticate the given license with application data and authentication data.
/// consumer to this method can use the GetAuthenticationData() to gets existing authentication data prior to update.
/// </summary>
 public virtual AuthenticatedLicense ReauthenticateWithData(AuthenticatedLicense license, string applicationData,
                                                        string authenticationData, bool allowReactivation)
{
    AuthenticatedLicense result = null;
    if (license == null)
        throw new ArgumentNullException("Invalid license");

    AuthenticationService service = new AuthenticationService();

    // Update the authentication data
    service.SetAuthenticationData(_parameters, license.LicenseKey, authenticationData);

    string xml = service.Reauthenticate(_parameters, license.ComputerID, license.LicenseKey, applicationData, allowReactivation);
    if (xml != null)
    {
        result = ReadLicenseFromString(xml);
        ValidateLicense(result);
    }
    return result;
}



Is any there other issues need to keep in mind during building & using modified server code?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Dec 09, 2014 6:54 am    Post subject: Reply with quote

It looks like you are modifying the source code that the application calls to Reauthenticate the license. This won't work unfortunately. The call to AuthenticationService.SetAuthenticationData will fail because the application only has the public key signature parameters and so can not call this method (which requires the private key parameters). This method can only be called by License Tracker which has both the public and private key parameters. You would not normally want the application (ie end user) to be able to set the authentication data - because this would allow them to effectively change their license parameters.

If you have purchased the Authentication Server source code then the AuthenticationService.asmx.cs file has a GetAuthenticationData method which you can change to save the application data into the licenceKey.AuthenticationData and return that. Something like

Code:
private string GetAuthenticationData(Product product,
                                     LicenseKey licenseKey,
                                     string applicationData)
{
    if (!string.IsNullOrEmpty(applicationData))
    {
        licenseKey.AuthenticationData = applicationData;
        licenseKey.Update();
    }
    return licenseKey.AuthenticationData;
}


If the applicationData returned by the application is not empty then it sets that value into the AuthenticationData and returns it.
_________________
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