for (Authorization auth : order.getAuthorizations()) { authorize(auth);
public CompletableFuture<CertAndSigningRequest> finalizeOrder(ProxyOrder order, KeyPair accountKeyPair, String email, String domain, String organization) { Stream<Authorization> stream = order.getOrder().getAuthorizations().stream(); Stream<CompletableFuture<Void>> futures = stream.map( (auth) -> processChallenge(auth)); CompletableFuture<List<Void>> results = futures.collect(CompletableFutureCollector.allOf()); return results.thenCompose( (nothing) -> finalizeOrder(order, domain, organization, accountKeyPair) ); }
/** * @return The list of challenges with tokens to create webpages for that remote end will call to verify we own the domain */ public CompletableFuture<ProxyOrder> placeOrder(URL accountUrl, KeyPair accountKeyPair) { try { log.info("reestablish account from location="+accountUrl+" and keypair"); Session session = new Session("acme://letsencrypt.org/staging"); Login login = session.login(accountUrl, accountKeyPair); Account account = login.getAccount(); log.info("create an order"); String domainTemp = "something.com"; Order order = account.newOrder() .domain(domainTemp) .create(); checkAuthStatii(order); List<ProxyAuthorization> auths = new ArrayList<>(); for(Authorization auth : order.getAuthorizations()) auths.add(new ProxyAuthorization(auth)); return CompletableFuture.completedFuture(new ProxyOrder(order, auths)); } catch (AcmeException e) { throw new RuntimeException(e); } }
@Override public Tuple2<Order, Dns01Challenge> challengeInit(String domainName) { AssertTools.assertNotNull(account, "You need to log in first"); Order order; try { order = account.newOrder() // .domains(domainName) // .create(); } catch (AcmeException e) { LOGGER.error("Could not ask for domain {}", domainName, e); throw new LetsencryptException("Could not ask for domain " + domainName, e); } // Get the DNS challenge Dns01Challenge challenge = null; List<String> availableChallenges = new ArrayList<>(); for (Authorization auth : order.getAuthorizations()) { auth.getChallenges().stream().map(it -> it.getType()).forEach(it -> availableChallenges.add(it)); challenge = auth.findChallenge(Dns01Challenge.TYPE); } if (challenge == null) { throw new LetsencryptException("DNS Challenge not found for " + domainName + " ; Available challenges are: [" + Joiner.on(", ").join(availableChallenges) + "]"); } return new Tuple2<>(order, challenge); }
private void checkAuthStatii(Order order) { for(Authorization auth : order.getAuthorizations()) { Status status = auth.getStatus(); log.info("checking auth="+auth.getDomain()+" status="+status+" location="+auth.getLocation()+" expires="+auth.getExpires()); if(status != Status.PENDING) throw new ChallengeInBadStateException("challenge in bad state="+auth.getJSON()); } }
for (Authorization auth : order.getAuthorizations()) { authorize(auth);
final Account account = new AccountBuilder().agreeToTermsOfService().useKeyPair(userKeyPair).create(session); final Order order = account.newOrder().domains(config.getDomains().trim().split(",")).create(); final boolean updated = order.getAuthorizations().stream().map(authorization -> { try { return authorize(authorization);