USB license dongles have long been a reliable method for securing and managing software licenses within the
software industry. These specialized USB sticks function as tangible hardware keys, authenticating software
applications and preventing unauthorized use.
The LICENSE4J licensing library significantly enhances this concept by offering exceptional flexibility: it
allows developers to utilize virtually any brand or model of standard USB stick as a license dongle. This
liberates developers from reliance on proprietary dongles, providing the freedom to select from a vast array of
readily available USB devices.
The LICENSE4J library operates by intelligently detecting key identifiers from the connected USB stick,
including its vendor ID, product ID, and serial number. This capability enables seamless integration of the
chosen USB device into the software licensing workflow, ensuring that only users possessing the correct,
authenticated dongle can access the software. See an example on how to get USB details and use as a license dongle at
github
Implementing this system is remarkably straightforward. Developers simply create an empty file on the designated
USB stick, which serves as a marker for the license validation process. Concurrently, they must define the
corresponding vendor and product IDs within their software during the license validation stage. This streamlined
activation process not only enhances security by tying software access to a physical key but also simplifies
deployment for both developers and end-users. Crucially, no third-party software is required for the detection
of USB stick properties; the LICENSE4J library inherently provides the necessary vendor ID and product ID for
the validation process.
License.getInstance().getBuilder()
.product("product-hash-value")
// null vendor, product id, put an empty file named "license.lic" in the root folder
.usbDongle(null, null, "license.lic")
.build();
System.out.println("name :" + License.getInstance().getSystemInformation().getUSBDongleName());
System.out.println("vendor Id :" + License.getInstance().getSystemInformation().getUSBDongleVendorId());
System.out.println("product Id :" + License.getInstance().getSystemInformation().getUSBDongleProductId());
System.out.println("serial :" + License.getInstance().getSystemInformation().getUSBDongleSerial());
usbDongle
method within the builder
class. Concurrently, you need to define a specific license file name or path that the system will search for on
the detected USB stick or pen drive. This ensures that the license data is correctly associated with and located
on the physical dongle for validation purposes.
String myUSBVendorId = "0951"; // Kingston
String myUSBProductId = "1625"; // DataTraveler
License.getInstance().getBuilder()
.product("product-hash-value")
.usbDongle(myUSBVendorId, myUSBProductId, "license.lic")
.build();
License.getInstance().validate("the license key");