website logo
⌘K
Getting Started
Introduction
Basic Concepts
Opening an Account
Creating & Configuring Products
Integrating SDK and Configuring License Fulfillment
Activate a Key-Based License
Vendor Platform
Issuing New Licenses
License Detail View
Order Detail View
Customer Detail View
Metadata
Analytics
Settings
Product Configuration
Product Features
Product Custom Fields
Product Versioning
License Policies
Product Bundles
License Entitlements
License Types
Activations & Device Transfers
Features
Custom Fields
License Start Date
License Note
Maintenance Period
Trial Licenses
Floating Licenses
License Activation Types
Portals
End-User Portal
Offline Portal
Air-Gapped Portal
License API
License API Authorization
License Activation/Deactivation
License Check
Consumption
Floating
Trial Key
Product Details
Device Variables
Changing Password
Management API
Making API Requests
Management API Authorization
Customer
Product
Order
License
Device
Analytics
SDKs
Tutorials
.NET/C# SDK
.NET/C# Management SDK
C++ SDK
Java SDK
Python SDK
Go SDK
Delphi SDK
Swift/Objective-C SDK
Android SDK
Unity SDK
Errors and Response Codes
Floating Server
API Reference
Deployment
Configuration
Floating Server UI
Securing the Server
Whitelabeling
FAQ
Floating Server Changelog
Integrations
Salesforce
FastSpring
Stripe
Shopify
Common Scenarios
Single Sign On (SSO)
Glossary
General
SDK Glossary
Vendor Platform
Product Configuration Glossary
License Configuration
Postman Collections
Frequently Asked Questions
Changelog
License API changelog
Platform changelog
Docs powered by
Archbee
SDKs
Java SDK

Java Advanced Usage

11min

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
|

// creates a new LicenseManager object, there can be multiple ones using this method
LicenseManager multipleLicences = LicenseManagerFactory.createLicenseManager();

// uses the singleton variant, only 1 manager can be initialized using this method
LicesneManager singleton = LicenseManagerFactory.getLicenseManager();


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
|

// another way to initialize the manager
// is to pass it an additional field which is
// your own implementation of the LicenseRepository interface
public class MyLicenseRepository implements LicenseRepository {
  	void save(License license) {
      	// save the license
    }
 	void delete() {
      	// delete the license 
    }
  	License load() {
		// load the license
    }
  	// add any additional methods you need
}

try {
	licenseManager.initialize(configuration, new MyLicenseRepository());
} catch (LicenseSpringException e) {
    log.error(e.getCause().getMessage());
}


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
|
LicenseSpringConfiguration configuration = LicenseSpringConfiguration.builder()
                        .apiKey("api_key")
                        .productCode("product_code")
                        .sharedKey("shared-key")
						.proxyHost("192.168.0.254")
                        .proxyPort(1337)
  						.proxyUser("SampleUser")
						.proxyPass("SamplePass")
                        .build();


Disable SSL

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
|
LicenseSpringConfiguration configuration = LicenseSpringConfiguration.builder()
                        .apiKey("api_key")
                        .productCode("product_code")
                        .sharedKey("shared-key")
						.disableSsl(true)
                        .build();


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.

Updated 15 Sep 2023
Did this page help you?
PREVIOUS
SDK Distribution and Licensing
NEXT
Python SDK
Docs powered by
Archbee
TABLE OF CONTENTS
Detecting Virtual Machines
Virtual Machines Currently Detected Using the Java SDK
Multiple Licenses on Same Device in LicenseClient
Custom License Storage in License Client
Implementing Your Own LicenseSpring using LicenseSpring Core
Forward Proxy
Disable SSL
Shutdown Scheduled Executors
Docs powered by
Archbee