Search in sources :

Example 66 with SSLContextService

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

the class TestListenHTTP method configureInvalidProcessorSslContextService.

private SSLContextService configureInvalidProcessorSslContextService() throws InitializationException {
    final SSLContextService sslContextService = new StandardSSLContextService();
    runner.addControllerService(SSL_CONTEXT_SERVICE_IDENTIFIER, 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.setProperty(ListenHTTP.SSL_CONTEXT_SERVICE, SSL_CONTEXT_SERVICE_IDENTIFIER);
    return sslContextService;
}
Also used : StandardRestrictedSSLContextService(org.apache.nifi.ssl.StandardRestrictedSSLContextService) SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService)

Example 67 with SSLContextService

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

the class TestListenHTTP method configureProcessorSslContextService.

private SSLContextService configureProcessorSslContextService() throws InitializationException {
    final SSLContextService sslContextService = new StandardRestrictedSSLContextService();
    runner.addControllerService(SSL_CONTEXT_SERVICE_IDENTIFIER, 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.setProperty(ListenHTTP.SSL_CONTEXT_SERVICE, SSL_CONTEXT_SERVICE_IDENTIFIER);
    return sslContextService;
}
Also used : StandardRestrictedSSLContextService(org.apache.nifi.ssl.StandardRestrictedSSLContextService) SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) StandardRestrictedSSLContextService(org.apache.nifi.ssl.StandardRestrictedSSLContextService)

Example 68 with SSLContextService

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

the class TestListenHTTP method testSecurePOSTRequestsReceivedWithoutEL.

@Test
public void testSecurePOSTRequestsReceivedWithoutEL() throws Exception {
    SSLContextService sslContextService = configureProcessorSslContextService();
    runner.setProperty(sslContextService, StandardRestrictedSSLContextService.RESTRICTED_SSL_ALGORITHM, "TLSv1.2");
    runner.enableControllerService(sslContextService);
    runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
    runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
    runner.assertValid();
    testPOSTRequestsReceived(HttpServletResponse.SC_OK);
}
Also used : StandardRestrictedSSLContextService(org.apache.nifi.ssl.StandardRestrictedSSLContextService) SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) Test(org.junit.Test)

Example 69 with SSLContextService

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

the class TestListenRELP method testTLS.

@Test
public void testTLS() throws InitializationException, IOException, InterruptedException {
    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.SSL_CONTEXT_SERVICE, "ssl-context");
    final List<RELPFrame> frames = new ArrayList<>();
    frames.add(OPEN_FRAME);
    frames.add(SYSLOG_FRAME);
    frames.add(SYSLOG_FRAME);
    frames.add(SYSLOG_FRAME);
    frames.add(SYSLOG_FRAME);
    frames.add(SYSLOG_FRAME);
    frames.add(CLOSE_FRAME);
    // three syslog frames should be transferred and three responses should be sent
    run(frames, 5, 5, sslContextService);
}
Also used : StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) ArrayList(java.util.ArrayList) RELPFrame(org.apache.nifi.processors.standard.relp.frame.RELPFrame) Test(org.junit.Test)

Example 70 with SSLContextService

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

the class TestGetHTTP method useSSLContextService.

private void useSSLContextService(final Map<String, String> sslProperties) {
    final SSLContextService service = new StandardSSLContextService();
    try {
        controller.addControllerService("ssl-service", service, sslProperties);
        controller.enableControllerService(service);
    } catch (InitializationException ex) {
        ex.printStackTrace();
        Assert.fail("Could not create SSL Context Service");
    }
    controller.setProperty(GetHTTP.SSL_CONTEXT_SERVICE, "ssl-service");
}
Also used : SSLContextService(org.apache.nifi.ssl.SSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) StandardSSLContextService(org.apache.nifi.ssl.StandardSSLContextService) InitializationException(org.apache.nifi.reporting.InitializationException)

Aggregations

SSLContextService (org.apache.nifi.ssl.SSLContextService)84 SSLContext (javax.net.ssl.SSLContext)29 Test (org.junit.Test)23 StandardSSLContextService (org.apache.nifi.ssl.StandardSSLContextService)22 RestrictedSSLContextService (org.apache.nifi.ssl.RestrictedSSLContextService)18 ArrayList (java.util.ArrayList)12 StandardRestrictedSSLContextService (org.apache.nifi.ssl.StandardRestrictedSSLContextService)12 IOException (java.io.IOException)11 ValidationResult (org.apache.nifi.components.ValidationResult)10 ComponentLog (org.apache.nifi.logging.ComponentLog)9 OnScheduled (org.apache.nifi.annotation.lifecycle.OnScheduled)7 InetSocketAddress (java.net.InetSocketAddress)6 ProcessException (org.apache.nifi.processor.exception.ProcessException)6 Charset (java.nio.charset.Charset)5 InitializationException (org.apache.nifi.reporting.InitializationException)5 MalformedURLException (java.net.MalformedURLException)4 URI (java.net.URI)4 ByteBuffer (java.nio.ByteBuffer)4 ProviderCreationException (org.apache.nifi.authentication.exception.ProviderCreationException)4 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)4