License Validation and Activation


The core of license management is handled by a single, versatile validate method. This method intelligently adapts its behavior based on its invocation. When a license key is provided as an argument, the method performs a dual function: it simultaneously validates the authenticity of the key and activates the license for the current device. This streamlined approach ensures a seamless initial setup.

Following a successful license validation and activation, the client receives cryptographically encrypted and digitally signed license data directly from the license server. This data, secured with the product's private key on the server, is then automatically saved to the configured persistence location. Depending on your initial setup, this could be either a designated file on the disk or an entry within the Windows Registry. Therefore, when you call the validate method with a license key argument, it not only handles the validation and activation but also seamlessly manages the saving of the activated license data, ensuring it's securely stored for future use.

Implementing the validation of a given license is straightforward, requiring minimal code, as demonstrated below.

// Validate the given license key
License.getInstance()
        .validate("12345-12345-12345-12345") // validate the license key obtained from user


For all subsequent uses of the software, once a license has been activated, the validate method should be called without any arguments. In this scenario, it will automatically load the previously saved license from its persisted location (either disk or the Windows Registry) and perform the necessary validation checks. This allows for effortless re-validation without requiring the user to re-enter their license key, providing a smooth and efficient user experience after the initial setup.

For subsequent license validations, when a license file has already been saved, the process remains equally straightforward, as shown below.
// Validate previously activated license
License.getInstance()
        .validate() // validate previously activated license


Validating Floating Licenses

Validating a floating license on either a SaaS or On-Premises License Server follows the same procedure as a node-locked license key: simply call the validate method with the license key as an argument. However, if the floating license is to be validated against an offline Floating License Server, the validate method should be called without any arguments, but the server's address must be defined using the .server method within the builder. The Floating License Server address must be defined as a URL, with the /fls path appended to the end.

// Validate the given floating license key
// on SaaS license server
License.getInstance()
        .validate("12345-12345-12345-12345") // validate the license key obtained from user


// Validate the given floating license key
// on on-premises license server
License.getInstance().getBuilder()
        .product("product-hash-code") // the only required argument
        .server("https://license.company.com") // if using on-premises license server
        .build();

License.getInstance()
        .validate("12345-12345-12345-12345") // validate the license key obtained from user


Validating Floating Licenses on Floating License Server

To validate a license on a locally installed Floating License Server, you won't use a license key. Instead, you'll need the address of the Floating License Server. The licensing library will use this address to connect and retrieve a license if one is available.

The Floating License Server address URL typically looks something like this: http://server.company.com:16090/fls. The port number can be configured on the Floating License Server. The /fls path is required; it can be added programmatically to the given address.

// Validate/Get a license from Floating License Server
// installed on user's own internal network or servers.
// port 16090 is the default port number for floating license server
// "/fls" path must be added to the URL
License.getInstance().getBuilder()
        .product("product-hash-code") // the only required argument
        .server("https://license.company.com:16090/fls") // if using on-premises license server
        .build();

License.getInstance()
        .validate() // validate without any argument