The Singleton design pattern has been utilized to develop the licensing library. The License class
encompasses all necessary methods and inner classes. The method
License.getLicense().getBuilder()
returns a
Builder
class, which is used to define
the product hash value, license file, license registry location, and any required features.
-
product(String productHashValue)
method requires only one parameter, which is used to
locate your product on the license server. The product hash code can be found on the license
server products page.
-
file(String file)
method defines the license file location for loading and saving. If
not specified, the system will use the current user's home folder with the last eight characters of
the hash code appended. e.g. If product hash code is
94E1B381016BEE2CBC5F644B6F078C28 and username is john default license file location on
Windows will be C:\Users\john\.6F078C28\license.l4j
Default is created as
System.getProperty("user.home") + File.separator + DOT + {last 8 chars of hash code} + File.seperator + license.l4j
-
registry(String windowsRegistryPath)
defines the license data location in registry for
loading and saving on Windows.
If not defined, registry location is not used on Windows. To use the registry it must be defined to
load/save license data. Simply HKEY_CURRENT_USER\SOFTWARE\ location can be used. e.g.
registry("MySoftware\\license")
The license data will be saved then loaded from
registry key
HKEY_CURRENT_USER\SOFTWARE\MySoftware\ with a REG_BINARY value of license
-
feature(String key, Object value, FeatureComparator comparator)
Any feature can be
checked
while validating license. if it matches on the license server, validation will be successful,
otherwise failed. See features page.
-
customFingerprint(String fingerprint)
Any custom-generated hardware fingerprint can be
used to validate the license. This could include a username, hostname, IP address, network block, or
any other unique identifier.
-
usbDongle(String vendorId, String productId, String licenseFileNamePath)
Any brand or
model of USB stick or disk can be used as a USB license dongle. You can optionally restrict usage to
specific USB vendor and product IDs. To identify the USB device, a license file name is required
(any empty file will suffice before validation).
// The only required parameter is product hash code
// given on license server Products page.
// Following is the minimal code to build the
// License instance. Default values for file
// and registry will be used.
License.getInstance().getBuilder()
.product("product-hash-code")
.build();