Class LicenseService
java.lang.Object
de.bytestore.hostinger.internal.service.LicenseService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck License on Space if Valid.voiddownloadLicense(String uuidIO) Downloads a license file from the server using the specified UUID and processes it.javax0.license3j.LicensegenerateFile(License databaseIO) Generates a License object from a provided License entity.Retrieves the expiration date of the license.Retrieves the features associated with the license.voidRetrieve owned Licenses from Space.com.google.gson.JsonObjectgetLicenseStatus(String uuidIO) Retrieves the license status for the specified UUID from Space.intgetLimitation(String typeIO) 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.getUUID()Retrieves the UUID associated with the license.booleanChecks if a license is available.booleanChecks if a certain type of feature is allowed based on the license.booleanChecks if the license is expired.voidload()Loads the license file and performs various checks and operations related to the license.voidonApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event) voidregenerate(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.voidRenews the license for the current object identified by a UUID.
-
Constructor Details
-
LicenseService
-
-
Method Details
-
onApplicationStarted
@EventListener public void onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event) -
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
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
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
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
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
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
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
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
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
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.
-