licsm - License server

licsm - License server

  licsm 1.0.0 License server runs using SQLITE in ubuntu linux. The following commands are used to install, configure and use licsm.

  USER MANUAL FOR CONFIGURING LICENSE SERVER

    1. Installing dpkg package manager.
        a. Install dpkg package manager if not present.
        sudo apt-get install dpkg

    2. Configuring and installing LicenseServer.
        a. Installing dependencies :
            i. Sqlite : Install sqlite3 using the following command using terminal in VPS / dedicated server.

                sudo apt-get install sqlite3

            ii. Update the linux in Ubuntu.

                sudo apt-get upgrade

            iii. Install the g++ using following command.

                sudo apt-get install build-essential

    3. Install licsm license server.
        a. Installing .deb file : Use following command to install the licsm license server.

        dpkg -i LicenseServer_1.0.0_x64.deb

    4. Configure the License JSON with provided License Key and registered email address.
        a. Run following command in ubuntu terminal in VPS / Dedicated server and fill details asked for (License key and Email address for registering license key). This email address should be same as provided while purchasing license key.

        /opt/LicenseServer/LicenseConfiguration.out

        b. Check if the following file is generated and present in folder before restarting license server.

        /opt/LicenseServer/Configuration.json

    5. Restart the Service RunAutomatically
        a. Check status of service RunAutomatically using the following command.

        systemctl status RunAutomatically

        b. If status is active restart the RunAutomatically service using following command.

        systemctl restart RunAutomatically

        c. If status is inactive start the RunAutomatically service using the following command.

        systemctl start RunAutomatically

    6. Check if need to change permission on /opt/LicenseServer/a.out. If you receive message permission denied while running /opt/LicenseServer/a.out you need to change the permission on the file using following command.

    chmod u+x /opt/LicenseServer/a.out

    7. For Users using MYSQL database, Following settings are mandatory to use the product.

      a. Creating database manually :

        i. Go to VPS Hosting settings and create MYSQL database with username and password. This Database name, Username and password shall be used while running /opt/LicenseServer/LicenseConfiguration.out

      b. Creating database automatically using licsm License manager :

        i. CREATE a new user with all privilages to create and modify database.

        Run MY SQL as root.

        sudo mysql -u root --skip-password

        Run the following command to create new user from root user. Change value of 'new_user' and 'password' in following command.

        CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';

        Run the following command to grant all privilages to the new_user

        GRANT ALL PRIVILEGES ON * . * TO 'new_user'@'localhost';

        Run following command to apply all privilages immediately :

        FLUSH PRIVILEGES;

    8. Keep the System Running

      To make sure that License server service RunAutomatically is running always and never stopped, Create a CRON job in Linux VPS/Dedicated server which runs following bash scripe every 5 or 10 or 15 minutes.

      #!/bin/bash
      if (systemctl -q is-active RunAutomatically.service)
         then
         echo "Application is still running."
         exit 1
         else
         echo "Application is stopped."
         systemctl start RunAutomatically.service
         exit 1
      fi
      exit 0
    9. Allow port 9080 on VPS / Dedicated server.

      i. For making licsm License server to run you must allow port 9080 on the VPS / Dedicated server. This can be done through the panel provided by your VPS / dedicated server provider.


  CLIENT AND VENDOR LIBRARIES FOR C++
  The licsm LicenseServer comes with two libraries for vendor and vendors customers. The vendor library provides API’s for managing licenses by vendor and Client library provides API’s for managing license registration, validation and validity check by application provided to customer from vendor.
  Vendor Library: It provides the following files “LicenseServerClientLib.so”, “LicenseServerClient.so”, “Json.so”, ”LicenseServerClientLib.h”. The API functions that can be used by vendor are following.
  1. Bool Initialize(const char* ip, const char* port, int waitTime).
  This API is used before performing any operation on license server from client or vendor application. This initializes the license server client. The IP should be the dedicated IP of the VPS or dedicated server which hosts license server. port should be 9080. waitTime is ideally 30.

  E.g.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);

  2. Bool InitializeDatabase();
  This is used when first time setting up license server to create sqlite database and configure it. Further operations should be performed only if this API returns true.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  lib.InitializeDatabase();

  3. Bool GenerateLicenses();
  This API is used to generate 10000 licenses in license server which are 25 characters long. It is recommended to use Generate1000Licenses instead to generate 1000 licenses at a time instead of bulk 10000 licenses.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  lib.GenerateLicenses();




  4. Bool Generate1000Licenses();
  This API is used to generate 1000 licenses in license server which are 25 characters long. Further operations on licenses should be performed only after either GenerateLicenses() or Generate1000Licenses() have been performed.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  lib.Generate1000Licenses();


  5. bool Generate1000FloatingLicenses() :
  This API is used to generate 1000 floating licenses which can be used by customers. Each license key generated using Generate1000Licenses() can support 0 to unlimited floating licenses. These floating licenses are not fixed and needs to be generated based on requirement.

  E.g. A customer buys software with 11 floating licenses, then the software vendor needs to generate floating licenses if there are not available 11 floating licenses. These floating licenses are not provided by vendor but when customer registers for floating license these floating licenses are automatically fetched and when customers deregisters a floating license the floating license is automatically released for reuse.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  lib.Generate1000FloatingLicenses();


  6. Bool ConfigurePlan(const char* plan, int numberOfDays, int permission);
  This API is used to configure plan in license server. The numberOfDays is the validity of licenses assigned to this plan and permission defines the permission level associated with the plan. It is recommended to use 365 for 1 year plan and a large integer e.g. 100000 for a lifetime license.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Bool bPlanConfigured = lib.ConfigurePlan(“Silver”,365,0);

  7. Bool RemovePlan(const char* plan);
  This API is used to remove a plan already configured previously with plan name equal to the plan name supplied in this API.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Bool bPlanRemoved = lib.RemovePlan(“Silver”);

  8. Char* AssignLicense(const char* email, const char* plan, bool bFloatingLicense = false, int floating_license_count = 0);
  This API is used to assign license to an email and corresponding plan. It returns the license assigned to email address which can then be supplied to customer as his/her license for software. The Customer application has to finally register this assigned license from their computer.
  The bFloatingLicense parameter tells the license server that this license has associated total floating_license_count floating licenses.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  char* assigned_license = lib.AssignLicense(“xyz@example.com”,”Silver”);
  cout << std::string(assigned_license) << endl;


  Eg. For assigning floating license for this license key. Here the license is associated with 11 floating licenses. 1 Fixed license + 11 floating licenses.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  char* assigned_license = lib.AssignLicense(“xyz@example.com”,”Silver”,”true”,11);
  cout << std::string(assigned_license) << endl;


  9. Char* GetLicense(const char* email);
  This API is used to get all licenses assigned to a particular email address in server.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  char* assigned_licenses = lib.GetLicense(“xyz@example.com”);
  cout << std::string(assigned_licenses) << endl;


  10. Char* GetLicensesExpiring(int numberOfDays);
  This API is used to get licenses expiring within the number of days provided in attribute numberOfDays. It provides a list of licenses.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  char* assigned_licenses = lib.GetLicensesExpiring(40);
  cout << std::string(assigned_licenses) << endl;

  11. Bool RevokeLicense(const char* license);
  This API is used to revoke a license which is already registered by the user.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Bool bRevokeLicense = lib.RevokeLicense(“AAAAABBBBBCCCCCDDDDDEEEEE”);
  cout << bRevokeLicense<< endl;

  12. Bool UnRevokeLicense(const char* license);
  This API is used to un revoke a license which was earlier revoked for some reason by vendor.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Bool bUnRevokeLicense = lib.UnRevokeLicense(“AAAAABBBBBCCCCCDDDDDEEEEE”);
  cout << bUnRevokeLicense<< endl;


  13. Bool IsLicenseRevoked(const char* license);
  This API is used to check if a registered license is revoked.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Bool bIsLicenseRevoked = lib.IsLicenseRevoked(“AAAAABBBBBCCCCCDDDDDEEEEE”);
  cout << bIsLicenseRevoked << endl;

  14. bool SetEncryptionKey(unsigned char encryption_key[16]);
  Before calling any other API the API SetEncryptionKey(…) needs to be called to set the encryption / decryption key. This key should match the key set in licsm License server self hosted server.

  The encryption key is 16 character long key and the encryption used is AES 128.

  Eg.
  LicenseServerClientLib lib(“127.0.0.1”,”9080”);
  //Lib.InitializeDatabase(); -> Use this if database not initialized.
  Unsigned char encryption_key[16]={‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’};
  bool bResult = SetEncryptionKey(encryption_key);

  Customer Library:
  1. Bool Initialize(const char* ip, const char* port)
  This is for initializing the customer library. It should be used before all three following functions.

  2. Bool RegisterLicense(const char* license, const char* macId, const char* email) :
  This API is used for registering licenses in LicenseServer running on VPS / Dedicated server. It should be supplied with license that was returned by vendor library AssignLicense(…), macId which can be mac id of network adapter or hardware id of PC / laptop of customer, email which is email supplied during AssignLicense / purchase of license.

  3. Bool ValidateLicense(const char* license, const char* macId):
  This API validates the license from the LicenseServer running on VPS / Dedicated server. It returns false if license is expired / license is revoked/ license is not yet registered. It returns true if license is valid and is within the validity interval.

  4. Char* GetValidity(const char* license, const char* macId);
  This API returns the validity of license by the date on which the license will expire. It is required to pass the license and macid used in previous steps to get the validity.

Disclaimer