credentials decoder fixes

This commit is contained in:
rdavidek 2026-02-18 14:38:26 +01:00
parent f7da49a36c
commit b77f50c3e3
4 changed files with 29 additions and 17 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ bin
*.zip *.zip
apis apis
tmp tmp
apicurio-migrator.yaml

View File

@ -57,22 +57,33 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget()); TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
ArtifactSearchResults apis = client.searchArtifacts(config.getApicurio().getDefaultApiGroup(), null, null, ArtifactSearchResults apis = client.searchArtifacts(config.getApicurio().getDefaultApiGroup(), null, null,
null, null, SortBy.name, SortOrder.asc, null, null); null, null, SortBy.name, SortOrder.asc, null, 9999);
log.info("Found {} APIs", apis.getCount()); List<SearchedArtifact> sortedArtifacts = apis.getArtifacts().stream()
.sorted(Comparator.comparing(SearchedArtifact::getId))
.collect(Collectors.toList());
log.info("Found {} APIs", sortedArtifacts.size());
int maxThreads = config.getMaxThreads(); int maxThreads = config.getMaxThreads();
ExecutorService executor = Executors.newFixedThreadPool(maxThreads); //ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
for (SearchedArtifact api : apis.getArtifacts()) { int skipCount = 0;
for (SearchedArtifact api : sortedArtifacts) {
final int index = apiCounter.getAndIncrement(); final int index = apiCounter.getAndIncrement();
executor.submit(() -> processApi(api, token, index, apis.getCount())); if (index <= skipCount) {
log.info("Skipping API {} of {}: {}", index, apis.getCount(), api.getName());
continue;
}
//executor.submit(() -> processApi(api, token, index, apis.getCount()));
processApi(api, token, index, apis.getCount());
} }
executor.shutdown(); // executor.shutdown();
if (!executor.awaitTermination(10, TimeUnit.MINUTES)) { // if (!executor.awaitTermination(10, TimeUnit.MINUTES)) {
log.warn("Timeout waiting for API import tasks to finish"); // log.warn("Timeout waiting for API import tasks to finish");
} // }
log.info("Finished processing APIs."); log.info("Finished processing APIs.");
} catch (Exception e) { } catch (Exception e) {
log.error("Error while exporting APIs.", e); log.error("Error while exporting APIs.", e);

View File

@ -202,20 +202,20 @@ public class ApiDefinitionMapper32to45 {
String encodedSecret = production.get("clientSecret").toString(); String encodedSecret = production.get("clientSecret").toString();
production.put("clientSecret", CredentialsDecoder.decodeCredentials(encodedSecret)); production.put("clientSecret", CredentialsDecoder.decodeCredentials(encodedSecret));
} }
if (sandbox != null && sandbox.containsKey("customParameters") && sandbox.get("customParameters") != null) { if (sandbox != null && sandbox.containsKey("customParameters")) {
String customParamsStr = sandbox.get("customParameters").toString();
try { try {
String customParamsStr = sandbox.get("customParameters").toString();
Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class); Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class);
sandbox.put("customParameters", customParams); sandbox.put("customParameters", customParams!=null?customParams:Collections.emptyMap());
} catch (Exception e) { } catch (Exception e) {
sandbox.put("customParameters", Collections.emptyMap()); sandbox.put("customParameters", Collections.emptyMap());
} }
} }
if (production != null && production.containsKey("customParameters") && production.get("customParameters") != null) { if (production != null && production.containsKey("customParameters")) {
String customParamsStr = production.get("customParameters").toString();
try { try {
String customParamsStr = production.get("customParameters").toString();
Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class); Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class);
production.put("customParameters", customParams); production.put("customParameters", customParams!=null?customParams:Collections.emptyMap());
} catch (Exception e) { } catch (Exception e) {
production.put("customParameters", Collections.emptyMap()); production.put("customParameters", Collections.emptyMap());
} }

View File

@ -55,7 +55,7 @@ public class CredentialsDecoder {
return decryptedText; return decryptedText;
} catch (Exception e) { } catch (Exception e) {
log.error("Error decoding credentials: ", e); log.error("Error decoding credentials: ", e);
return null; return credentials; // Return original if decoding fails
} }
} }
} }