mirror of https://github.com/shred/acme4j
Order returns an error document
parent
4e1d173cc3
commit
c623d72426
|
@ -39,6 +39,7 @@ public class Order extends AcmeResource {
|
|||
private byte[] csr;
|
||||
private Instant notBefore;
|
||||
private Instant notAfter;
|
||||
private Problem error;
|
||||
private List<URL> authorizations;
|
||||
private Certificate certificate;
|
||||
private boolean loaded = false;
|
||||
|
@ -69,6 +70,14 @@ public class Order extends AcmeResource {
|
|||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Problem} document if the order failed.
|
||||
*/
|
||||
public Problem getError() {
|
||||
load();
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the expiry date of the authorization, if set by the server.
|
||||
*/
|
||||
|
@ -163,6 +172,8 @@ public class Order extends AcmeResource {
|
|||
URL certUrl = json.get("certificate").asURL();
|
||||
certificate = certUrl != null ? Certificate.bind(getSession(), certUrl) : null;
|
||||
|
||||
this.error = json.get("error").asProblem();
|
||||
|
||||
this.authorizations = json.get("authorizations").asArray().stream()
|
||||
.map(JSON.Value::asURL)
|
||||
.collect(toList());
|
||||
|
|
|
@ -75,6 +75,10 @@ public class OrderTest {
|
|||
assertThat(order.getCertificate().getLocation(), is(url("https://example.com/acme/cert/1234")));
|
||||
assertThat(order.getCsr(), is(csr));
|
||||
|
||||
assertThat(order.getError(), is(notNullValue()));
|
||||
assertThat(order.getError().getType(), is("urn:ietf:params:acme:error:connection"));
|
||||
assertThat(order.getError().getDetail(), is("connection refused"));
|
||||
|
||||
List<Authorization> auths = order.getAuthorizations();
|
||||
assertThat(auths.size(), is(2));
|
||||
assertThat(auths.stream().map(Authorization::getLocation)::iterator,
|
||||
|
|
|
@ -8,5 +8,9 @@
|
|||
"https://example.com/acme/authz/1234",
|
||||
"https://example.com/acme/authz/2345"
|
||||
],
|
||||
"certificate": "https://example.com/acme/cert/1234"
|
||||
"certificate": "https://example.com/acme/cert/1234",
|
||||
"error": {
|
||||
"type": "urn:ietf:params:acme:error:connection",
|
||||
"detail": "connection refused"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue