SDKs
Java SDK

Java Advanced Usage

9min

Detecting Virtual Machines

In case your License is using the Prevent virtual machine feature, the Java SDK will try to detect a Virtual Machine (VM) by comparing common VM signatures in hardware components of a node (computer).

In case any of the mentioned components match a VM component signature and the feature is active, the License activation will fail!

If you come across a Virtual Machine that's not properly detected, please submit a ticket with information about the VM used so we can add it to the detector.

Virtual Machines Currently Detected Using the Java SDK

The detection process compares the hardware signatures of the current node (computer) against a list of the following known VM signatures:

bhyve Docker Container FreeBSD Jail KVM LXC Lguest Linux-VServer Microsoft Hyper-V OpenVZ Parallels Project ACRN QEMU QNX Hypervisor VMware Windows Virtual PC Xen/Oracle Virtual Iron VirtualBox

Multiple Licenses on Same Device in LicenseClient

By default, the LicenseManager is used as a singleton - but if there is a need for multiple LicenseManagers, each with it's own configuration - you can use the LicenseManagerFactory to create additional managers or use the singleton like before.

Java


Custom License Storage in License Client

By default the license is stored on the local disk - encrypted when storing. The location of the license can be changed via the Configuration object. A custom LicenseRepository can also be implemented, see sample below:

Java


Implementing Your Own LicenseSpring using LicenseSpring Core

This is possible to do, where you get to reuse most of the DTOs and authorization that was built. Feel free to contact us, if you require help of implementing your own SDK, with the boilerplate and authorization layers already finished.

Forward Proxy

The Java License Client, Floating Client, Proxy Floating and Management SDK - all have support for setting up a forward proxy. Just set the proxyPort and proxyHost fields in any of the configurations to use a forward proxy for your application. You can set just the proxyPort field - this will automatically use "localhost" as the proxyHost.

There is also support for Basic Auth, by setting the proxyUser and proxyPass fields in any of the configurations.

Here is an example setup for the License Client module:

Java


Disable SSL

disableSsl() still uses ssl traffic, it just trusts all certificates



In rare cases, some clients using a forward proxy cannot verify the public certificate of LicenseSpring servers. For these cases, there is an option in the the License Client, Floating Client and Management SDK called disableSsl

Here is an example setup for the License Client module:

Java


Shutdown Scheduled Executors

License Client (LicenseManager), Floating Client (FloatingLicenseService) and Proxy Floating Client (ProxyFloatingService) have the method shutdownScheduler(), which calls shutdownNow() for their scheduled executors. The executors are used in making periodic checks (if it's enabled) and in some cases will leave threads running indefinitely - when no shutdown signal is received.

Offline mode toggle

LicenseManager has the option to dinamically trigger offline/online mode with the method setOfflineMode(boolean) - mentioned here: https://docs.licensespring.com/sdks/java/modules/license-client#NzxDY For detecting if the user has access to internet: The connection type is "com.licensespring.model.exceptions.infrastructure.ConnectionException", with the message: "api.licensespring.com: nodename nor servname provided, or not known" or message "timeout" - depending if the internet was available at some point during app running ("timeout" message if internet was available at some point and later disabled)