/** * Returns a reason why the challenge has failed in the past, if returned by the * server. If there are multiple errors, they can be found in * {@link Problem#getSubProblems()}. */ @CheckForNull public Problem getError() { return getJSON().get(KEY_ERROR) .map(it -> it.asProblem(getLocation())) .orElse(null); }
/** * Returns a reason why the challenge has failed in the past, if returned by the * server. If there are multiple errors, they can be found in * {@link Problem#getSubProblems()}. */ @CheckForNull public Problem getError() { return getJSON().get(KEY_ERROR) .map(it -> it.asProblem(getLocation())) .orElse(null); }
@Override protected void setJSON(JSON json) { String type = json.get(KEY_TYPE).asString(); if (!acceptable(type)) { throw new AcmeProtocolException("incompatible type " + type + " for this challenge"); } String loc = json.get(KEY_URL).asString(); if (loc != null && !loc.equals(getLocation().toString())) { throw new AcmeProtocolException("challenge has changed its location"); } super.setJSON(json); }
@Override protected void setJSON(JSON json) { String type = json.get(KEY_TYPE).asString(); if (!acceptable(type)) { throw new AcmeProtocolException("incompatible type " + type + " for this challenge"); } String loc = json.get(KEY_URL).asString(); if (loc != null && !loc.equals(getLocation().toString())) { throw new AcmeProtocolException("challenge has changed its location"); } super.setJSON(json); }
/** * Triggers this {@link Challenge}. The ACME server is requested to validate the * response. Note that the validation is performed asynchronously by the ACME server. * <p> * If this method is invoked a second time, the ACME server is requested to retry the * validation. This can be useful if the client state has changed, for example after a * firewall rule has been updated. */ public void trigger() throws AcmeException { LOG.debug("trigger"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); prepareResponse(claims); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
/** * Triggers this {@link Challenge}. The ACME server is requested to validate the * response. Note that the validation is performed asynchronously by the ACME server. * <p> * If this method is invoked a second time, the ACME server is requested to retry the * validation. This can be useful if the client state has changed, for example after a * firewall rule has been updated. */ public void trigger() throws AcmeException { LOG.debug("trigger"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); prepareResponse(claims); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }