From 28f3710d7318b1767cf530a19e6856ba6d5e3f6a Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 7 Dec 2025 20:40:33 +0100 Subject: [PATCH 1/2] Minor fix --- .../httpServer/httpServer/src/handlers/RequestHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java b/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java index bc002e0..e67b2d1 100644 --- a/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java +++ b/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java @@ -3,6 +3,7 @@ package httpServer.httpServer.src.handlers; import com.fasterxml.jackson.databind.ObjectMapper; import com.sun.net.httpserver.HttpExchange; import common.common.src.html.HtmlManager; +import common.common.src.json.JsonManager; import common.common.src.logger.Logger; import httpServer.httpServer.src.annotations.AllowedVerb; import httpServer.httpServer.src.annotations.OnlyAuthorizedClients; @@ -44,8 +45,7 @@ public class RequestHandler implements IRequestHandler { .lines() .reduce("", (acc, line) -> acc + line + "\n"); - ObjectMapper mapper = new ObjectMapper(); - Client client = mapper.readValue(body, Client.class); + Client client = JsonManager.deserialize(body, Client.class); System.out.println("Received POST data:\n" + body); From a16b24d13326b61d901c375628b29b3a8ffd43f7 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 7 Dec 2025 20:51:30 +0100 Subject: [PATCH 2/2] Give SSLContext to request handler --- src/main/java/httpServer/httpServer/src/Main.java | 2 +- .../httpServer/src/handlers/RequestHandler.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/httpServer/httpServer/src/Main.java b/src/main/java/httpServer/httpServer/src/Main.java index 76c0664..8b3e7b2 100644 --- a/src/main/java/httpServer/httpServer/src/Main.java +++ b/src/main/java/httpServer/httpServer/src/Main.java @@ -47,7 +47,7 @@ public class Main { } }); - IRequestHandler requestHandler = new RequestHandler(); + IRequestHandler requestHandler = new RequestHandler(ctx); IRequestHandler proxy = (IRequestHandler) Proxy.newProxyInstance( requestHandler.getClass().getClassLoader(), diff --git a/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java b/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java index e67b2d1..d359b46 100644 --- a/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java +++ b/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java @@ -10,12 +10,18 @@ import httpServer.httpServer.src.annotations.OnlyAuthorizedClients; import httpServer.httpServer.src.authorization.AuthorizedClients; import httpServer.httpServer.src.authorization.Client; +import javax.net.ssl.SSLContext; import java.io.*; import java.nio.charset.StandardCharsets; public class RequestHandler implements IRequestHandler { - final AuthorizedClients authorizedClients = new AuthorizedClients(); + private final AuthorizedClients authorizedClients = new AuthorizedClients(); + private final SSLContext sslCtx; + + public RequestHandler(SSLContext ctx) { + this.sslCtx = ctx; + } @AllowedVerb(name = "GET") public void handleRoot(HttpExchange exchange) {