Debug output of JWS header, payload and JSON response

pull/55/head
Richard Körber 2017-04-19 00:48:21 +02:00
parent 5de6efce95
commit 7d822e106c
1 changed files with 9 additions and 4 deletions

View File

@ -168,8 +168,6 @@ public class DefaultConnection implements Connection {
resetNonce(session); resetNonce(session);
} }
LOG.debug("POST {} with claims: {}", url, claims);
conn = httpConnector.openConnection(url); conn = httpConnector.openConnection(url);
conn.setRequestMethod("POST"); conn.setRequestMethod("POST");
conn.setRequestProperty(ACCEPT_HEADER, "application/json"); conn.setRequestProperty(ACCEPT_HEADER, "application/json");
@ -188,8 +186,16 @@ public class DefaultConnection implements Connection {
} else { } else {
jws.getHeaders().setJwkHeaderValue("jwk", jwk); jws.getHeaders().setJwkHeaderValue("jwk", jwk);
} }
jws.setAlgorithmHeaderValue(keyAlgorithm(jwk)); jws.setAlgorithmHeaderValue(keyAlgorithm(jwk));
jws.setKey(keypair.getPrivate()); 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); byte[] outputData = jws.getCompactSerialization().getBytes(DEFAULT_CHARSET);
conn.setFixedLengthStreamingMode(outputData.length); conn.setFixedLengthStreamingMode(outputData.length);
@ -248,13 +254,12 @@ public class DefaultConnection implements Connection {
JSON result = null; JSON result = null;
String response = "";
try { try {
InputStream in = InputStream in =
conn.getResponseCode() < 400 ? conn.getInputStream() : conn.getErrorStream(); conn.getResponseCode() < 400 ? conn.getInputStream() : conn.getErrorStream();
if (in != null) { if (in != null) {
result = JSON.parse(in); result = JSON.parse(in);
LOG.debug("Result JSON: {}", response); LOG.debug("Result JSON: {}", result.toString());
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new AcmeNetworkException(ex); throw new AcmeNetworkException(ex);