Skip to content

Commit

Permalink
refactor: strip testCMD class of license-related functionality and de…
Browse files Browse the repository at this point in the history
…pendencies ♻️ 🗑️ 🧹

- Removed constructor with dependencies (`SheftService`, `LicenseService`, `ObjectMapper`)
- Added empty constructor
- Removed all injected services (`sheftService`, `licenseService`, `jacksonObjectMapper`)
- Emptied `run` method, removing license generation and validation logic
- Added unused imports (`InitialSetupMigration`, `AuthorityRepository`)
- Retained unused license-related imports (`LicenseDTO`, `LicenseValidationResult`)
- Simplified class to an empty implementation of `CommandLineRunner`

This change indicates a significant architectural shift or preparation for future implementation.
  • Loading branch information
adelelawady committed Jan 7, 2025
1 parent 0079f3b commit 81efbba
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions src/main/java/com/konsol/core/service/test/testCMD.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.konsol.core.service.test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.konsol.core.config.dbmigrations.InitialSetupMigration;
import com.konsol.core.repository.AuthorityRepository;
import com.konsol.core.service.LicenseService;
import com.konsol.core.service.SheftService;
import com.konsol.core.service.dto.LicenseDTO;
Expand All @@ -15,44 +17,13 @@
public class testCMD implements CommandLineRunner {

private final Logger log = LoggerFactory.getLogger(testCMD.class);
private final SheftService sheftService;
private final LicenseService licenseService;
private final ObjectMapper jacksonObjectMapper;

public testCMD(SheftService sheftService, LicenseService licenseService, ObjectMapper jacksonObjectMapper) {
this.sheftService = sheftService;
this.licenseService = licenseService;
this.jacksonObjectMapper = jacksonObjectMapper;
public testCMD() {

}

@Override
public void run(String... args) throws Exception {
// Generate a new license
// LicenseDTO license = licenseService.generateLicense("clientId", 30);
// log.info("Generated license: {}", license);

// Validate the newly generated license
// LicenseValidationResult result = licenseService.validateLicense(license.getLicenseKey());
// log.info("Validation result for new license: {}", result);

// Try to validate the hardcoded license key

licenseService.generatePublicAndPrivateKeys();

String data = licenseService.createEncryptedAdminKey("ALI ELAWADY", Instant.now().plus(30, java.time.temporal.ChronoUnit.DAYS));

// Decrypt the key
String decryptedJson = licenseService.decryptRSA(data);

// Parse the JSON into AdminLicenseData
// LicenseService.AdminLicenseData licenseData = jacksonObjectMapper.readValue(decryptedJson, LicenseService.AdminLicenseData.class);

System.out.println("EncryptedAdminKey: " + data);
// LicenseDTO licenseDTO= licenseService.processSuperAdminKey(data);

// System.out.println( "LicenseDTO: "+licenseDTO.toString());

// LicenseValidationResult result = licenseService.validateLicense("qO96f9fIOyUqyqp56Ce_npIMdhEI5VP3uA6L1vJSe1Y");
// log.info("Validation result for hardcoded license: {}", result);
}
}

0 comments on commit 81efbba

Please sign in to comment.