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();
|
Map<String, Object> json = conn.readJsonResponse();
|
||||||
unmarshal(json);
|
unmarshal(json, conn);
|
||||||
|
|
||||||
URI location = conn.getLocation();
|
|
||||||
if (location != null) {
|
|
||||||
setLocation(conn.getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
URI tos = conn.getLink("terms-of-service");
|
|
||||||
if (tos != null) {
|
|
||||||
this.agreement = tos;
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AcmeNetworkException(ex);
|
throw new AcmeNetworkException(ex);
|
||||||
}
|
}
|
||||||
|
@ -269,9 +259,11 @@ public class Registration extends AcmeResource {
|
||||||
*
|
*
|
||||||
* @param json
|
* @param json
|
||||||
* JSON data
|
* JSON data
|
||||||
|
* @param conn
|
||||||
|
* {@link Connection} with headers to be evaluated
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void unmarshal(Map<String, Object> json) {
|
private void unmarshal(Map<String, Object> json, Connection conn) {
|
||||||
if (json.containsKey("agreement")) {
|
if (json.containsKey("agreement")) {
|
||||||
try {
|
try {
|
||||||
this.agreement = new URI((String) json.get("agreement"));
|
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();
|
conn.throwAcmeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
URI location = conn.getLocation();
|
Map<String, Object> json = conn.readJsonResponse();
|
||||||
if (location != null) {
|
unmarshal(json, conn);
|
||||||
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);
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AcmeNetworkException(ex);
|
throw new AcmeNetworkException(ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,6 +308,11 @@ public class RegistrationTest {
|
||||||
return HttpURLConnection.HTTP_ACCEPTED;
|
return HttpURLConnection.HTTP_ACCEPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> readJsonResponse() {
|
||||||
|
return getJsonAsMap("modifyRegistrationResponse");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getLocation() {
|
public URI getLocation() {
|
||||||
return locationUri;
|
return locationUri;
|
||||||
|
|
|
@ -21,6 +21,10 @@ modifyRegistration = \
|
||||||
"agreement":"http://example.com/agreement.pdf",\
|
"agreement":"http://example.com/agreement.pdf",\
|
||||||
"contact":["mailto:foo2@example.com"]}
|
"contact":["mailto:foo2@example.com"]}
|
||||||
|
|
||||||
|
modifyRegistrationResponse = \
|
||||||
|
{"agreement":"http://example.com/agreement.pdf",\
|
||||||
|
"contact":["mailto:foo2@example.com"]}
|
||||||
|
|
||||||
recoverRegistration = \
|
recoverRegistration = \
|
||||||
{"resource":"recover-reg",\
|
{"resource":"recover-reg",\
|
||||||
"method":"contact",\
|
"method":"contact",\
|
||||||
|
|
Loading…
Reference in New Issue