Return registration status

pull/30/head
Richard Körber 2016-07-07 00:11:26 +02:00
parent 7eb2fe5945
commit 7eec503d55
4 changed files with 16 additions and 2 deletions

View File

@ -49,6 +49,7 @@ public class Registration extends AcmeResource {
private final List<URI> contacts = new ArrayList<>(); private final List<URI> contacts = new ArrayList<>();
private URI agreement; private URI agreement;
private Status status;
/** /**
* Creates a new instance of {@link Registration} and binds it to the {@link Session}. * Creates a new instance of {@link Registration} and binds it to the {@link Session}.
@ -87,6 +88,13 @@ public class Registration extends AcmeResource {
return Collections.unmodifiableList(contacts); return Collections.unmodifiableList(contacts);
} }
/**
* Returns the current status of the registration.
*/
public Status getStatus() {
return status;
}
/** /**
* Updates the registration to the current account status. * Updates the registration to the current account status.
*/ */
@ -283,6 +291,10 @@ public class Registration extends AcmeResource {
} }
} }
if (json.containsKey("status")) {
this.status = Status.parse((String) json.get("status"));
}
URI location = conn.getLocation(); URI location = conn.getLocation();
if (location != null) { if (location != null) {
setLocation(location); setLocation(location);

View File

@ -20,7 +20,7 @@ package org.shredzone.acme4j;
*/ */
public enum Status { public enum Status {
PENDING, PROCESSING, VALID, INVALID, REVOKED, DEACTIVATED, UNKNOWN; PENDING, PROCESSING, VALID, INVALID, REVOKED, DEACTIVATED, GOOD, UNKNOWN;
/** /**
* Parses the string and returns a corresponding Status object. * Parses the string and returns a corresponding Status object.

View File

@ -109,6 +109,7 @@ public class RegistrationTest {
assertThat(registration.getAgreement(), is(agreementUri)); assertThat(registration.getAgreement(), is(agreementUri));
assertThat(registration.getContacts(), hasSize(1)); assertThat(registration.getContacts(), hasSize(1));
assertThat(registration.getContacts().get(0), is(URI.create("mailto:foo2@example.com"))); assertThat(registration.getContacts().get(0), is(URI.create("mailto:foo2@example.com")));
assertThat(registration.getStatus(), is(Status.GOOD));
provider.close(); provider.close();
} }

View File

@ -36,7 +36,8 @@ updateRegistration = \
updateRegistrationResponse = \ updateRegistrationResponse = \
{"agreement":"http://example.com/agreement.pdf",\ {"agreement":"http://example.com/agreement.pdf",\
"contact":["mailto:foo2@example.com"]} "contact":["mailto:foo2@example.com"],\
"status":"good"}
newAuthorizationRequest = \ newAuthorizationRequest = \
{"resource":"new-authz",\ {"resource":"new-authz",\