Search in sources :

Example 1 with ProxyAuthorization

use of org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization in project webpieces by deanhiller.

the class TestFullSslSetupWizard method postOrgAndPlaceOrderAndFinalizeOrder.

private MockProxyAuthorization postOrgAndPlaceOrderAndFinalizeOrder(String url) throws MalformedURLException {
    URL accountUrl = new URL("http://someurlfor.com/myexact/account/1234");
    mockAcmeClient.setOpenAccount(XFuture.completedFuture(accountUrl));
    List<ProxyAuthorization> proxyAuth = new ArrayList<>();
    MockProxyAuthorization mockProxyAuth = new MockProxyAuthorization("domain.com", Instant.now(), Status.PENDING, new URL("http://somelocation.asdf"), "sometokenforwebdisplay", "authcontent111");
    proxyAuth.add(mockProxyAuth);
    mockAcmeClient.setProxyOrder(XFuture.completedFuture(new ProxyOrder(null, proxyAuth)));
    mockAcmeClient.setCertAndSigningRequest(XFuture.completedFuture(new CertAndSigningRequest("fakecsr", new ArrayList<>())));
    HttpFullRequest req = Requests.createPostRequest(url, "organization", "DeanCo");
    req.addHeader(new Header(KnownHeaderName.COOKIE, "webSession=1-xjrs6SeNeSxmJQtaTwM8gDorNiQ=:backendUser=admin"));
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    List<Header> headers = response.getResponse().getHeaderLookupStruct().getHeaders(KnownHeaderName.LOCATION);
    Assert.assertEquals(1, headers.size());
    Assert.assertEquals("https://myhost.com/@sslcert/maintainssl", headers.get(0).getValue());
    return mockProxyAuth;
}
Also used : ProxyOrder(org.webpieces.plugin.secure.sslcert.acme.ProxyOrder) ArrayList(java.util.ArrayList) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) URL(java.net.URL) CertAndSigningRequest(org.webpieces.plugin.secure.sslcert.CertAndSigningRequest) HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ProxyAuthorization(org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization)

Example 2 with ProxyAuthorization

use of org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization in project webpieces by deanhiller.

the class InstallSslCertController method createWebPages.

/**
 * WE ONLY use ONE webpage that renders ALL requests for these tokens and that web page just looks up the token in the database
 * to see if the page exists and only renders an html page if that page exists
 */
private XFuture<ProxyOrder> createWebPages(ProxyOrder order) {
    List<ProxyAuthorization> authorizations = order.getAuthorizations();
    Map<String, String> properties = new HashMap<>();
    for (ProxyAuthorization auth : authorizations) {
        log.info("process domain=" + auth.getDomain() + " expires=" + auth.getExpires() + " status=" + auth.getStatus() + " else=" + auth.getLocation());
        Instant expires = auth.getExpires();
        String dateTime = expires.toString();
        String domain = auth.getDomain();
        String authContent = auth.getAuthContent();
        String value = authContent + "---" + domain + "---" + dateTime;
        String token = auth.getToken();
        log.info("putting token in map=" + token + " value=" + value);
        properties.put(token, value);
    }
    return storage.save(InstallSslCertPlugin.PLUGIN_PROPERTIES_KEY, properties).thenApply((nothing) -> order);
}
Also used : HashMap(java.util.HashMap) Instant(java.time.Instant) ProxyAuthorization(org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization)

Aggregations

ProxyAuthorization (org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization)2 URL (java.net.URL)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)1 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)1 Header (org.webpieces.httpparser.api.common.Header)1 CertAndSigningRequest (org.webpieces.plugin.secure.sslcert.CertAndSigningRequest)1 ProxyOrder (org.webpieces.plugin.secure.sslcert.acme.ProxyOrder)1 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)1