public CompletableFuture<AcmeInfo> fetchRemoteInfo() { try { Session session = new Session(config.getProviderLocation()); Metadata metadata = session.getMetadata(); URI termsOfServiceUri = metadata.getTermsOfService(); URL website = metadata.getWebsite(); return CompletableFuture.completedFuture(new AcmeInfo(termsOfServiceUri, website)); } catch(AcmeException e) { throw new RuntimeException(e); } }
/** * Finds your {@link Account} at the ACME server. It will be found by your user's * public key. If your key is not known to the server yet, a new account will be * created. * <p> * This is a simple way of finding your {@link Account}. A better way is to get the * URL and KeyIdentifier of your new account with {@link Account#getLocation()} * {@link Session#getKeyIdentifier()} and store it somewhere. If you need to get * access to your account later, reconnect to it via * {@link Account#bind(Session, URI)} by using the stored location. * * @param session * {@link Session} to bind with * @return {@link Login} that is connected to your account */ private Account findOrRegisterAccount(Session session, KeyPair accountKey) throws AcmeException { // Ask the user to accept the TOS, if server provides us with a link. URI tos = session.getMetadata().getTermsOfService(); if (tos != null) { acceptAgreement(tos); } Account account = new AccountBuilder() .agreeToTermsOfService() .useKeyPair(accountKey) .create(session); LOG.info("Registered a new user, URL: {}", account.getLocation()); return account; }