SDKs
...
Tutorials
Best Practices

Local License File

12min
after license activation the sdk creates an encrypted file that contains license information this article provides information about the local license file and data location see also security and cryptographic providers docid\ fumkiwphdwap4of5i6s7q for more information about license encryption and custom license storage docid 5rgmpnpkksypdlzawvlhz for information about alternative ways to save license prerequisites completed the getting started docid\ lsfy9tq3vfq4roow9shkd tutorial, specifically initialized licensemanager (or licensehandler ) with your configuration using the appropriate settings created a licenseid using either licenseid fromkey or licenseid fromuser function, depending on the activation method you prefer implemented basic license management, including license activations, deactivations, and both online and local license checks default data location the location of the license file depends on the operating system in use on windows, the default sdk data location is {systemdrive} /users/{username}/appdata/local/licensespring/{productcode} on linux, the default sdk data location is home/ licensespring/licensespring/{productcode} on macos, the default sdk data location is /library/application support/licensespring/{productcode} to get the location and name of local license file use the following method auto datalocation = licensemanager >datalocation(); auto filename = licensemanager >licensefilename();var path = licensemanager getinstance() datalocation; var name = licensemanager getinstance() licensefilename;let file = manager licensefilemanager = licensemanager(conf) folder path = manager data location() file name = manager license file name() print("data folder path ",folder path) print("data file name ",file name) changing data location using license manager to change the location of local license file, use licensemanager >setdatalocation( l"my/license/path" ); licensemanager >setlicensefilename( l"mylicense lic" );licensemanager getinstance() datalocation = "my/data/location"; licensemanager getinstance() licensefilename = "mylicense lic";manager set data location("my/data/location") manager set license file name("cool name") you can also delete all files created by sdk using the clearlocalstorage method licensemanager >clearlocalstorage();licensemanager getinstance() clearlocalstorage(); swift try manager clearlocalstorage()manager clear local storage() using extended options if preferred, it is also possible to adjust the location of the local license file before the creation of the licensemanager object in the c++ sdk this is possible by constructing the extendedoptions object with the license file path as the lone parameter extendedoptions options = extendedoptions(licensefilepath); alternatively, it is possible to set the license file path after the extendedoptions using the the setlicensefilepath() method as follows options setlicensefilepath(licensefilepath); license file corruption in case the license file gets corrupted during encryption or writing, local license data could be lost to prevent this, you can check if the local license file is corrupted either on every license file write through a flag in extendedoptions , or whenever you want // check if license file is corrupted bool iscorrupted = licensemanager islicensefilecorrupted(); // enable check on every license file write extendedoptions extendedoptions; extendedoptions enablelicensecorruptioncheck( true ); manager is license file corrupted() note this introduces a runtime overhead due to decrypting an encrypted string usage scenarios changing the data location allows to implement different scenarios, making the license file acessible by certain users and applications sharing the license between users the default data location makes the license available for the current user only to make it available for all users of the device, set a path that all users can acess, e g licensemanager >setdatalocation( l"c \users\public\\{product code}" );licensemanager getinstance() datalocation = "c \users\public\\{product code}"; swift configuration licensedirectorypath = url(fileurlwithpath "/users/shared/shared location")manager = licensemanager(conf) manager set data location(f"c \users\public\\{product code}" sharing the license between applications when you have multiple apps that use licensespring, you can provide a single license for all products if the user activates a license for one product, the other apps could access the license without license reactivation to achieve this, make the data location path not product dependent licensemanager >setdatalocation( l"c /users/{username}/appdata/local/licensespring/{companyname}" );licensemanager getinstance() datalocation = "c /users/{username}/appdata/local/licensespring/{companyname}"; swift configuration licensedirectorypath = url(fileurlwithpath "/users/xxx/shared location")manager = licensemanager(conf) manager set data location(f"c /users/{username}/appdata/local/licensespring/{companyname}") note currently license files created by different sdks are not compatible make sure to store the license files created by different sdks separately locallicenseexception will be thrown if the sdk attempts to read a license file created by another sdk it also occurs when the local license file is damaged or cannot be loaded or saved