diff --git a/cryptea-1.0.0.jar b/cryptea-1.0.0.jar deleted file mode 100644 index b6cc860..0000000 Binary files a/cryptea-1.0.0.jar and /dev/null differ diff --git a/cryptea-tools-1.0.0.jar b/cryptea-tools-1.0.0.jar new file mode 100644 index 0000000..9709fa1 Binary files /dev/null and b/cryptea-tools-1.0.0.jar differ diff --git a/cryptea/src/main/java/tools/cryptea/Certificate.java b/cryptea/src/main/java/tools/cryptea/Certificate.java index 983b360..f2c5a58 100644 --- a/cryptea/src/main/java/tools/cryptea/Certificate.java +++ b/cryptea/src/main/java/tools/cryptea/Certificate.java @@ -33,17 +33,12 @@ import tools.cryptea.utils.Base64Helper; import tools.cryptea.utils.HexHelper; import tools.cryptea.utils.JsonHelper; import tools.jackson.databind.JsonNode; -import tools.jackson.databind.ObjectMapper; -import tools.jackson.databind.node.ObjectNode; public class Certificate { // Url base per verifica public static final String BASE_URL = "https://cryptea.web.francescomancuso.it"; - // per Jackson v3 - private static final ObjectMapper mapper = new ObjectMapper(); - // per richieste HTTP private static final HttpClient CLIENT = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) @@ -236,31 +231,32 @@ public class Certificate { String[] parts = cleaned.split("\\."); if (parts.length < 4) throw new IllegalArgumentException("Formato certificato incompleto"); - return Base64Helper.toString(parts[0]).split("\\|")[1]; + + String id = null; + try { + id = Base64Helper.toString(parts[0]).split("\\|")[1].split("\\=")[1]; + } catch (Exception e) { + throw new IllegalArgumentException("Formato certificato errato"); + } + return id; } /** * Controlla se il certificato รจ stato revocato, attraverso una verifica remota * OCSP (Online Certificate Status Protocol) * - * @param mdex I metadati estratti dal certificato + * @param certId L'ID del certificato estratto * @return Un array, r[0] indica true/false, r[1] l'eventuale motivo di errore * @throws Exception Nella gestione della richiesta HTTP */ public static String[] certificateIsActive(String certId) throws Exception { String[] ret = new String[2]; - ObjectNode json = mapper.createObjectNode(); - json.put("action", "verify_cert"); - json.put("certId", certId); - - String finalJson = JsonHelper.nodeToJson(json); - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI(BASE_URL + "/api/v2/verify")) + .uri(new URI(BASE_URL + "/api/v2/cert/" + certId + "/verify")) .headers("Content-Type", "application/json") .timeout(Duration.ofSeconds(15)) - .POST(HttpRequest.BodyPublishers.ofString(finalJson)) + .GET() .build(); try { @@ -270,10 +266,10 @@ public class Certificate { String status = jsonRes.get("status").asString(); if (status.equals("ok")) { - ret[0] = jsonRes.get("isActive").asString(); + ret[0] = jsonRes.get("content").get("isActive").asString(); } else { ret[0] = "null"; - ret[1] = "Errore nel processo di verifica!"; + ret[1] = jsonRes.get("content").get("reason").asString() + " - Codice di errore: " + jsonRes.get("code").asString(); } } catch (HttpTimeoutException e) {