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 

Authentication Data

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Tue Apr 21, 2015 12:16 pm    Post subject: Authentication Data Reply with quote

I want to include the company name as part of the license, during the license installation process. To do so, I modified the AuthenticatedLicenseInstallForm with an additional text box. My application then reads this text and saves it in a text file. This has worked fine for local licenses, but I don't think that it's adequate for network licenses since the text file would be located in the server.

I believe that either Authentication Data or Product Info would be better for this purpose, but since the company name will be provided by the user during the license installation I don't know how to proceed to include this information in the license. Could you please help? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Apr 21, 2015 10:25 pm    Post subject: Reply with quote

Your current approach will still work for network licenses - however you would need to include the Company Name in the FloatingLicense so that clients can access it. To do this you would modify the FloatingLicense class to add a CompanyName property and modify the LicenseServer.GetLicense method to set the property.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Wed Apr 22, 2015 12:11 pm    Post subject: Reply with quote

Sorry, but I'm a little confused. So, will I still need the text file in the server containing the company name? Is it possible to permanently include this information in the floating license only one time during the authentication process?

I'm not sure of the required modification to the LicenseServer.GetLicense method. Could you please provide some sample code in C#? Thank you.
Back to top
View user's profile Send private message
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Wed Apr 22, 2015 2:19 pm    Post subject: Reply with quote

I think that I figured it out. This is the modified portion of the LicenseServer.GetLicense method:
Code:
if (result == null)
                {
                    int numLicenses = NumFloatingLicenses;
                    if (_activeLicenses.Count >= numLicenses)
                        throw new LicenseLimitException(numLicenses);

                    result = new FloatingLicense(client);
                    _activeLicenses.Add(result);

                    TextReader tr = new StreamReader(companyNameFile);
                    result.CompanyName = tr.ReadLine();
                    tr.Close();
                }

Now it seems that the I will have two cases: the local licenses will continue getting the company name from the text file, but the floating licenses will have the information already embedded in them, so I will have to modify my application for these two cases. Am I missing something here? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Apr 22, 2015 11:03 pm    Post subject: Reply with quote

Quote:
Now it seems that the I will have two cases: the local licenses will continue getting the company name from the text file, but the floating licenses will have the information already embedded in them, so I will have to modify my application for these two cases. Am I missing something here? Thank you.


That's correct.

It is also possible to include the company name in the license file using the ApplicationData mechanism. This allows you to pass data from the application back to the AuthenticationServer when the license is authenticated. If the "Include Application Data in License" option is selected for the Product (in License Tracker) then the Authentication Server will embed this data in the signed license and you can access it via the AuthenticatedLicense.ApplicationData property. To get this to work you would need to derive your own class from AuthenticatedLicenseProvider and override the GetApplicationData() method which returns the application data to be passed to the server. You would change the AuthenticatedLicenseInstallForm to store the company name when it is entered into in a static (shared) variable and then have the GetApplicationData return this variable.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Wed Oct 28, 2015 5:37 pm    Post subject: Reply with quote

Sorry to bring this issue back again, but my implementation above has a bug somewhere and I cannot find it. For some reason the Company Name information gets lost at some point and the application - which works with a network license - doesn't receive it. Instead, it shows the default company name for local licenses.

This is how I modified the LicenseServer.GetLicense method:
Code:
public FloatingLicense GetLicense(string client)
        {
            FloatingLicense result = null;
            lock (this)
            {
                // check for an existing license first
                //
                foreach (FloatingLicense license in _activeLicenses)
                {
                    if (license.Client == client)
                    {
                        result = license;
                        break;
                    }
                }

                // otherwise create a new license if the limit has
                // not been exceeded
                //
                if (result == null)
                {
                    int numLicenses = NumFloatingLicenses;
                    if (_activeLicenses.Count >= numLicenses)
                        throw new LicenseLimitException(numLicenses);

                    result = new FloatingLicense(client);
                    _activeLicenses.Add(result);

                    TextReader tr = new StreamReader(companyNameFile);
                    result.CompanyName = tr.ReadLine();
                    tr.Close();
                }
            }
            return result;
        }

I think that the problem could be in the following code in the Program file of my application:
Code:
if (_floatingLicense != null)
            {
                EntryForm.companyName = _floatingLicense.CompanyName; // reads the company name from the floating license
            }
            Application.Run(new EntryForm());

Not sure if result.companyName in the LicenseServer.GetLicense method is the same as _floatingLicense.CompanyName. Please advise.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Oct 28, 2015 10:59 pm    Post subject: Reply with quote

I'm not sure I can really help debugging this - since it is your modified code. I would run the SampleLicenseService project in the debugger (instead as a service). To do this you need to set the Command line arguments to /r (in the Project properties Debug tab). You then should be able to set a break point in the GetLicense method and check that your CompanyName is being read correctly.

You can debug the client application in a separate instance of Visual Studio and check the CompanyName property in the floatingLicense that the client receives.
_________________
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
Page 1 of 1

 
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