/** * Reads the next batch of URLs from the server, and fills the queue with the URLs. If * there is a "next" header, it is used for the next batch of URLs. */ private void readAndQueue() throws AcmeException { Session session = login.getSession(); try (Connection conn = session.connect()) { conn.sendSignedPostAsGetRequest(nextUrl, login); JSON json = conn.readJsonResponse(); if (json != null) { fillUrlList(json); } nextUrl = conn.getLinks("next").stream().findFirst().orElse(null); } }
/** * Reads the next batch of URLs from the server, and fills the queue with the URLs. If * there is a "next" header, it is used for the next batch of URLs. */ private void readAndQueue() throws AcmeException { Session session = login.getSession(); try (Connection conn = session.connect()) { conn.sendSignedPostAsGetRequest(nextUrl, login); JSON json = conn.readJsonResponse(); if (json != null) { fillUrlList(json); } nextUrl = conn.getLinks("next").stream().findFirst().orElse(null); } }
/** * Downloads the certificate chain. * <p> * The certificate is downloaded lazily by the other methods. So usually there is no * need to invoke this method, unless the download is to be enforced. If the * certificate has been downloaded already, nothing will happen. * * @throws AcmeException * if the certificate could not be downloaded */ public void download() throws AcmeException { if (certChain == null) { LOG.debug("download"); try (Connection conn = getSession().connect()) { conn.sendCertificateRequest(getLocation(), getLogin()); alternates = new ArrayList<>(conn.getLinks("alternate")); certChain = new ArrayList<>(conn.readCertificates()); } } }
/** * Downloads the certificate chain. * <p> * The certificate is downloaded lazily by the other methods. So usually there is no * need to invoke this method, unless the download is to be enforced. If the * certificate has been downloaded already, nothing will happen. * * @throws AcmeException * if the certificate could not be downloaded */ public void download() throws AcmeException { if (certChain == null) { LOG.debug("download"); try (Connection conn = getSession().connect()) { conn.sendCertificateRequest(getLocation(), getLogin()); alternates = new ArrayList<>(conn.getLinks("alternate")); certChain = new ArrayList<>(conn.readCertificates()); } } }
/** * Updates this resource, by fetching the current resource data from the server. * * @throws AcmeException * if the resource could not be fetched. * @throws AcmeRetryAfterException * the resource is still being processed, and the server returned an * estimated date when the process will be completed. If you are polling * for the resource to complete, you should wait for the date given in * {@link AcmeRetryAfterException#getRetryAfter()}. Note that the status * of the resource is updated even if this exception was thrown. */ public void update() throws AcmeException { String resourceType = getClass().getSimpleName(); LOG.debug("update {}", resourceType); try (Connection conn = getSession().connect()) { conn.sendSignedPostAsGetRequest(getLocation(), getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } conn.handleRetryAfter(resourceType + " is not completed yet"); } }
/** * Updates this resource, by fetching the current resource data from the server. * * @throws AcmeException * if the resource could not be fetched. * @throws AcmeRetryAfterException * the resource is still being processed, and the server returned an * estimated date when the process will be completed. If you are polling * for the resource to complete, you should wait for the date given in * {@link AcmeRetryAfterException#getRetryAfter()}. Note that the status * of the resource is updated even if this exception was thrown. */ public void update() throws AcmeException { String resourceType = getClass().getSimpleName(); LOG.debug("update {}", resourceType); try (Connection conn = getSession().connect()) { conn.sendSignedPostAsGetRequest(getLocation(), getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } conn.handleRetryAfter(resourceType + " is not completed yet"); } }
/** * Commits the changes and updates the account. */ public void commit() throws AcmeException { LOG.debug("modify/commit"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); if (!editContacts.isEmpty()) { claims.put(KEY_CONTACT, editContacts); } conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } } }
/** * Commits the changes and updates the account. */ public void commit() throws AcmeException { LOG.debug("modify/commit"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); if (!editContacts.isEmpty()) { claims.put(KEY_CONTACT, editContacts); } conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } } }
/** * Permanently deactivates an account. Related certificates may still be valid after * account deactivation, and need to be revoked separately if neccessary. * <p> * A deactivated account cannot be reactivated! */ public void deactivate() throws AcmeException { LOG.debug("deactivate"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put(KEY_STATUS, "deactivated"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
try (Connection conn = session.connect()) { JSONBuilder claims = new JSONBuilder(); claims.putBase64("certificate", cert.getEncoded());
/** * Permanently deactivates the {@link Authorization}. */ public void deactivate() throws AcmeException { LOG.debug("deactivate"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put("status", "deactivated"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
/** * Permanently deactivates the {@link Authorization}. */ public void deactivate() throws AcmeException { LOG.debug("deactivate"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put("status", "deactivated"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
/** * Finalizes the order, by providing a CSR. * <p> * After a successful finalization, the certificate is available at * {@link #getCertificate()}. * <p> * Even though the ACME protocol uses the term "finalize an order", this method is * called {@link #execute(byte[])} to avoid confusion with the general * {@link Object#finalize()} method. * * @param csr * CSR containing the parameters for the certificate being requested, in * DER format */ public void execute(byte[] csr) throws AcmeException { LOG.debug("finalize"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.putBase64("csr", csr); conn.sendSignedRequest(getFinalizeLocation(), claims, getLogin()); } invalidate(); }
/** * Finalizes the order, by providing a CSR. * <p> * After a successful finalization, the certificate is available at * {@link #getCertificate()}. * <p> * Even though the ACME protocol uses the term "finalize an order", this method is * called {@link #execute(byte[])} to avoid confusion with the general * {@link Object#finalize()} method. * * @param csr * CSR containing the parameters for the certificate being requested, in * DER format */ public void execute(byte[] csr) throws AcmeException { LOG.debug("finalize"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.putBase64("csr", csr); conn.sendSignedRequest(getFinalizeLocation(), claims, getLogin()); } invalidate(); }
/** * Permanently deactivates an account. Related certificates may still be valid after * account deactivation, and need to be revoked separately if neccessary. * <p> * A deactivated account cannot be reactivated! */ public void deactivate() throws AcmeException { LOG.debug("deactivate"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put(KEY_STATUS, "deactivated"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
try (Connection conn = session.connect()) { JSONBuilder claims = new JSONBuilder(); claims.putBase64("certificate", cert.getEncoded());
/** * 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); } } }
/** * Cancels a recurrent order. * * @since 2.3 */ public void cancelRecurrent() throws AcmeException { if (!getSession().getMetadata().isStarEnabled()) { throw new AcmeException("CA does not support short-term automatic renewals"); } LOG.debug("cancel"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put("status", "canceled"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }
/** * Cancels a recurrent order. * * @since 2.3 */ public void cancelRecurrent() throws AcmeException { if (!getSession().getMetadata().isStarEnabled()) { throw new AcmeException("CA does not support short-term automatic renewals"); } LOG.debug("cancel"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); claims.put("status", "canceled"); conn.sendSignedRequest(getLocation(), claims, getLogin()); JSON json = conn.readJsonResponse(); if (json != null) { setJSON(json); } } }