/** * Add a email address to the list of contacts. * <p> * This is a convenience call for {@link #addContact(String)} that doesn't * require from you attach "mailto" scheme before email address. * * @param email * Contact email without "mailto" scheme (e.g. test@gmail.com) * @throws IllegalArgumentException * if there is a syntax error in the URI string * @return itself */ public AccountBuilder addEmail(String email) { addContact("mailto:" + email); return this; }
/** * Add a email address to the list of contacts. * <p> * This is a convenience call for {@link #addContact(String)} that doesn't * require from you attach "mailto" scheme before email address. * * @param email * Contact email without "mailto" scheme (e.g. test@gmail.com) * @throws IllegalArgumentException * if there is a syntax error in the URI string * @return itself */ public AccountBuilder addEmail(String email) { addContact("mailto:" + email); return this; }
/** * Add a contact address to the list of contacts. * <p> * This is a convenience call for {@link #addContact(URI)}. * * @param contact * Contact URI as string * @throws IllegalArgumentException * if there is a syntax error in the URI string * @return itself */ public AccountBuilder addContact(String contact) { addContact(URI.create(contact)); return this; }
/** * Add a contact address to the list of contacts. * <p> * This is a convenience call for {@link #addContact(URI)}. * * @param contact * Contact URI as string * @throws IllegalArgumentException * if there is a syntax error in the URI string * @return itself */ public AccountBuilder addContact(String contact) { addContact(URI.create(contact)); return this; }
public CompletableFuture<URL> openAccount(String email, KeyPair accountKeyPair) { try { log.info("open account"); Session session = new Session("acme://letsencrypt.org/staging"); Account account = new AccountBuilder() .addContact("mailto:"+email) .agreeToTermsOfService() .useKeyPair(accountKeyPair) .create(session); URL location = account.getLocation(); log.info("account location="+location); return CompletableFuture.completedFuture(location); } catch (AcmeException e) { throw new RuntimeException(e); } } //TODO: Put the remote request INTO a different pool to not hold up the webserver main
private void login() { KeyPair accountKeyPair = RSATools.createKeyPair(RSACrypt.RSA_CRYPT.loadKeysPemFromString(config.getAccountKeypairPem())); LOGGER.info("Registering account"); try { account = new AccountBuilder() // .addContact("mailto:" + config.getContactEmail()) // .agreeToTermsOfService() // .useKeyPair(accountKeyPair) // .create(session); } catch (AcmeException e) { LOGGER.error("Problem logging in", e); throw new LetsencryptException("Problem logging in", e); } URL accountLocationUrl = account.getLocation(); session.login(accountLocationUrl, accountKeyPair); // Get the location LOGGER.info("AcmeClient location: {}", accountLocationUrl); }