diff --git a/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEAccountService.java b/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEAccountService.java index 38db0b2c3dc..8c9f704cf5e 100644 --- a/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEAccountService.java +++ b/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEAccountService.java @@ -74,33 +74,40 @@ public Response updateAccount(@PathParam("id") String accountID, JWS jws) throws engine.validateJWS(jws, header.getAlg(), account.getJWK()); String payload = new String(jws.getPayloadAsBytes(), "UTF-8"); - logger.info("Payload: " + payload); - ACMEAccount update; - try { - update = ACMEAccount.fromJSON(payload); - } catch (JsonProcessingException e) { - throw engine.createMalformedException(e.toString()); + if (payload.isEmpty()) { + logger.info("Empty payload; treating as POST-as-GET"); } - String newStatus = update.getStatus(); - if (newStatus != null) { - logger.info("New status: " + newStatus); - account.setStatus(newStatus); - } + else { + logger.info("Payload: " + payload); - String[] newContact = update.getContact(); - if (newContact != null) { - logger.info("New contact:"); - for (String c : newContact) { - logger.info("- " + c); + ACMEAccount update; + try { + update = ACMEAccount.fromJSON(payload); + } catch (JsonProcessingException e) { + throw engine.createMalformedException(e.toString()); + } + + String newStatus = update.getStatus(); + if (newStatus != null) { + logger.info("New status: " + newStatus); + account.setStatus(newStatus); + } + + String[] newContact = update.getContact(); + if (newContact != null) { + logger.info("New contact:"); + for (String c : newContact) { + logger.info("- " + c); + } + account.setContact(newContact); } - account.setContact(newContact); - } - engine.updateAccount(account); + engine.updateAccount(account); - // TODO: if account is deactivated, cancel all account's pending operations + // TODO: if account is deactivated, cancel all account's pending operations + } // RFC 8555 Section 7.1.2.1 Orders List //