Search in sources :

Example 6 with Session

use of org.shredzone.acme4j.Session in project webpieces by deanhiller.

the class AcmeClientProxy method placeOrder.

// TODO: Put the remote request INTO a different pool to not hold up the webserver main
// threadpool so only synchronous requests will hold up synchronous requests
/**
 * @return The list of challenges with tokens to create webpages for that remote end will call to verify we own the domain
 */
public XFuture<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 XFuture.completedFuture(new ProxyOrder(order, auths));
    } catch (AcmeException e) {
        throw SneakyThrow.sneak(e);
    }
}
Also used : Order(org.shredzone.acme4j.Order) Authorization(org.shredzone.acme4j.Authorization) Account(org.shredzone.acme4j.Account) AcmeException(org.shredzone.acme4j.exception.AcmeException) ArrayList(java.util.ArrayList) Login(org.shredzone.acme4j.Login) Session(org.shredzone.acme4j.Session)

Aggregations

Session (org.shredzone.acme4j.Session)6 AcmeException (org.shredzone.acme4j.exception.AcmeException)5 Account (org.shredzone.acme4j.Account)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 URL (java.net.URL)2 KeyPair (java.security.KeyPair)2 AccountBuilder (org.shredzone.acme4j.AccountBuilder)2 Authorization (org.shredzone.acme4j.Authorization)2 Order (org.shredzone.acme4j.Order)2 CSRBuilder (org.shredzone.acme4j.util.CSRBuilder)2 LetsEncryptAccountEntity (com.peterphi.servicemanager.service.db.entity.LetsEncryptAccountEntity)1 BufferedWriter (java.io.BufferedWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1