mirror of https://github.com/shred/acme4j
Read response after modifying a registration
parent
1adfb8c9df
commit
cb5a853715
|
@ -102,17 +102,7 @@ public class Registration extends AcmeResource {
|
|||
}
|
||||
|
||||
Map<String, Object> json = conn.readJsonResponse();
|
||||
unmarshal(json);
|
||||
|
||||
URI location = conn.getLocation();
|
||||
if (location != null) {
|
||||
setLocation(conn.getLocation());
|
||||
}
|
||||
|
||||
URI tos = conn.getLink("terms-of-service");
|
||||
if (tos != null) {
|
||||
this.agreement = tos;
|
||||
}
|
||||
unmarshal(json, conn);
|
||||
} catch (IOException ex) {
|
||||
throw new AcmeNetworkException(ex);
|
||||
}
|
||||
|
@ -269,9 +259,11 @@ public class Registration extends AcmeResource {
|
|||
*
|
||||
* @param json
|
||||
* JSON data
|
||||
* @param conn
|
||||
* {@link Connection} with headers to be evaluated
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void unmarshal(Map<String, Object> json) {
|
||||
private void unmarshal(Map<String, Object> json, Connection conn) {
|
||||
if (json.containsKey("agreement")) {
|
||||
try {
|
||||
this.agreement = new URI((String) json.get("agreement"));
|
||||
|
@ -290,6 +282,16 @@ public class Registration extends AcmeResource {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
URI location = conn.getLocation();
|
||||
if (location != null) {
|
||||
setLocation(location);
|
||||
}
|
||||
|
||||
URI tos = conn.getLink("terms-of-service");
|
||||
if (tos != null) {
|
||||
this.agreement = tos;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -376,18 +378,8 @@ public class Registration extends AcmeResource {
|
|||
conn.throwAcmeException();
|
||||
}
|
||||
|
||||
URI location = conn.getLocation();
|
||||
if (location != null) {
|
||||
setLocation(conn.getLocation());
|
||||
}
|
||||
|
||||
URI tos = conn.getLink("terms-of-service");
|
||||
if (tos != null) {
|
||||
Registration.this.agreement = tos;
|
||||
}
|
||||
|
||||
Registration.this.contacts.clear();
|
||||
Registration.this.contacts.addAll(editContacts);
|
||||
Map<String, Object> json = conn.readJsonResponse();
|
||||
unmarshal(json, conn);
|
||||
} catch (IOException ex) {
|
||||
throw new AcmeNetworkException(ex);
|
||||
}
|
||||
|
|
|
@ -308,6 +308,11 @@ public class RegistrationTest {
|
|||
return HttpURLConnection.HTTP_ACCEPTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> readJsonResponse() {
|
||||
return getJsonAsMap("modifyRegistrationResponse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getLocation() {
|
||||
return locationUri;
|
||||
|
|
|
@ -21,6 +21,10 @@ modifyRegistration = \
|
|||
"agreement":"http://example.com/agreement.pdf",\
|
||||
"contact":["mailto:foo2@example.com"]}
|
||||
|
||||
modifyRegistrationResponse = \
|
||||
{"agreement":"http://example.com/agreement.pdf",\
|
||||
"contact":["mailto:foo2@example.com"]}
|
||||
|
||||
recoverRegistration = \
|
||||
{"resource":"recover-reg",\
|
||||
"method":"contact",\
|
||||
|
|
Loading…
Reference in New Issue