mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
licensere reTry (#5763)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
+31
-5
@@ -480,12 +480,17 @@ public class KeygenLicenseVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean verifyStandardLicense(String licenseKey, LicenseContext context) {
|
private boolean verifyStandardLicense(String licenseKey, LicenseContext context) {
|
||||||
|
int maxRetries = 5;
|
||||||
|
Exception lastException = null;
|
||||||
|
|
||||||
|
for (int attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
log.info("Checking standard license key");
|
log.info("Checking standard license key (attempt {}/{})", attempt, maxRetries);
|
||||||
String machineFingerprint = generateMachineFingerprint();
|
String machineFingerprint = generateMachineFingerprint();
|
||||||
|
|
||||||
// First, try to validate the license
|
// First, try to validate the license
|
||||||
JsonNode validationResponse = validateLicense(licenseKey, machineFingerprint, context);
|
JsonNode validationResponse =
|
||||||
|
validateLicense(licenseKey, machineFingerprint, context);
|
||||||
if (validationResponse != null) {
|
if (validationResponse != null) {
|
||||||
boolean isValid = validationResponse.path("meta").path("valid").asBoolean();
|
boolean isValid = validationResponse.path("meta").path("valid").asBoolean();
|
||||||
String licenseId = validationResponse.path("data").path("id").asText();
|
String licenseId = validationResponse.path("data").path("id").asText();
|
||||||
@@ -499,7 +504,8 @@ public class KeygenLicenseVerifier {
|
|||||||
"License not activated for this machine. Attempting to"
|
"License not activated for this machine. Attempting to"
|
||||||
+ " activate...");
|
+ " activate...");
|
||||||
boolean activated =
|
boolean activated =
|
||||||
activateMachine(licenseKey, licenseId, machineFingerprint, context);
|
activateMachine(
|
||||||
|
licenseKey, licenseId, machineFingerprint, context);
|
||||||
if (activated) {
|
if (activated) {
|
||||||
// Revalidate after activation
|
// Revalidate after activation
|
||||||
validationResponse =
|
validationResponse =
|
||||||
@@ -518,10 +524,30 @@ public class KeygenLicenseVerifier {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error verifying standard license: {}", e.getMessage());
|
lastException = e;
|
||||||
return false;
|
log.error(
|
||||||
|
"Error verifying standard license (attempt {}/{}): {}",
|
||||||
|
attempt,
|
||||||
|
maxRetries,
|
||||||
|
e.getMessage());
|
||||||
|
if (attempt < maxRetries) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000L * attempt);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException(
|
||||||
|
"License verification failed after "
|
||||||
|
+ maxRetries
|
||||||
|
+ " attempts: "
|
||||||
|
+ (lastException != null ? lastException.getMessage() : "unknown error"),
|
||||||
|
lastException);
|
||||||
|
}
|
||||||
|
|
||||||
private JsonNode validateLicense(
|
private JsonNode validateLicense(
|
||||||
String licenseKey, String machineFingerprint, LicenseContext context) throws Exception {
|
String licenseKey, String machineFingerprint, LicenseContext context) throws Exception {
|
||||||
|
|||||||
+7
@@ -55,7 +55,14 @@ public class LicenseKeyChecker {
|
|||||||
|
|
||||||
@Scheduled(initialDelay = 604800000, fixedRate = 604800000) // 7 days in milliseconds
|
@Scheduled(initialDelay = 604800000, fixedRate = 604800000) // 7 days in milliseconds
|
||||||
public void checkLicensePeriodically() {
|
public void checkLicensePeriodically() {
|
||||||
|
try {
|
||||||
evaluateLicense();
|
evaluateLicense();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
log.error(
|
||||||
|
"Periodic license check failed after all retries: {}. Keeping existing license"
|
||||||
|
+ " status.",
|
||||||
|
e.getMessage());
|
||||||
|
}
|
||||||
synchronizeLicenseSettings();
|
synchronizeLicenseSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user