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

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ bin
/api.yaml
*.zip
apis
tmp
tmp
apicurio-migrator.yaml

View File

@ -57,22 +57,33 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
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);
List<SearchedArtifact> sortedArtifacts = apis.getArtifacts().stream()
.sorted(Comparator.comparing(SearchedArtifact::getId))
.collect(Collectors.toList());
log.info("Found {} APIs", apis.getCount());
log.info("Found {} APIs", sortedArtifacts.size());
int maxThreads = config.getMaxThreads();
ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
//ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
int skipCount = 0;
for (SearchedArtifact api : apis.getArtifacts()) {
for (SearchedArtifact api : sortedArtifacts) {
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();
if (!executor.awaitTermination(10, TimeUnit.MINUTES)) {
log.warn("Timeout waiting for API import tasks to finish");
}
// executor.shutdown();
// if (!executor.awaitTermination(10, TimeUnit.MINUTES)) {
// log.warn("Timeout waiting for API import tasks to finish");
// }
log.info("Finished processing APIs.");
} catch (Exception e) {
log.error("Error while exporting APIs.", e);

View File

@ -202,20 +202,20 @@ public class ApiDefinitionMapper32to45 {
String encodedSecret = production.get("clientSecret").toString();
production.put("clientSecret", CredentialsDecoder.decodeCredentials(encodedSecret));
}
if (sandbox != null && sandbox.containsKey("customParameters") && sandbox.get("customParameters") != null) {
String customParamsStr = sandbox.get("customParameters").toString();
if (sandbox != null && sandbox.containsKey("customParameters")) {
try {
String customParamsStr = sandbox.get("customParameters").toString();
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) {
sandbox.put("customParameters", Collections.emptyMap());
}
}
if (production != null && production.containsKey("customParameters") && production.get("customParameters") != null) {
String customParamsStr = production.get("customParameters").toString();
if (production != null && production.containsKey("customParameters")) {
try {
String customParamsStr = production.get("customParameters").toString();
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) {
production.put("customParameters", Collections.emptyMap());
}

View File

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