Class LicenseService

java.lang.Object
de.bytestore.hostinger.internal.service.LicenseService

@Service @Component public class LicenseService extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Check License on Space if Valid.
    void
    Downloads a license file from the server using the specified UUID and processes it.
    javax0.license3j.License
    generateFile(License databaseIO)
    Generates a License object from a provided License entity.
    Retrieves the expiration date of the license.
    Map<String,javax0.license3j.Feature>
    Retrieves the features associated with the license.
    void
    Retrieve owned Licenses from Space.
    com.google.gson.JsonObject
    Retrieves the license status for the specified UUID from Space.
    int
    Retrieves the limitation value for a certain type of feature based on the license.
    Retrieves the private key from a specified file path and returns it as a PrivateKey object.
    byte[]
    Retrieves the signature associated with the current license.
    Retrieves the UUID associated with the license.
    boolean
    Checks if a license is available.
    boolean
    isAllowed(String typeIO)
    Checks if a certain type of feature is allowed based on the license.
    boolean
    Checks if the license is expired.
    void
    Loads the license file and performs various checks and operations related to the license.
    void
    onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event)
     
    void
    regenerate(License license, io.jmix.core.FileStorage fileStorage)
    Regenerates a license file, writes it to an output stream, and saves it to the provided file storage.
    void
    Renews the license for the current object identified by a UUID.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • onApplicationStarted

      @EventListener public void onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event)
    • getFeatures

      public Map<String,javax0.license3j.Feature> getFeatures()
      Retrieves the features associated with the license.
      Returns:
      A map of feature names to Feature objects.
    • load

      public void load()
      Loads the license file and performs various checks and operations related to the license.
    • getLicenses

      public void getLicenses()
      Retrieve owned Licenses from Space.
    • getLicenseStatus

      public com.google.gson.JsonObject getLicenseStatus(String uuidIO)
      Retrieves the license status for the specified UUID from Space.
      Parameters:
      uuidIO - The UUID of the license.
      Returns:
      The license status as a JsonObject.
    • downloadLicense

      public void downloadLicense(String uuidIO)
      Downloads a license file from the server using the specified UUID and processes it. Validates the checksum from the server against the checksum calculated on the client to ensure file integrity. If the checksum validation passes, the file is saved locally and loaded. Handles potential issues such as missing checksum, checksum mismatch, or failed downloads.
      Parameters:
      uuidIO - The universally unique identifier (UUID) of the license file to be downloaded.
    • hasLicense

      public boolean hasLicense()
      Checks if a license is available.
      Returns:
      true if a license is available, false otherwise.
    • isExpired

      public boolean isExpired()
      Checks if the license is expired.
      Returns:
      true if the license is expired, false otherwise.
    • checkIfValid

      public void checkIfValid()
      Check License on Space if Valid.
    • getPrivateKey

      public PrivateKey getPrivateKey()
      Retrieves the private key from a specified file path and returns it as a PrivateKey object.
      Returns:
      The PrivateKey object representing the retrieved private key.
      Throws:
      RuntimeException - If an IOException, NoSuchAlgorithmException, or InvalidKeySpecException occurs.
    • getUUID

      public UUID getUUID()
      Retrieves the UUID associated with the license.
      Returns:
      The UUID of the license.
    • getSignature

      public byte[] getSignature()
      Retrieves the signature associated with the current license. The signature is returned as a byte array.
      Returns:
      a byte array containing the signature, or null if the licenseIO object is null.
    • getExpire

      public Date getExpire()
      Retrieves the expiration date of the license.
      Returns:
      The expiration date as a Date object.
    • renewLicense

      public void renewLicense()
      Renews the license for the current object identified by a UUID. This method interacts with an external Space service to request a license renewal. It sends an HTTP POST request to the internal license renewal endpoint and handles the HTTP response. If the renewal process encounters any exceptions, it logs the error and generates an audit log entry with a medium security level. Note: This implementation includes a logging statement for debugging purposes, which may need to be removed in the release version. Error scenarios: - If the HTTP request fails or an exception is thrown during the renewal process, an error is logged, and an audit log is created with details for further analysis.
    • isAllowed

      public boolean isAllowed(String typeIO)
      Checks if a certain type of feature is allowed based on the license.
      Parameters:
      typeIO - The type of feature to check (e.g., "cms", "ecommerce", "hosting", "support").
      Returns:
      true if the feature is allowed, false otherwise.
    • getLimitation

      public int getLimitation(String typeIO)
      Retrieves the limitation value for a certain type of feature based on the license.
      Parameters:
      typeIO - The type of feature to retrieve the limitation for (e.g., "cms", "ecommerce", "hosting", "support").
      Returns:
      The limitation value as an integer. Returns 0 if the limitation is not found in the license.
    • generateFile

      public javax0.license3j.License generateFile(License databaseIO)
      Generates a License object from a provided License entity.
      Parameters:
      databaseIO - The License entity to generate the License object from.
      Returns:
      The generated License object.
    • regenerate

      public void regenerate(License license, io.jmix.core.FileStorage fileStorage)
      Regenerates a license file, writes it to an output stream, and saves it to the provided file storage.
      Parameters:
      fileStorage - The storage system to save the newly generated license file.