Class Helpers

java.lang.Object
io.cryptolens.methods.Helpers

public class Helpers extends Object
A collection of helper methods that operate on a license key. If you are using cryptolens-android.jar, please avoid using GetMachineCode and all versions of IsOnRightMachine that do not take in a custom machine code string.
  • Constructor Details

    • Helpers

      public Helpers()
  • Method Details

    • GetMachineCode

      public static String GetMachineCode()
      Returns a unique identifier of the device. Note, root access may be required. Note, this method is not the same as the one used in our .NET client. Also, this method only works on desktop computers. API note: If you do not want to depend on slf4j or if you use the cryptolens-android binary, please call GetMachineCode with v=2.
    • GetMachineCode

      public static String GetMachineCode(int v)
      This method uses a special OS command to find the UUID of the device. In comparison to the default method, GetMachineCode, this method does not depend on slf4j to compute the device fingerprint, assuming that v=2. If v=2, the result of this method should be the same as in the .NET SDK and Python on Windows.

      Note: If it is not possible to retrieve the UUID, this method will return null. Please keep this in mind and check for the null case.

      Parameters:
      v - If set to 2, this method will use the UUID of the device instead of depending on slf4j. Note, it currently only supports Windows. You can read more here: https://help.cryptolens.io/faq/index#java.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, boolean isFloatingLicense)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object.
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, int v)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object.
      v - If set to 2, this method will use the UUID of the device instead of depending on slf4j. Note, it currently only supports Windows. You can read more here: https://help.cryptolens.io/faq/index#java.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, int v, boolean isFloatingLicense)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object.
      v - If set to 2, this method will use the UUID of the device instead of depending on slf4j. Note, it currently only supports Windows. You can read more here: https://help.cryptolens.io/faq/index#java.
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, boolean isFloatingLicense, boolean allowOverdraft)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      allowOverdraft - If floating licensing is enabled with overdraft, this parameter should be set to true. You can enable overdraft by setting ActivateModel.MaxOverdraft" to a value greater than 0.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, int v, boolean isFloatingLicense, boolean allowOverdraft)
      Check if the device is registered with the license key.
      Parameters:
      license - The license key object.
      v - If set to 2, this method will use the UUID of the device instead of depending on slf4j. Note, it currently only supports Windows. You can read more here: https://help.cryptolens.io/faq/index#java.
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      allowOverdraft - If floating licensing is enabled with overdraft, this parameter should be set to true. You can enable overdraft by setting ActivateModel.MaxOverdraft" to a value greater than 0.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, String machineCode)
      Check if the device is registered with the license key. This method is useful for platforms where the GetMachineCode() is not supported, eg. on Android.
      Parameters:
      license - The license key object.
      machineCode - The machine code of the current device.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, String machineCode, boolean isFloatingLicense)
      Check if the device is registered with the license key. This method is useful for platforms where the GetMachineCode() is not supported, eg. on Android.
      Parameters:
      license - The license key object.
      machineCode - The machine code of the current device.
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • IsOnRightMachine

      public static boolean IsOnRightMachine(LicenseKey license, String machineCode, boolean isFloatingLicense, boolean allowOverdraft)
      Check if the device is registered with the license key. This method is useful for platforms where the GetMachineCode() is not supported, eg. on Android.
      Parameters:
      license - The license key object.
      machineCode - The machine code of the current device.
      isFloatingLicense - If this is a floating license, this parameter has to be set to true. You can enable floating licenses by setting @see ActivateModel.FloatingTimeInterval.
      allowOverdraft - If floating licensing is enabled with overdraft, this parameter should be set to true. You can enable overdraft by setting ActivateModel.MaxOverdraft" to a value greater than 0.
      Returns:
      True if the license is registered with this machine and False otherwise.
    • HasExpired

      public static boolean HasExpired(LicenseKey licenseKey)
      Check if the current license has expired.
      Parameters:
      licenseKey - a license key object.
      Returns:
      True if it has expired and false otherwise.
    • HasNotExpired

      public static boolean HasNotExpired(LicenseKey licenseKey)
      Check if the current license has not expired.
      Parameters:
      licenseKey - a license key object.
      Returns:
      True if it has not expired and false otherwise.
    • HasFeature

      public static boolean HasFeature(LicenseKey licenseKey, int feature)
      Check if the license has a certain feature enabled (i.e. set to true).
      Parameters:
      licenseKey - a license key object.
      feature - The feature, eg 1 to 8.
      Returns:
      If the feature is set to true, true is returned and false otherwise.
    • HasFeature

      public static boolean HasFeature(LicenseKey licenseKey, String featureName)

      Uses a special data object associated with the license key to determine if a certain feature exists (instead of the 8 feature flags).

      Formatting: The name of the data object should be 'cryptolens_features' and it should be structured as a JSON array.

      For example,

      ["f1", "f2"]

      means f1 and f2 are true. You can also have feature bundling, eg.

      ["f1", ["f2",["voice","image"]]]

      which means that f1 and f2 are true, as well as f2.limited and f2.image. You can set any depth, eg. you can have

      ["f1", ["f2",[["voice",["all"]], "image"]]]

      means f2.voice.all is true as well as f2.voice and f2. The dots symbol is used to specify the "sub-features".

      Parameters:
      licenseKey - a license key object.
      featureName - the name of the feature (case-sensitive).
      Returns:
      True if the feature exists and false otherwise.
    • SHA256

      public static String SHA256(String rawData)
      Return the sha256 checksum of a string.
    • IsSuccessful

      public static boolean IsSuccessful(BasicResult result)
      Checks if a response from Cryptolens is successful.
      Parameters:
      result - The response from an API call. All responses inherit from BasicResult.
      Returns:
      True if the response is successful and false otherwise.