private Registration loadOrRegisterAccount(Session session) throws AcmeException { Registration reg; try { messages.add("registering new user", LOG); reg = new RegistrationBuilder().create(session); URI agreement = reg.getAgreement(); messages.add("accepting terms of service", LOG); EditableRegistration editableReg = reg.modify(); editableReg.setAgreement(agreement); editableReg.addContact("mailto:" + config.getProperty("server.login")); editableReg.commit(); } catch (AcmeConflictException ex) { messages.add("account already exists. use it", LOG); reg = Registration.bind(session, ex.getLocation()); } return reg; }
certificate = reg.requestCertificate(csr); } catch (AcmeUnauthorizedException e) { LOG.info("authorizations expired. create new csr"); certificate = reg.requestCertificate(csrb.getEncoded()); } catch (Exception e1) { LOG.error("unable to renew certificate with new csr", e1);
logger.info("Registered a new user, URL: " + reg.getLocation()); URI agreement = reg.getAgreement(); logger.info("Terms of Service: " + agreement); acceptAgreement(reg, agreement); reg = Registration.bind(session, ex.getLocation()); logger.info("Account does already exist, URL: " + reg.getLocation(), ex);
Authorization auth = aRegistration.authorizeDomain(aDomain); logger.info("Authorization for domain " + aDomain);
private void acceptAgreement(Registration aRegistration, URI aAgreement) throws AcmeException { Assert.isTrue(config.isAcceptTermsOfService(),"You must accept the TOS: " + aAgreement + " by setting the property acme.accept-terms-of-service to true"); // Motify the Registration and accept the agreement aRegistration.modify().setAgreement(aAgreement).commit(); logger.info("Updated user's ToS"); }
private void authorize(Registration reg, String domain) throws AcmeException, FileNotFoundException, IOException { messages.add("authorizing domain: " + domain, LOG); Authorization auth = reg.authorizeDomain(domain); messages.add("find http challenge", LOG); Http01Challenge challenge1 = auth.findChallenge(Http01Challenge.TYPE);
Certificate certificate = reg.requestCertificate(csrb.getEncoded());
private void doSetup() { messages.add("starting up...", LOG); Registration reg = loadOrCreateRegistration(); if (reg == null) { return; } CSRBuilder csrb = createCSR(reg); if (csrb == null) { return; } messages.add("requesting certificate", LOG); Certificate certificate; try { certificate = reg.requestCertificate(csrb.getEncoded()); } catch (Exception e) { String message = "unable to request certificate"; messages.add(message); LOG.error(message, e); return; } downloadCertificate(certificate); }