Search in sources :

Example 16 with StandardSSLContextService

use of org.apache.nifi.ssl.StandardSSLContextService in project nifi by apache.

the class TestPostHTTP method testTwoWaySSL.

@Test
public void testTwoWaySSL() throws Exception {
    final Map<String, String> sslProps = new HashMap<>();
    sslProps.put(StandardSSLContextService.KEYSTORE.getName(), "src/test/resources/localhost-ks.jks");
    sslProps.put(StandardSSLContextService.KEYSTORE_PASSWORD.getName(), "localtest");
    sslProps.put(StandardSSLContextService.KEYSTORE_TYPE.getName(), "JKS");
    sslProps.put(StandardSSLContextService.TRUSTSTORE.getName(), "src/test/resources/localhost-ts.jks");
    sslProps.put(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName(), "localtest");
    sslProps.put(StandardSSLContextService.TRUSTSTORE_TYPE.getName(), "JKS");
    sslProps.put(TestServer.NEED_CLIENT_AUTH, "true");
    setup(sslProps);
    final SSLContextService sslContextService = new StandardSSLContextService();
    runner.addControllerService("ssl-context", sslContextService);
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE, "src/test/resources/localhost-ts.jks");
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_PASSWORD, "localtest");
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_TYPE, "JKS");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE, "src/test/resources/localhost-ks.jks");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_PASSWORD, "localtest");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_TYPE, "JKS");
    runner.enableControllerService(sslContextService);
    runner.setProperty(PostHTTP.URL, server.getSecureUrl());
    runner.setProperty(PostHTTP.SSL_CONTEXT_SERVICE, "ssl-context");
    runner.setProperty(PostHTTP.CHUNKED_ENCODING, "false");
    runner.enqueue("Hello world".getBytes());
    runner.run();
    runner.assertAllFlowFilesTransferred(PostHTTP.REL_SUCCESS, 1);
}
Also used : HashMap(java.util.HashMap) SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) Test(org.junit.Test)

Example 17 with StandardSSLContextService

use of org.apache.nifi.ssl.StandardSSLContextService in project nifi by apache.

the class ITListenAndPutSyslog method configureSSLContextService.

private SSLContextService configureSSLContextService(TestRunner runner) throws InitializationException {
    final SSLContextService sslContextService = new StandardSSLContextService();
    runner.addControllerService("ssl-context", sslContextService);
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE, "src/test/resources/localhost-ts.jks");
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_PASSWORD, "localtest");
    runner.setProperty(sslContextService, StandardSSLContextService.TRUSTSTORE_TYPE, "JKS");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE, "src/test/resources/localhost-ks.jks");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_PASSWORD, "localtest");
    runner.setProperty(sslContextService, StandardSSLContextService.KEYSTORE_TYPE, "JKS");
    runner.enableControllerService(sslContextService);
    return sslContextService;
}
Also used : SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService)

Aggregations

StandardSSLContextService (org.apache.nifi.ssl.StandardSSLContextService)17 SSLContextService (org.apache.nifi.ssl.SSLContextService)11 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 Before (org.junit.Before)4 InitializationException (org.apache.nifi.reporting.InitializationException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 LivySessionController (org.apache.nifi.controller.livy.LivySessionController)1 ConsumeMQTT (org.apache.nifi.processors.mqtt.ConsumeMQTT)1 PublishMQTT (org.apache.nifi.processors.mqtt.PublishMQTT)1 RELPFrame (org.apache.nifi.processors.standard.relp.frame.RELPFrame)1 StandardRestrictedSSLContextService (org.apache.nifi.ssl.StandardRestrictedSSLContextService)1 FlowFileUnpackagerV3 (org.apache.nifi.util.FlowFileUnpackagerV3)1 MockFlowFile (org.apache.nifi.util.MockFlowFile)1