diff --git a/src/main/java/httpServer/httpServer/src/Main.java b/src/main/java/httpServer/httpServer/src/Main.java index 6ec5692..58941b8 100644 --- a/src/main/java/httpServer/httpServer/src/Main.java +++ b/src/main/java/httpServer/httpServer/src/Main.java @@ -49,7 +49,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 8291d33..866bfb5 100644 --- a/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java +++ b/src/main/java/httpServer/httpServer/src/handlers/RequestHandler.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; 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 common.common.src.json.JsonManager; import httpServer.httpServer.src.annotations.AllowedVerb; @@ -11,13 +12,19 @@ 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; import java.util.Map; 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) { @@ -73,8 +80,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);