Search in sources :

Example 1 with BrowserProxySettings

use of com.github.tomakehurst.wiremock.common.BrowserProxySettings in project wiremock by wiremock.

the class GetCaCertTask method execute.

@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
    BrowserProxySettings browserProxySettings = admin.getOptions().browserProxySettings();
    KeyStoreSettings caKeyStore = browserProxySettings.caKeyStore();
    try {
        X509KeyStore x509KeyStore = new X509KeyStore(caKeyStore.loadStore(), caKeyStore.password().toCharArray());
        X509Certificate certificate = x509KeyStore.getCertificateAuthority().certificateChain()[0];
        return new ResponseDefinitionBuilder().withStatus(HTTP_OK).withHeader("Content-Type", "application/x-pem-file").withBody("-----BEGIN CERTIFICATE-----\r\n" + BASE64_ENCODER.encodeToString(certificate.getEncoded()) + "\r\n" + "-----END CERTIFICATE-----").build();
    } catch (Exception e) {
        String message = "Failed to export certificate authority cert from " + caKeyStore.path();
        admin.getOptions().notifier().error(message, e);
        return new ResponseDefinition(HTTP_INTERNAL_ERROR, message);
    }
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) KeyStoreSettings(com.github.tomakehurst.wiremock.common.ssl.KeyStoreSettings) X509KeyStore(com.github.tomakehurst.wiremock.http.ssl.X509KeyStore) ResponseDefinition(com.github.tomakehurst.wiremock.http.ResponseDefinition) BrowserProxySettings(com.github.tomakehurst.wiremock.common.BrowserProxySettings) X509Certificate(java.security.cert.X509Certificate)

Example 2 with BrowserProxySettings

use of com.github.tomakehurst.wiremock.common.BrowserProxySettings in project wiremock by wiremock.

the class WireMockApp method buildStubRequestHandler.

public StubRequestHandler buildStubRequestHandler() {
    Map<String, PostServeAction> postServeActions = options.extensionsOfType(PostServeAction.class);
    BrowserProxySettings browserProxySettings = options.browserProxySettings();
    return new StubRequestHandler(this, new StubResponseRenderer(options.filesRoot().child(FILES_ROOT), getGlobalSettingsHolder(), new ProxyResponseRenderer(options.proxyVia(), options.httpsSettings().trustStore(), options.shouldPreserveHostHeader(), options.proxyHostHeader(), globalSettingsHolder, browserProxySettings.trustAllProxyTargets(), browserProxySettings.trustedProxyTargets(), options.getStubCorsEnabled()), ImmutableList.copyOf(options.extensionsOfType(ResponseTransformer.class).values())), this, postServeActions, requestJournal, getStubRequestFilters(), options.getStubRequestLoggingDisabled());
}
Also used : BrowserProxySettings(com.github.tomakehurst.wiremock.common.BrowserProxySettings)

Aggregations

BrowserProxySettings (com.github.tomakehurst.wiremock.common.BrowserProxySettings)2 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 KeyStoreSettings (com.github.tomakehurst.wiremock.common.ssl.KeyStoreSettings)1 ResponseDefinition (com.github.tomakehurst.wiremock.http.ResponseDefinition)1 X509KeyStore (com.github.tomakehurst.wiremock.http.ssl.X509KeyStore)1 X509Certificate (java.security.cert.X509Certificate)1