@Test public void testGetMetadata() throws Exception { server = setupTestGetMetadata(); AcmeAccount account = populateBasicAccount(ACCOUNT_8_V2); AcmeMetadata metadata = acmeClient.getMetadata(account, false); assertNotNull(metadata); assertEquals("https: assertEquals("https: assertArrayEquals(new String[] { "happy-hacker-ca.invalid", "happy-hacker2-ca.invalid" }, metadata.getCAAIdentities()); assertTrue(metadata.isExternalAccountRequired()); metadata = acmeClient.getMetadata(account, false); assertNotNull(metadata); assertEquals("https: assertNull(metadata.getWebsiteUrl()); assertNull(metadata.getCAAIdentities()); assertFalse(metadata.isExternalAccountRequired()); metadata = acmeClient.getMetadata(account, false); assertNull(metadata); }
public AcmeMetadata getMetadata(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); if (staging && account.getServerUrl(true) == null) { throw acme.noAcmeServerStagingUrlGiven(); } HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META); if (metadata == null) { return null; } AcmeMetadata.Builder metadataBuilder = AcmeMetadata.builder(); String termsOfServiceUrl = getOptionalJsonString(metadata, TERMS_OF_SERVICE); if (termsOfServiceUrl != null) { metadataBuilder.setTermsOfServiceUrl(termsOfServiceUrl); } String websiteUrl = getOptionalJsonString(metadata, WEBSITE); if (websiteUrl != null) { metadataBuilder.setWebsiteUrl(websiteUrl); } JsonArray caaIdentitiesArray = metadata.getJsonArray(CAA_IDENTITIES); if (caaIdentitiesArray != null) { final List<String> caaIdentities = new ArrayList<>(caaIdentitiesArray.size()); for (JsonString caaIdentity : caaIdentitiesArray.getValuesAs(JsonString.class)) { caaIdentities.add(caaIdentity.getString()); } metadataBuilder.setCaaIdentities(caaIdentities.toArray(new String[caaIdentities.size()])); } boolean externalAccountRequired = metadata.getBoolean(EXTERNAL_ACCOUNT_REQUIRED, false); metadataBuilder.setExternalAccountRequired(externalAccountRequired); return metadataBuilder.build(); }
AcmeClientSpi { public AcmeMetadata getMetadata(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); if (staging && account.getServerUrl(true) == null) { throw acme.noAcmeServerStagingUrlGiven(); } HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META); if (metadata == null) { return null; } AcmeMetadata.Builder metadataBuilder = AcmeMetadata.builder(); String termsOfServiceUrl = getOptionalJsonString(metadata, TERMS_OF_SERVICE); if (termsOfServiceUrl != null) { metadataBuilder.setTermsOfServiceUrl(termsOfServiceUrl); } String websiteUrl = getOptionalJsonString(metadata, WEBSITE); if (websiteUrl != null) { metadataBuilder.setWebsiteUrl(websiteUrl); } JsonArray caaIdentitiesArray = metadata.getJsonArray(CAA_IDENTITIES); if (caaIdentitiesArray != null) { final List<String> caaIdentities = new ArrayList<>(caaIdentitiesArray.size()); for (JsonString caaIdentity : caaIdentitiesArray.getValuesAs(JsonString.class)) { caaIdentities.add(caaIdentity.getString()); } metadataBuilder.setCaaIdentities(caaIdentities.toArray(new String[caaIdentities.size()])); } boolean externalAccountRequired = metadata.getBoolean(EXTERNAL_ACCOUNT_REQUIRED, false); metadataBuilder.setExternalAccountRequired(externalAccountRequired); return metadataBuilder.build(); } }
AcmeClientSpi { public AcmeMetadata getMetadata(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); if (staging && account.getServerUrl(true) == null) { throw acme.noAcmeServerStagingUrlGiven(); } HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META); if (metadata == null) { return null; } AcmeMetadata.Builder metadataBuilder = AcmeMetadata.builder(); String termsOfServiceUrl = getOptionalJsonString(metadata, TERMS_OF_SERVICE); if (termsOfServiceUrl != null) { metadataBuilder.setTermsOfServiceUrl(termsOfServiceUrl); } String websiteUrl = getOptionalJsonString(metadata, WEBSITE); if (websiteUrl != null) { metadataBuilder.setWebsiteUrl(websiteUrl); } JsonArray caaIdentitiesArray = metadata.getJsonArray(CAA_IDENTITIES); if (caaIdentitiesArray != null) { final List<String> caaIdentities = new ArrayList<>(caaIdentitiesArray.size()); for (JsonString caaIdentity : caaIdentitiesArray.getValuesAs(JsonString.class)) { caaIdentities.add(caaIdentity.getString()); } metadataBuilder.setCaaIdentities(caaIdentities.toArray(new String[caaIdentities.size()])); } boolean externalAccountRequired = metadata.getBoolean(EXTERNAL_ACCOUNT_REQUIRED, false); metadataBuilder.setExternalAccountRequired(externalAccountRequired); return metadataBuilder.build(); }  }
AcmeClientSpi { public AcmeMetadata getMetadata(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); if (staging && account.getServerUrl(true) == null) { throw acme.noAcmeServerStagingUrlGiven(); } HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META); if (metadata == null) { return null; } AcmeMetadata.Builder metadataBuilder = AcmeMetadata.builder(); String termsOfServiceUrl = getOptionalJsonString(metadata, TERMS_OF_SERVICE); if (termsOfServiceUrl != null) { metadataBuilder.setTermsOfServiceUrl(termsOfServiceUrl); } String websiteUrl = getOptionalJsonString(metadata, WEBSITE); if (websiteUrl != null) { metadataBuilder.setWebsiteUrl(websiteUrl); } JsonArray caaIdentitiesArray = metadata.getJsonArray(CAA_IDENTITIES); if (caaIdentitiesArray != null) { final List<String> caaIdentities = new ArrayList<>(caaIdentitiesArray.size()); for (JsonString caaIdentity : caaIdentitiesArray.getValuesAs(JsonString.class)) { caaIdentities.add(caaIdentity.getString()); } metadataBuilder.setCaaIdentities(caaIdentities.toArray(new String[caaIdentities.size()])); } boolean externalAccountRequired = metadata.getBoolean(EXTERNAL_ACCOUNT_REQUIRED, false); metadataBuilder.setExternalAccountRequired(externalAccountRequired); return metadataBuilder.build(); }  Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging); AcmeMetadata getMetadata(AcmeAccount account, boolean staging); boolean createAccount(AcmeAccount account, boolean staging); boolean createAccount(AcmeAccount account, boolean staging, boolean onlyReturnExisting); void updateAccount(AcmeAccount account, boolean staging, boolean termsOfServiceAgreed); void updateAccount(AcmeAccount account, boolean staging, String[] contactUrls); void updateAccount(AcmeAccount account, boolean staging, boolean termsOfServiceAgreed, String[] contactUrls); void changeAccountKey(AcmeAccount account, boolean staging); void changeAccountKey(AcmeAccount account, boolean staging, X509Certificate certificate, PrivateKey privateKey); void deactivateAccount(AcmeAccount account, boolean staging); X509CertificateChainAndSigningKey obtainCertificateChain(AcmeAccount account, boolean staging, String... domainNames); X509CertificateChainAndSigningKey obtainCertificateChain(AcmeAccount account, boolean staging, String keyAlgorithmName, int keySize,
                                                                    String... domainNames); String createAuthorization(AcmeAccount account, boolean staging, String domainName); void deactivateAuthorization(AcmeAccount account, boolean staging, String authorizationUrl); abstract AcmeChallenge proveIdentifierControl(AcmeAccount account, List<AcmeChallenge> challenges); abstract void cleanupAfterChallenge(AcmeAccount account, AcmeChallenge challenge); void revokeCertificate(AcmeAccount account, boolean staging, X509Certificate certificate); void revokeCertificate(AcmeAccount account, boolean staging, X509Certificate certificate, CRLReason reason); byte[] getNewNonce(final AcmeAccount account, final boolean staging); }
AcmeClientSpi { public AcmeMetadata getMetadata(AcmeAccount account, boolean staging) throws AcmeException { Assert.checkNotNullParam("account", account); if (staging && account.getServerUrl(true) == null) { throw acme.noAcmeServerStagingUrlGiven(); } HttpURLConnection connection = sendGetRequest(account.getServerUrl(staging), HttpURLConnection.HTTP_OK, JSON_CONTENT_TYPE); JsonObject directoryJson = getJsonResponse(connection); JsonObject metadata = directoryJson.getJsonObject(META); if (metadata == null) { return null; } AcmeMetadata.Builder metadataBuilder = AcmeMetadata.builder(); String termsOfServiceUrl = getOptionalJsonString(metadata, TERMS_OF_SERVICE); if (termsOfServiceUrl != null) { metadataBuilder.setTermsOfServiceUrl(termsOfServiceUrl); } String websiteUrl = getOptionalJsonString(metadata, WEBSITE); if (websiteUrl != null) { metadataBuilder.setWebsiteUrl(websiteUrl); } JsonArray caaIdentitiesArray = metadata.getJsonArray(CAA_IDENTITIES); if (caaIdentitiesArray != null) { final List<String> caaIdentities = new ArrayList<>(caaIdentitiesArray.size()); for (JsonString caaIdentity : caaIdentitiesArray.getValuesAs(JsonString.class)) { caaIdentities.add(caaIdentity.getString()); } metadataBuilder.setCaaIdentities(caaIdentities.toArray(new String[caaIdentities.size()])); } boolean externalAccountRequired = metadata.getBoolean(EXTERNAL_ACCOUNT_REQUIRED, false); metadataBuilder.setExternalAccountRequired(externalAccountRequired); return metadataBuilder.build(); }  Map<AcmeResource, URL> getResourceUrls(AcmeAccount account, boolean staging); AcmeMetadata getMetadata(AcmeAccount account, boolean staging); boolean createAccount(AcmeAccount account, boolean staging); boolean createAccount(AcmeAccount account, boolean staging, boolean onlyReturnExisting); void updateAccount(AcmeAccount account, boolean staging, boolean termsOfServiceAgreed); void updateAccount(AcmeAccount account, boolean staging, String[] contactUrls); void updateAccount(AcmeAccount account, boolean staging, boolean termsOfServiceAgreed, String[] contactUrls); void changeAccountKey(AcmeAccount account, boolean staging); void changeAccountKey(AcmeAccount account, boolean staging, X509Certificate certificate, PrivateKey privateKey); void deactivateAccount(AcmeAccount account, boolean staging); X509CertificateChainAndSigningKey obtainCertificateChain(AcmeAccount account, boolean staging, String... domainNames); X509CertificateChainAndSigningKey obtainCertificateChain(AcmeAccount account, boolean staging, String keyAlgorithmName, int keySize,
                                                                    String... domainNames); String createAuthorization(AcmeAccount account, boolean staging, String domainName); void deactivateAuthorization(AcmeAccount account, boolean staging, String authorizationUrl); abstract AcmeChallenge proveIdentifierControl(AcmeAccount account, List<AcmeChallenge> challenges); abstract void cleanupAfterChallenge(AcmeAccount account, AcmeChallenge challenge); void revokeCertificate(AcmeAccount account, boolean staging, X509Certificate certificate); void revokeCertificate(AcmeAccount account, boolean staging, X509Certificate certificate, CRLReason reason); byte[] getNewNonce(final AcmeAccount account, final boolean staging); static final int DEFAULT_EC_KEY_SIZE; static final int DEFAULT_KEY_SIZE; static final String DEFAULT_KEY_ALGORITHM_NAME; }