/** * Get the resource URLs needed to perform operations from the ACME server. * * @param account the ACME account information to use (must not be {@code null}) * @param staging whether or not the staging server URL should be used * @return a map of ACME resources to URLs * @throws AcmeException if an error occurs while attempting to get the resource URLs from the ACME server */ public Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); final Map<AcmeResource, URL> resourceUrls = account.getResourceUrls(staging); if (resourceUrls.isEmpty()) { HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); try { for (AcmeResource resource : AcmeResource.values()) { String resourceUrl = getOptionalJsonString(directoryJson, resource.getValue()); URL url = resourceUrl != null ? new URL(resourceUrl) : null; resourceUrls.put(resource, url); } } catch (MalformedURLException e) { throw acme.unableToRetrieveAcmeServerDirectoryUrls(e); } } return resourceUrls; }
HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META);
/** * Get the resource URLs needed to perform operations from the ACME server. * * @param account the ACME account information to use (must not be {@code null}) * @param staging whether or not the staging server URL should be used * @return a map of ACME resources to URLs * @throws AcmeException if an error occurs while attempting to get the resource URLs from the ACME server */ public Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); final Map<AcmeResource, URL> resourceUrls = account.getResourceUrls(staging); if (resourceUrls.isEmpty()) { HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); try { for (AcmeResource resource : AcmeResource.values()) { String resourceUrl = getOptionalJsonString(directoryJson, resource.getValue()); URL url = resourceUrl != null ? new URL(resourceUrl) : null; resourceUrls.put(resource, url); } } catch (MalformedURLException e) { throw acme.unableToRetrieveAcmeServerDirectoryUrls(e); } } return resourceUrls; }
/** * Get the resource URLs needed to perform operations from the ACME server. * * @param account the ACME account information to use (must not be {@code null}) * @param staging whether or not the staging server URL should be used * @return a map of ACME resources to URLs * @throws AcmeException if an error occurs while attempting to get the resource URLs from the ACME server */ public Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); final Map<AcmeResource, URL> resourceUrls = account.getResourceUrls(staging); if (resourceUrls.isEmpty()) { HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); try { for (AcmeResource resource : AcmeResource.values()) { String resourceUrl = getOptionalJsonString(directoryJson, resource.getValue()); URL url = resourceUrl != null ? new URL(resourceUrl) : null; resourceUrls.put(resource, url); } } catch (MalformedURLException e) { throw acme.unableToRetrieveAcmeServerDirectoryUrls(e); } } return resourceUrls; }
/** * Get the resource URLs needed to perform operations from the ACME server. * * @param account the ACME account information to use (must not be {@code null}) * @param staging whether or not the staging server URL should be used * @return a map of ACME resources to URLs * @throws AcmeException if an error occurs while attempting to get the resource URLs from the ACME server */ public Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); final Map<AcmeResource, URL> resourceUrls = account.getResourceUrls(staging); if (resourceUrls.isEmpty()) { HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); try { for (AcmeResource resource : AcmeResource.values()) { String resourceUrl = getOptionalJsonString(directoryJson, resource.getValue()); URL url = resourceUrl != null ? new URL(resourceUrl) : null; resourceUrls.put(resource, url); } } catch (MalformedURLException e) { throw acme.unableToRetrieveAcmeServerDirectoryUrls(e); } } return resourceUrls; }
static AcmeAccount resetAcmeAccount(AcmeAccount acmeAccount, boolean staging) { String accountUrl = acmeAccount.getAccountUrl(); if (accountUrl != null) { String stagingEndpoint = acmeAccount.getStagingServerUrl().substring(0, acmeAccount.getStagingServerUrl().indexOf("/" + DIRECTORY)); if ((accountUrl.startsWith(stagingEndpoint) && ! staging) || (! accountUrl.startsWith(stagingEndpoint) && staging)) { // need to reset the account information so it will get populated with the correct staging / non-staging account URL AcmeAccount.Builder acmeAccountBuilder = AcmeAccount.builder(); acmeAccountBuilder .setServerUrl(acmeAccount.getServerUrl()) .setStagingServerUrl(acmeAccount.getStagingServerUrl()) .setDn(acmeAccount.getDn()) .setKey(acmeAccount.getCertificate(), acmeAccount.getPrivateKey()) .setTermsOfServiceAgreed(acmeAccount.isTermsOfServiceAgreed()); if (acmeAccount.getContactUrls() != null) { acmeAccountBuilder.setContactUrls(acmeAccount.getContactUrls()); } return acmeAccountBuilder.build(); } } return acmeAccount; }
HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META);
HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META);
HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META);