Package com.seeq.utilities.license
Class LicenseManager
java.lang.Object
com.seeq.utilities.license.LicenseManager
- All Implemented Interfaces:
FileChangeListener
,Closeable
,AutoCloseable
Loads and reports on the current license installed on the machine it is running on. This class will monitor the
license folder for changes and reload licenses appropriately.
The class must be instantiated and then
initialize()
must be called.
Remarks:
This class utilizes the Reprise License Manager (RLM) system to load and validate licenses. Currently, we are using
their free version called RlmEZ. The Seeq-specific public key is compiled directly into a native library called
rlmez1203 (.dll / .so / .jnilib for Windows / Linux / OSX, respectively).
Although RlmEZ has a Java wrapper for loading and validation, it uses JNI to access the aforementioned library and it
is really hard to get Maven to put the native libraries in the right place and have them load correctly in all
scenarios (development, production, IntelliJ etc). So instead we just spawn a subprocess that uses their C++
example client. This will be pretty easy to crack from a pirating standpoint-- just replace the ezclient executable
with something that always reports a valid license. The Java wrapper is not quite as easy to crack-- but it's still
no match for a savvy pirate. If pirating becomes an issue, we'll have to figure out the best course of action... it
may not be obvious.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Called to destroy the LicenseManager and stop all background threads.computeLicense
(Path licenseFolder, Long currentActiveUsers) void
disableFeature
(LicensedFeature.Feature feature) void
enableFeature
(LicensedFeature.Feature feature) Retrieves the current license as read from the license folder.Return the local folder that contains the licensesInitializes the license manager so thatgetCurrentLicense()
can be called.void
onFileDelete
(Path filePath) Called when the file is deleted.void
onFileModify
(Path filePath) Called when the file is modified or created.void
Loads the license file from the location specified in the constructor.
-
Constructor Details
-
LicenseManager
-
-
Method Details
-
getLicenseFolder
Return the local folder that contains the licenses- Returns:
- license folder path
-
getHostName
-
initialize
Initializes the license manager so thatgetCurrentLicense()
can be called. Note that this function returns immediately, but spawns a thread that reads in the license (since ezclient can take over a second to search for a license, and is called once per license level). AFileWatcher
instance is used to detect changes in the license folder. -
close
public void close()Called to destroy the LicenseManager and stop all background threads.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getCurrentLicense
Retrieves the current license as read from the license folder. Note that this function will wait for the file to be read in for the first time, but subsequently will return immediately for all follow-on calls.- Returns:
- the current license
-
onFileModify
Description copied from interface:FileChangeListener
Called when the file is modified or created. While WatchService can emit an ENTRY_CREATE event it is always paired with a ENTRY_MODIFY event and so an onFileCreate method is not provided in order to reduce duplicate messages.- Specified by:
onFileModify
in interfaceFileChangeListener
- Parameters:
filePath
- The file path.
-
onFileDelete
Description copied from interface:FileChangeListener
Called when the file is deleted.- Specified by:
onFileDelete
in interfaceFileChangeListener
- Parameters:
filePath
- The file path.
-
computeLicense
-
readLicense
public void readLicense()Loads the license file from the location specified in the constructor. You can call this function directly if you want to be sure that the latest license has been loaded for subsequent calls togetCurrentLicense()
. -
disableFeature
-
enableFeature
-