mirror of https://github.com/shred/acme4j
Rename respond method to prepareResponse
parent
8923e35d21
commit
3f8299c004
|
@ -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());
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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("{}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue