From e3ff6043df7ff43e6ada0905bdadae2ceb192492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Wed, 16 Dec 2015 00:50:55 +0100 Subject: [PATCH] More debug log output --- .../org/shredzone/acme4j/impl/AbstractAcmeClient.java | 10 ++++++++++ .../org/shredzone/acme4j/impl/DefaultConnection.java | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/AbstractAcmeClient.java b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/AbstractAcmeClient.java index aa9c7d7f..2256f4f1 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/AbstractAcmeClient.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/AbstractAcmeClient.java @@ -31,6 +31,8 @@ import org.shredzone.acme4j.connector.Session; import org.shredzone.acme4j.exception.AcmeException; import org.shredzone.acme4j.exception.AcmeServerException; import org.shredzone.acme4j.util.ClaimBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An abstract implementation of the {@link AcmeClient} interface. It contains abstract @@ -39,6 +41,7 @@ import org.shredzone.acme4j.util.ClaimBuilder; * @author Richard "Shred" Körber */ public abstract class AbstractAcmeClient implements AcmeClient { + private static final Logger LOG = LoggerFactory.getLogger(AbstractAcmeClient.class); private final Session session = new Session(); @@ -70,6 +73,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public void newRegistration(Account account, Registration registration) throws AcmeException { + LOG.debug("newRegistration"); try (Connection conn = createConnection()) { ClaimBuilder claims = new ClaimBuilder(); claims.putResource(Resource.NEW_REG); @@ -94,6 +98,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public void updateRegistration(Account account, Registration registration) throws AcmeException { + LOG.debug("updateRegistration"); if (registration.getLocation() == null) { throw new IllegalArgumentException("location must be set. Use newRegistration() if not known."); } @@ -116,6 +121,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public void newAuthorization(Account account, Authorization auth) throws AcmeException { + LOG.debug("newAuthorization"); try (Connection conn = createConnection()) { ClaimBuilder claims = new ClaimBuilder(); claims.putResource(Resource.NEW_AUTHZ); @@ -163,6 +169,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public void triggerChallenge(Account account, Challenge challenge) throws AcmeException { + LOG.debug("triggerChallenge"); try (Connection conn = createConnection()) { ClaimBuilder claims = new ClaimBuilder(); claims.putResource("challenge"); @@ -176,6 +183,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public void updateChallenge(Account account, Challenge challenge) throws AcmeException { + LOG.debug("updateChallenge"); try (Connection conn = createConnection()) { conn.sendRequest(challenge.getUri()); challenge.unmarshall(conn.readJsonResponse()); @@ -184,6 +192,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public URI requestCertificate(Account account, byte[] csr) throws AcmeException { + LOG.debug("requestCertificate"); try (Connection conn = createConnection()) { ClaimBuilder claims = new ClaimBuilder(); claims.putResource(Resource.NEW_CERT); @@ -200,6 +209,7 @@ public abstract class AbstractAcmeClient implements AcmeClient { @Override public X509Certificate downloadCertificate(URI certUri) throws AcmeException { + LOG.debug("downloadCertificate"); try (Connection conn = createConnection()) { conn.sendRequest(certUri); return conn.readCertificate(); diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java index 037249e5..6a15c348 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java @@ -259,7 +259,9 @@ public class DefaultConnection implements Connection { Matcher m = p.matcher(link); if (m.matches()) { try { - return new URI(m.group(1)); + String location = m.group(1); + LOG.debug("Link: {} -> {}", relation, location); + return new URI(location); } catch (URISyntaxException ex) { throw new AcmeException("Bad Link header: " + link); }