CamelCase JSON keys

pull/55/head
Richard Körber 2017-12-16 11:43:37 +01:00
parent 2ab4038bd5
commit 8c26cf869d
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
22 changed files with 49 additions and 49 deletions

View File

@ -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";

View File

@ -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<String, Object> createExternalAccountBinding(String kid,

View File

@ -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<String> 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();
}
/**

View File

@ -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;

View File

@ -103,7 +103,7 @@ public class Problem implements Serializable {
*/
public List<Problem> getSubProblems() {
return unmodifiableList(
problemJson.get("sub-problems")
problemJson.get("subproblems")
.asArray().stream()
.map(o -> o.asProblem(baseUrl))
.collect(toList())

View File

@ -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;

View File

@ -124,7 +124,7 @@ public class AccountBuilderTest {
assertThat(enforceJwk, is(true));
JSON binding = claims.toJSON()
.get("external-account-binding")
.get("externalAccountBinding")
.required()
.asObject();

View File

@ -146,7 +146,7 @@ public class AccountTest {
@Override
public Collection<URL> getLinks(String relation) {
switch(relation) {
case "terms-of-service": return Arrays.asList(agreementUrl);
case "termsOfService": return Arrays.asList(agreementUrl);
default: return null;
}
}

View File

@ -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<Problem> errors = challenge.getErrors();
assertThat(errors, is(notNullValue()));

View File

@ -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));

View File

@ -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"

View File

@ -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"
}

View File

@ -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"
}

View File

@ -1,5 +1,5 @@
{
"terms-of-service-agreed": true,
"termsOfServiceAgreed": true,
"contact": [
"mailto:foo2@example.com",
"mailto:foo3@example.com"

View File

@ -1,5 +1,5 @@
{
"terms-of-service-agreed": true,
"termsOfServiceAgreed": true,
"contact": [
"mailto:foo@example.com"
]

View File

@ -1,3 +1,3 @@
{
"only-return-existing": true
"onlyReturnExisting": true
}

View File

@ -1,5 +1,5 @@
{
"terms-of-service-agreed": true,
"termsOfServiceAgreed": true,
"contact": [
"mailto:foo@example.com"
]

View File

@ -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\"",

View File

@ -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"
}

View File

@ -3,6 +3,6 @@
"contact": [
"mailto:foo2@example.com"
],
"terms-of-service-agreed": true,
"termsOfServiceAgreed": true,
"orders": "https://example.com/acme/acct/1/orders"
}

View File

@ -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",

View File

@ -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'"
+ "}"));
}