Search in sources :

Example 1 with GetStatusConfig

use of org.apache.nifi.toolkit.tls.configuration.GetStatusConfig in project nifi by apache.

the class TlsToolkitGetStatusCommandLine method main.

public static void main(String[] args) {
    TlsToolkitGetStatusCommandLine commandLine = new TlsToolkitGetStatusCommandLine();
    try {
        commandLine.parse(args);
    } catch (CommandLineParseException e) {
        System.exit(e.getExitCode().ordinal());
    }
    final GetStatusConfig config = commandLine.createConfig();
    try {
        final TlsToolkitGetStatus tlsToolkitGetStatus = new TlsToolkitGetStatus();
        tlsToolkitGetStatus.get(config);
    } catch (Exception e) {
        commandLine.printUsage("Error communicating with " + config.getUrl().toString() + " (" + e.getMessage() + ")");
        System.exit(ExitCode.SERVICE_ERROR.ordinal());
    }
    System.exit(ExitCode.SUCCESS.ordinal());
}
Also used : CommandLineParseException(org.apache.nifi.toolkit.tls.commandLine.CommandLineParseException) GetStatusConfig(org.apache.nifi.toolkit.tls.configuration.GetStatusConfig) URISyntaxException(java.net.URISyntaxException) CommandLineParseException(org.apache.nifi.toolkit.tls.commandLine.CommandLineParseException)

Example 2 with GetStatusConfig

use of org.apache.nifi.toolkit.tls.configuration.GetStatusConfig in project nifi by apache.

the class TlsToolkitGetStatusCommandLineTest method testSuccess.

@Test
public void testSuccess() {
    try {
        final String urlStr = "https://localhost:8443/test";
        commandLine.parse("-u", urlStr, "-ts", "src/test/resources/localhost/truststore.jks", "-tst", "JKS", "-tsp", "t7rmn1fg8np2ck1sduqdd85opv");
        final GetStatusConfig config = commandLine.createConfig();
        Assert.assertNotNull(config);
        final URI url = config.getUrl();
        Assert.assertNotNull(url);
        Assert.assertEquals(urlStr, url.toString());
        final SSLContext sslContext = config.getSslContext();
        Assert.assertNotNull(sslContext);
    } catch (CommandLineParseException e) {
        fail("Expected success");
    }
}
Also used : CommandLineParseException(org.apache.nifi.toolkit.tls.commandLine.CommandLineParseException) SSLContext(javax.net.ssl.SSLContext) URI(java.net.URI) GetStatusConfig(org.apache.nifi.toolkit.tls.configuration.GetStatusConfig) Test(org.junit.Test)

Aggregations

CommandLineParseException (org.apache.nifi.toolkit.tls.commandLine.CommandLineParseException)2 GetStatusConfig (org.apache.nifi.toolkit.tls.configuration.GetStatusConfig)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 SSLContext (javax.net.ssl.SSLContext)1 Test (org.junit.Test)1