Class LicenseManager

java.lang.Object
com.seeq.utilities.license.LicenseManager
All Implemented Interfaces:
FileChangeListener, Closeable, AutoCloseable

public class LicenseManager extends Object implements FileChangeListener, Closeable
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 Details

    • LicenseManager

      public LicenseManager(Configuration configuration)
  • Method Details

    • getLicenseFolder

      public Path getLicenseFolder()
      Return the local folder that contains the licenses
      Returns:
      license folder path
    • getHostName

      public String getHostName()
    • initialize

      public LicenseManager initialize()
      Initializes the license manager so that getCurrentLicense() 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). A FileWatcher 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 interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getCurrentLicense

      public License 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

      public void onFileModify(Path filePath)
      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 interface FileChangeListener
      Parameters:
      filePath - The file path.
    • onFileDelete

      public void onFileDelete(Path filePath)
      Description copied from interface: FileChangeListener
      Called when the file is deleted.
      Specified by:
      onFileDelete in interface FileChangeListener
      Parameters:
      filePath - The file path.
    • computeLicense

      public License computeLicense(Path licenseFolder, Long currentActiveUsers)
    • 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 to getCurrentLicense().
    • disableFeature

      public void disableFeature(LicensedFeature.Feature feature)
    • enableFeature

      public void enableFeature(LicensedFeature.Feature feature)