mirror of https://github.com/shred/acme4j
parent
658bfa2cda
commit
7c2c88add0
|
@ -19,6 +19,7 @@ import java.time.Instant;
|
|||
import java.util.Objects;
|
||||
|
||||
import org.shredzone.acme4j.AcmeResource;
|
||||
import org.shredzone.acme4j.Problem;
|
||||
import org.shredzone.acme4j.Session;
|
||||
import org.shredzone.acme4j.Status;
|
||||
import org.shredzone.acme4j.connector.Connection;
|
||||
|
@ -47,6 +48,7 @@ public class Challenge extends AcmeResource {
|
|||
protected static final String KEY_STATUS = "status";
|
||||
protected static final String KEY_URI = "uri";
|
||||
protected static final String KEY_VALIDATED = "validated";
|
||||
protected static final String KEY_ERROR = "error";
|
||||
|
||||
private JSON data = JSON.empty();
|
||||
|
||||
|
@ -117,6 +119,13 @@ public class Challenge extends AcmeResource {
|
|||
return data.get(KEY_VALIDATED).asInstant();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason why the challenge failed, if returned by the server.
|
||||
*/
|
||||
public Problem getError() {
|
||||
return data.get(KEY_ERROR).asProblem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JSON representation of the challenge data.
|
||||
*/
|
||||
|
|
|
@ -113,6 +113,9 @@ public class ChallengeTest {
|
|||
assertThat(challenge.getStatus(), is(Status.VALID));
|
||||
assertThat(challenge.getLocation(), is(new URI("http://example.com/challenge/123")));
|
||||
assertThat(challenge.getValidated(), is(parseTimestamp("2015-12-12T17:19:36.336785823Z")));
|
||||
assertThat(challenge.getError(), is(notNullValue()));
|
||||
assertThat(challenge.getError().getType(), is(URI.create("urn:ietf:params:acme:error:connection")));
|
||||
assertThat(challenge.getError().getDetail(), is("connection refused"));
|
||||
assertThat(challenge.getJSON().get("type").asString(), is("generic-01"));
|
||||
assertThat(challenge.getJSON().get("uri").asURL(), is(new URL("http://example.com/challenge/123")));
|
||||
assertThat(challenge.getJSON().get("not-present").asString(), is(nullValue()));
|
||||
|
|
|
@ -225,7 +225,11 @@ genericChallenge = \
|
|||
"type":"generic-01", \
|
||||
"status":"valid", \
|
||||
"uri":"http://example.com/challenge/123", \
|
||||
"validated":"2015-12-12T17:19:36.336785823Z" \
|
||||
"validated":"2015-12-12T17:19:36.336785823Z", \
|
||||
"error": { \
|
||||
"type": "urn:ietf:params:acme:error:connection", \
|
||||
"detail": "connection refused" \
|
||||
}\
|
||||
}
|
||||
|
||||
httpChallenge = \
|
||||
|
|
Loading…
Reference in New Issue