From 5421a1b1ae05281657608f0e3406ea0b7635fc6f Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 30 Jul 2024 21:43:41 +0200 Subject: [PATCH] Remove maxUses from entities --- .../java/de/licenseapi/entities/License.java | 48 +++++++------------ .../de/licenseapi/entities/LicenseStatus.java | 9 +++- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/integrations/java/src/main/java/de/licenseapi/entities/License.java b/integrations/java/src/main/java/de/licenseapi/entities/License.java index d77b4bc..2fb79ab 100644 --- a/integrations/java/src/main/java/de/licenseapi/entities/License.java +++ b/integrations/java/src/main/java/de/licenseapi/entities/License.java @@ -10,7 +10,6 @@ public class License { private final ArrayList groups; private final ArrayList permissions; private final ArrayList meta; - private final int maxUses; private final int currentUses; private final Date expirationDate; @@ -22,18 +21,16 @@ public class License { * @param groups The groups of the license * @param permissions The permissions of the license * @param meta The meta information of the license - * @param maxUses The maximum amount of uses of the license * @param currentUses The current amount of uses of the license * @param expirationDate The expiration date of the license */ public License(LicenseStatus status, String licenseKey, ArrayList groups, ArrayList permissions, - ArrayList meta, int maxUses, int currentUses, Date expirationDate) { + ArrayList meta, int currentUses, Date expirationDate) { this.status = status; this.licenseKey = licenseKey; this.groups = groups; this.permissions = permissions; this.meta = meta; - this.maxUses = maxUses; this.currentUses = currentUses; this.expirationDate = expirationDate; } @@ -47,7 +44,8 @@ public class License { *
  • {@link LicenseStatus#VALID}
  • *
  • {@link LicenseStatus#EXPIRED}
  • *
  • {@link LicenseStatus#INVALID}
  • - *
  • {@link LicenseStatus#MAX_USES_REACHED}
  • + *
  • {@link LicenseStatus#INVALID_SIGNATURE}
  • + *
  • {@link LicenseStatus#RENEWAL_REQUIRED}
  • * * * @return the status of the license @@ -65,24 +63,6 @@ public class License { return status == LicenseStatus.VALID; } - /** - * Checks if the license has expired - * - * @return {@code true} if the license has expired and {@code false} if not - */ - public boolean isExpired() { - return status == LicenseStatus.EXPIRED; - } - - /** - * Checks if the license has reached the maximum amount of uses (if the maximum amount of uses is set) - * - * @return {@code true} if the license has reached the maximum amount of uses and {@code false} if not - */ - public boolean isMaxUsesReached() { - return status == LicenseStatus.MAX_USES_REACHED; - } - /** * Gets the current license key. If the license key is invalid, this method will return {@code null} * @@ -152,15 +132,6 @@ public class License { return null; } - /** - * Gets the maximum amount of uses of the license. If the maximum amount of uses is not set, this method will return {@code -1} - * - * @return the maximum amount of uses of the license - */ - public int getMaxUses() { - return maxUses; - } - /** * Gets the current amount of uses of the license * @@ -178,4 +149,17 @@ public class License { public Date getExpirationDate() { return expirationDate; } + + @Override + public String toString() { + return "License{" + + "status=" + status + + ", licenseKey='" + licenseKey + '\'' + + ", groups=" + groups + + ", permissions=" + permissions + + ", meta=" + meta + + ", currentUses=" + currentUses + + ", expirationDate=" + expirationDate + + '}'; + } } diff --git a/integrations/java/src/main/java/de/licenseapi/entities/LicenseStatus.java b/integrations/java/src/main/java/de/licenseapi/entities/LicenseStatus.java index 5ed8b22..a8e5ba0 100644 --- a/integrations/java/src/main/java/de/licenseapi/entities/LicenseStatus.java +++ b/integrations/java/src/main/java/de/licenseapi/entities/LicenseStatus.java @@ -18,8 +18,13 @@ public enum LicenseStatus { INVALID, /** - * The provided license key has reached the maximum amount of uses. + * Either the provided public key has been tampered with or the signature is invalid. */ - MAX_USES_REACHED + INVALID_SIGNATURE, + + /** + * The license key is valid, but the license needs to be renewed. + */ + RENEWAL_REQUIRED }