From 7d822e106cb02c27a9303d85a1b06ca2af27d154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Wed, 19 Apr 2017 00:48:21 +0200 Subject: [PATCH] Debug output of JWS header, payload and JSON response --- .../acme4j/connector/DefaultConnection.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/connector/DefaultConnection.java b/acme4j-client/src/main/java/org/shredzone/acme4j/connector/DefaultConnection.java index 0004fee8..aa6c2985 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/connector/DefaultConnection.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/connector/DefaultConnection.java @@ -168,8 +168,6 @@ public class DefaultConnection implements Connection { resetNonce(session); } - LOG.debug("POST {} with claims: {}", url, claims); - conn = httpConnector.openConnection(url); conn.setRequestMethod("POST"); conn.setRequestProperty(ACCEPT_HEADER, "application/json"); @@ -188,8 +186,16 @@ public class DefaultConnection implements Connection { } else { jws.getHeaders().setJwkHeaderValue("jwk", jwk); } + jws.setAlgorithmHeaderValue(keyAlgorithm(jwk)); jws.setKey(keypair.getPrivate()); + + if (LOG.isDebugEnabled()) { + LOG.debug("POST {}", url); + LOG.debug(" Payload: {}", claims.toString()); + LOG.debug(" JWS Header: {}", jws.getHeaders().getFullHeaderAsJsonString()); + } + byte[] outputData = jws.getCompactSerialization().getBytes(DEFAULT_CHARSET); conn.setFixedLengthStreamingMode(outputData.length); @@ -248,13 +254,12 @@ public class DefaultConnection implements Connection { JSON result = null; - String response = ""; try { InputStream in = conn.getResponseCode() < 400 ? conn.getInputStream() : conn.getErrorStream(); if (in != null) { result = JSON.parse(in); - LOG.debug("Result JSON: {}", response); + LOG.debug("Result JSON: {}", result.toString()); } } catch (IOException ex) { throw new AcmeNetworkException(ex);