Rename respond method to prepareResponse

pull/55/head
Richard Körber 2018-01-14 14:16:29 +01:00
parent 8923e35d21
commit 3f8299c004
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
6 changed files with 22 additions and 22 deletions

View File

@ -40,8 +40,8 @@ import org.slf4j.LoggerFactory;
* that is unknown to acme4j. * that is unknown to acme4j.
* <p> * <p>
* Subclasses must override {@link Challenge#acceptable(String)} so it only accepts the * Subclasses must override {@link Challenge#acceptable(String)} so it only accepts the
* own type. {@link Challenge#respond(JSONBuilder)} should be overridden to put all * own type. {@link Challenge#prepareResponse(JSONBuilder)} should be overridden to put
* required data to the response. * all required data to the response.
*/ */
public class Challenge extends AcmeJsonResource { public class Challenge extends AcmeJsonResource {
private static final long serialVersionUID = 2338794776848388099L; private static final long serialVersionUID = 2338794776848388099L;
@ -142,10 +142,10 @@ public class Challenge extends AcmeJsonResource {
/** /**
* Exports the response state, as preparation for triggering the challenge. * Exports the response state, as preparation for triggering the challenge.
* *
* @param cb * @param response
* {@link JSONBuilder} to copy the response to * {@link JSONBuilder} to write the response to
*/ */
protected void respond(JSONBuilder cb) { protected void prepareResponse(JSONBuilder response) {
// Do nothing here... // Do nothing here...
} }
@ -185,7 +185,7 @@ public class Challenge extends AcmeJsonResource {
LOG.debug("trigger"); LOG.debug("trigger");
try (Connection conn = getSession().provider().connect()) { try (Connection conn = getSession().provider().connect()) {
JSONBuilder claims = new JSONBuilder(); JSONBuilder claims = new JSONBuilder();
respond(claims); prepareResponse(claims);
conn.sendSignedRequest(getLocation(), claims, getSession()); conn.sendSignedRequest(getLocation(), claims, getSession());

View File

@ -47,9 +47,9 @@ public class TokenChallenge extends Challenge {
} }
@Override @Override
protected void respond(JSONBuilder cb) { protected void prepareResponse(JSONBuilder response) {
super.respond(cb); super.prepareResponse(response);
cb.put(KEY_KEY_AUTHORIZATION, getAuthorization()); response.put(KEY_KEY_AUTHORIZATION, getAuthorization());
} }
/** /**

View File

@ -120,16 +120,16 @@ public class ChallengeTest {
} }
/** /**
* Test that {@link Challenge#respond(JSONBuilder)} contains the type. * Test that {@link Challenge#prepareResponse(JSONBuilder)} contains the type.
*/ */
@Test @Test
public void testRespond() throws JoseException { public void testRespond() throws JoseException {
Challenge challenge = new Challenge(session, getJSON("genericChallenge")); Challenge challenge = new Challenge(session, getJSON("genericChallenge"));
JSONBuilder cb = new JSONBuilder(); JSONBuilder response = new JSONBuilder();
challenge.respond(cb); challenge.prepareResponse(response);
assertThat(cb.toString(), sameJSONAs("{}")); assertThat(response.toString(), sameJSONAs("{}"));
} }
/** /**

View File

@ -52,10 +52,10 @@ public class DnsChallengeTest {
assertThat(challenge.getStatus(), is(Status.PENDING)); assertThat(challenge.getStatus(), is(Status.PENDING));
assertThat(challenge.getDigest(), is("rzMmotrIgsithyBYc0vgiLUEEKYx0WetQRgEF2JIozA")); assertThat(challenge.getDigest(), is("rzMmotrIgsithyBYc0vgiLUEEKYx0WetQRgEF2JIozA"));
JSONBuilder cb = new JSONBuilder(); JSONBuilder response = new JSONBuilder();
challenge.respond(cb); challenge.prepareResponse(response);
assertThat(cb.toString(), sameJSONAs("{\"keyAuthorization\"=\"" assertThat(response.toString(), sameJSONAs("{\"keyAuthorization\"=\""
+ KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields()); + KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields());
} }

View File

@ -56,10 +56,10 @@ public class HttpChallengeTest {
assertThat(challenge.getToken(), is(TOKEN)); assertThat(challenge.getToken(), is(TOKEN));
assertThat(challenge.getAuthorization(), is(KEY_AUTHORIZATION)); assertThat(challenge.getAuthorization(), is(KEY_AUTHORIZATION));
JSONBuilder cb = new JSONBuilder(); JSONBuilder response = new JSONBuilder();
challenge.respond(cb); challenge.prepareResponse(response);
assertThat(cb.toString(), sameJSONAs("{\"keyAuthorization\"=\"" assertThat(response.toString(), sameJSONAs("{\"keyAuthorization\"=\""
+ KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields()); + KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields());
} }

View File

@ -53,10 +53,10 @@ public class TlsSni02ChallengeTest {
assertThat(challenge.getSubject(), is("5bf0b9908ed73bc53ed3327afa52f76b.0a4bea00520f0753f42abe0bb39e3ea8.token.acme.invalid")); assertThat(challenge.getSubject(), is("5bf0b9908ed73bc53ed3327afa52f76b.0a4bea00520f0753f42abe0bb39e3ea8.token.acme.invalid"));
assertThat(challenge.getSanB(), is("14e2350a04434f93c2e0b6012968d99d.ed459b6a7a019d9695609b8514f9d63d.ka.acme.invalid")); assertThat(challenge.getSanB(), is("14e2350a04434f93c2e0b6012968d99d.ed459b6a7a019d9695609b8514f9d63d.ka.acme.invalid"));
JSONBuilder cb = new JSONBuilder(); JSONBuilder response = new JSONBuilder();
challenge.respond(cb); challenge.prepareResponse(response);
assertThat(cb.toString(), sameJSONAs("{\"keyAuthorization\"=\"" assertThat(response.toString(), sameJSONAs("{\"keyAuthorization\"=\""
+ KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields()); + KEY_AUTHORIZATION + "\"}").allowingExtraUnexpectedFields());
} }