From 8c26cf869d072eccd0e64900edf20a4d4abd92da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Sat, 16 Dec 2017 11:43:37 +0100 Subject: [PATCH] CamelCase JSON keys --- .../java/org/shredzone/acme4j/Account.java | 2 +- .../org/shredzone/acme4j/AccountBuilder.java | 8 ++++---- .../java/org/shredzone/acme4j/Metadata.java | 6 +++--- .../main/java/org/shredzone/acme4j/Order.java | 2 +- .../java/org/shredzone/acme4j/Problem.java | 2 +- .../shredzone/acme4j/connector/Resource.java | 12 +++++------ .../shredzone/acme4j/AccountBuilderTest.java | 2 +- .../org/shredzone/acme4j/AccountTest.java | 2 +- .../acme4j/challenge/ChallengeTest.java | 4 ++-- .../acme4j/connector/ResourceTest.java | 12 +++++------ .../src/test/resources/json/directory.json | 20 +++++++++---------- .../test/resources/json/directoryNoMeta.json | 6 +++--- .../test/resources/json/finalizeResponse.json | 2 +- .../resources/json/modifyAccountResponse.json | 2 +- .../src/test/resources/json/newAccount.json | 2 +- .../json/newAccountOnlyExisting.json | 2 +- .../resources/json/newAccountResponse.json | 2 +- .../src/test/resources/json/problem.json | 2 +- .../resources/json/requestOrderResponse.json | 2 +- .../resources/json/updateAccountResponse.json | 2 +- .../resources/json/updateOrderResponse.json | 2 +- .../org/shredzone/acme4j/it/SessionIT.java | 2 +- 22 files changed, 49 insertions(+), 49 deletions(-) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Account.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Account.java index 5f13bbed..9de03471 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Account.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Account.java @@ -49,7 +49,7 @@ public class Account extends AcmeResource { private static final long serialVersionUID = 7042863483428051319L; private static final Logger LOG = LoggerFactory.getLogger(Account.class); - private static final String KEY_TOS_AGREED = "terms-of-service-agreed"; + private static final String KEY_TOS_AGREED = "termsOfServiceAgreed"; private static final String KEY_ORDERS = "orders"; private static final String KEY_CONTACT = "contact"; private static final String KEY_STATUS = "status"; diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java b/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java index 0a81a02b..0dc181e8 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java @@ -167,14 +167,14 @@ public class AccountBuilder { claims.put("contact", contacts); } if (termsOfServiceAgreed != null) { - claims.put("terms-of-service-agreed", termsOfServiceAgreed); + claims.put("termsOfServiceAgreed", termsOfServiceAgreed); } if (keyIdentifier != null) { - claims.put("external-account-binding", createExternalAccountBinding( + claims.put("externalAccountBinding", createExternalAccountBinding( keyIdentifier, session.getKeyPair().getPublic(), macKey, resourceUrl)); } if (onlyExisting != null) { - claims.put("only-return-existing", onlyExisting); + claims.put("onlyReturnExisting", onlyExisting); } int resp = conn.sendSignedRequest(resourceUrl, claims, session, true, HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED); @@ -203,7 +203,7 @@ public class AccountBuilder { * @param macKey * {@link SecretKey} to sign the key identifier with * @param resource - * "new-account" resource URL + * "newAccount" resource URL * @return Created JSON structure */ private Map createExternalAccountBinding(String kid, diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Metadata.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Metadata.java index 7f2b42d1..a4005a13 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Metadata.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Metadata.java @@ -44,7 +44,7 @@ public class Metadata { * available. */ public URI getTermsOfService() { - return meta.get("terms-of-service").asURI(); + return meta.get("termsOfService").asURI(); } /** @@ -60,7 +60,7 @@ public class Metadata { * itself for the purposes of CAA record validation. Empty if not available. */ public Collection getCaaIdentities() { - return meta.get("caa-identities").asArray().stream() + return meta.get("caaIdentities").asArray().stream() .map(Value::asString) .collect(toList()); } @@ -69,7 +69,7 @@ public class Metadata { * Returns whether an external account is required by this CA. */ public boolean isExternalAccountRequired() { - return meta.get("external-account-required").orElse(false).asBoolean(); + return meta.get("externalAccountRequired").orElse(false).asBoolean(); } /** diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java index 18137e4f..e622325f 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java @@ -201,7 +201,7 @@ public class Order extends AcmeResource { this.expires = json.get("expires").asInstant(); this.notBefore = json.get("notBefore").asInstant(); this.notAfter = json.get("notAfter").asInstant(); - this.finalizeUrl = json.get("finalizeURL").asURL(); + this.finalizeUrl = json.get("finalize").asURL(); URL certUrl = json.get("certificate").asURL(); certificate = certUrl != null ? Certificate.bind(getSession(), certUrl) : null; diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Problem.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Problem.java index 1389629b..a4e9a0d9 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Problem.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Problem.java @@ -103,7 +103,7 @@ public class Problem implements Serializable { */ public List getSubProblems() { return unmodifiableList( - problemJson.get("sub-problems") + problemJson.get("subproblems") .asArray().stream() .map(o -> o.asProblem(baseUrl)) .collect(toList()) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/connector/Resource.java b/acme4j-client/src/main/java/org/shredzone/acme4j/connector/Resource.java index 00aad5a6..eb709f56 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/connector/Resource.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/connector/Resource.java @@ -18,12 +18,12 @@ package org.shredzone.acme4j.connector; */ public enum Resource { - NEW_NONCE("new-nonce"), - NEW_ACCOUNT("new-account"), - NEW_ORDER("new-order"), - NEW_AUTHZ("new-authz"), - REVOKE_CERT("revoke-cert"), - KEY_CHANGE("key-change"); + NEW_NONCE("newNonce"), + NEW_ACCOUNT("newAccount"), + NEW_ORDER("newOrder"), + NEW_AUTHZ("newAuthz"), + REVOKE_CERT("revokeCert"), + KEY_CHANGE("keyChange"); private final String path; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java index ed1fde52..ceebd4dc 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java @@ -124,7 +124,7 @@ public class AccountBuilderTest { assertThat(enforceJwk, is(true)); JSON binding = claims.toJSON() - .get("external-account-binding") + .get("externalAccountBinding") .required() .asObject(); diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java index 31f63a48..e44d6803 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java @@ -146,7 +146,7 @@ public class AccountTest { @Override public Collection getLinks(String relation) { switch(relation) { - case "terms-of-service": return Arrays.asList(agreementUrl); + case "termsOfService": return Arrays.asList(agreementUrl); default: return null; } } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java index 86a2307b..414174ce 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java @@ -109,8 +109,8 @@ public class ChallengeTest { assertThat(challenge.getValidated(), is(parseTimestamp("2015-12-12T17:19:36.336785823Z"))); assertThat(challenge.getJSON().get("type").asString(), is("generic-01")); assertThat(challenge.getJSON().get("url").asURL(), is(url("http://example.com/challenge/123"))); - assertThat(challenge.getJSON().get("not-present").asString(), is(nullValue())); - assertThat(challenge.getJSON().get("not-present-url").asURL(), is(nullValue())); + assertThat(challenge.getJSON().get("notPresent").asString(), is(nullValue())); + assertThat(challenge.getJSON().get("notPresentUrl").asURL(), is(nullValue())); List errors = challenge.getErrors(); assertThat(errors, is(notNullValue())); diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java index 4383033b..4cc78024 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java @@ -28,12 +28,12 @@ public class ResourceTest { */ @Test public void testPath() { - assertThat(Resource.NEW_NONCE.path(), is("new-nonce")); - assertThat(Resource.NEW_ACCOUNT.path(), is("new-account")); - assertThat(Resource.NEW_ORDER.path(), is("new-order")); - assertThat(Resource.NEW_AUTHZ.path(), is("new-authz")); - assertThat(Resource.REVOKE_CERT.path(), is("revoke-cert")); - assertThat(Resource.KEY_CHANGE.path(), is("key-change")); + assertThat(Resource.NEW_NONCE.path(), is("newNonce")); + assertThat(Resource.NEW_ACCOUNT.path(), is("newAccount")); + assertThat(Resource.NEW_ORDER.path(), is("newOrder")); + assertThat(Resource.NEW_AUTHZ.path(), is("newAuthz")); + assertThat(Resource.REVOKE_CERT.path(), is("revokeCert")); + assertThat(Resource.KEY_CHANGE.path(), is("keyChange")); // fails if there are untested future Resource values assertThat(Resource.values().length, is(6)); diff --git a/acme4j-client/src/test/resources/json/directory.json b/acme4j-client/src/test/resources/json/directory.json index fea8bdb9..68650945 100644 --- a/acme4j-client/src/test/resources/json/directory.json +++ b/acme4j-client/src/test/resources/json/directory.json @@ -1,18 +1,18 @@ { - "new-nonce": "https://example.com/acme/new-nonce", - "new-account": "https://example.com/acme/new-account", - "new-order": "https://example.com/acme/new-order" - "new-authz": "https://example.com/acme/new-authz", + "newNonce": "https://example.com/acme/new-nonce", + "newAccount": "https://example.com/acme/new-account", + "newOrder": "https://example.com/acme/new-order" + "newAuthz": "https://example.com/acme/new-authz", "meta": { - "terms-of-service": "https://example.com/acme/terms", + "termsOfService": "https://example.com/acme/terms", "website": "https://www.example.com/", - "caa-identities": [ + "caaIdentities": [ "example.com" ], - "external-account-required": true, - "x-test-string": "foobar", - "x-test-uri": "https://www.example.org", - "x-test-array": [ + "externalAccountRequired": true, + "xTestString": "foobar", + "xTestUri": "https://www.example.org", + "xTestArray": [ "foo", "bar", "barfoo" diff --git a/acme4j-client/src/test/resources/json/directoryNoMeta.json b/acme4j-client/src/test/resources/json/directoryNoMeta.json index 15c597ac..4393d34c 100644 --- a/acme4j-client/src/test/resources/json/directoryNoMeta.json +++ b/acme4j-client/src/test/resources/json/directoryNoMeta.json @@ -1,5 +1,5 @@ { - "new-account": "https://example.com/acme/new-account", - "new-authz": "https://example.com/acme/new-authz", - "new-order": "https://example.com/acme/new-order" + "newAccount": "https://example.com/acme/new-account", + "newAuthz": "https://example.com/acme/new-authz", + "newOrder": "https://example.com/acme/new-order" } diff --git a/acme4j-client/src/test/resources/json/finalizeResponse.json b/acme4j-client/src/test/resources/json/finalizeResponse.json index 0f003ca4..a72dbfe9 100644 --- a/acme4j-client/src/test/resources/json/finalizeResponse.json +++ b/acme4j-client/src/test/resources/json/finalizeResponse.json @@ -17,6 +17,6 @@ "https://example.com/acme/authz/1234", "https://example.com/acme/authz/2345" ], - "finalizeURL": "https://example.com/acme/acct/1/order/1/finalize", + "finalize": "https://example.com/acme/acct/1/order/1/finalize", "certificate": "https://example.com/acme/cert/1234" } diff --git a/acme4j-client/src/test/resources/json/modifyAccountResponse.json b/acme4j-client/src/test/resources/json/modifyAccountResponse.json index 1d8b9a53..9520f59c 100644 --- a/acme4j-client/src/test/resources/json/modifyAccountResponse.json +++ b/acme4j-client/src/test/resources/json/modifyAccountResponse.json @@ -1,5 +1,5 @@ { - "terms-of-service-agreed": true, + "termsOfServiceAgreed": true, "contact": [ "mailto:foo2@example.com", "mailto:foo3@example.com" diff --git a/acme4j-client/src/test/resources/json/newAccount.json b/acme4j-client/src/test/resources/json/newAccount.json index 8f018b6c..17f33aef 100644 --- a/acme4j-client/src/test/resources/json/newAccount.json +++ b/acme4j-client/src/test/resources/json/newAccount.json @@ -1,5 +1,5 @@ { - "terms-of-service-agreed": true, + "termsOfServiceAgreed": true, "contact": [ "mailto:foo@example.com" ] diff --git a/acme4j-client/src/test/resources/json/newAccountOnlyExisting.json b/acme4j-client/src/test/resources/json/newAccountOnlyExisting.json index 5c1cb6f4..7fa29dd0 100644 --- a/acme4j-client/src/test/resources/json/newAccountOnlyExisting.json +++ b/acme4j-client/src/test/resources/json/newAccountOnlyExisting.json @@ -1,3 +1,3 @@ { - "only-return-existing": true + "onlyReturnExisting": true } diff --git a/acme4j-client/src/test/resources/json/newAccountResponse.json b/acme4j-client/src/test/resources/json/newAccountResponse.json index 8f018b6c..17f33aef 100644 --- a/acme4j-client/src/test/resources/json/newAccountResponse.json +++ b/acme4j-client/src/test/resources/json/newAccountResponse.json @@ -1,5 +1,5 @@ { - "terms-of-service-agreed": true, + "termsOfServiceAgreed": true, "contact": [ "mailto:foo@example.com" ] diff --git a/acme4j-client/src/test/resources/json/problem.json b/acme4j-client/src/test/resources/json/problem.json index 981dc492..a680103b 100644 --- a/acme4j-client/src/test/resources/json/problem.json +++ b/acme4j-client/src/test/resources/json/problem.json @@ -2,7 +2,7 @@ "type": "urn:ietf:params:acme:error:malformed", "detail": "Some of the identifiers requested were rejected", "instance": "/documents/error.html", - "sub-problems": [ + "subproblems": [ { "type": "urn:ietf:params:acme:error:malformed", "detail": "Invalid underscore in DNS name \"_example.com\"", diff --git a/acme4j-client/src/test/resources/json/requestOrderResponse.json b/acme4j-client/src/test/resources/json/requestOrderResponse.json index b1d92078..09f642a2 100644 --- a/acme4j-client/src/test/resources/json/requestOrderResponse.json +++ b/acme4j-client/src/test/resources/json/requestOrderResponse.json @@ -29,5 +29,5 @@ "https://example.com/acme/authz/1234", "https://example.com/acme/authz/2345" ], - "finalizeURL": "https://example.com/acme/acct/1/order/1/finalize" + "finalize": "https://example.com/acme/acct/1/order/1/finalize" } diff --git a/acme4j-client/src/test/resources/json/updateAccountResponse.json b/acme4j-client/src/test/resources/json/updateAccountResponse.json index 06830820..97dfbe82 100644 --- a/acme4j-client/src/test/resources/json/updateAccountResponse.json +++ b/acme4j-client/src/test/resources/json/updateAccountResponse.json @@ -3,6 +3,6 @@ "contact": [ "mailto:foo2@example.com" ], - "terms-of-service-agreed": true, + "termsOfServiceAgreed": true, "orders": "https://example.com/acme/acct/1/orders" } diff --git a/acme4j-client/src/test/resources/json/updateOrderResponse.json b/acme4j-client/src/test/resources/json/updateOrderResponse.json index d3eec3cd..d0d0c75d 100644 --- a/acme4j-client/src/test/resources/json/updateOrderResponse.json +++ b/acme4j-client/src/test/resources/json/updateOrderResponse.json @@ -17,7 +17,7 @@ "https://example.com/acme/authz/1234", "https://example.com/acme/authz/2345" ], - "finalizeURL": "https://example.com/acme/acct/1/order/1/finalize", + "finalize": "https://example.com/acme/acct/1/order/1/finalize", "certificate": "https://example.com/acme/cert/1234", "error": { "type": "urn:ietf:params:acme:error:connection", diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/SessionIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/SessionIT.java index c50b8284..f3fda030 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/SessionIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/SessionIT.java @@ -68,7 +68,7 @@ public class SessionIT extends PebbleITBase { assertThat(meta.getWebsite(), is(nullValue())); assertThat(meta.getCaaIdentities(), is(empty())); assertThat(meta.getJSON().toString(), sameJSONAs("{" - + "'terms-of-service': 'data:text/plain,Do%20what%20thou%20wilt'" + + "'termsOfService': 'data:text/plain,Do%20what%20thou%20wilt'" + "}")); }