use of org.apache.nifi.toolkit.tls.properties.NiFiPropertiesWriter in project nifi by apache.
the class NifiPropertiesTlsClientConfigWriter method updateProperties.
protected void updateProperties(NiFiPropertiesWriter niFiPropertiesWriter, TlsClientConfig tlsClientConfig) throws IOException {
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_KEYSTORE, CONF + new File(tlsClientConfig.getKeyStore()).getName());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_KEYSTORE_TYPE, tlsClientConfig.getKeyStoreType());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_KEYSTORE_PASSWD, tlsClientConfig.getKeyStorePassword());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_KEY_PASSWD, tlsClientConfig.getKeyPassword());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_TRUSTSTORE, CONF + new File(tlsClientConfig.getTrustStore()).getName());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_TRUSTSTORE_TYPE, tlsClientConfig.getTrustStoreType());
niFiPropertiesWriter.setPropertyValue(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD, tlsClientConfig.getTrustStorePassword());
getHostnamePropertyStream().forEach(s -> niFiPropertiesWriter.setPropertyValue(s, hostname));
overlayProperties.stringPropertyNames().stream().filter(s -> !metaProperties.contains(s)).forEach(s -> niFiPropertiesWriter.setPropertyValue(s, overlayProperties.getProperty(s)));
getIncrementingPropertyMap().entrySet().forEach(nameToIntegerEntry -> niFiPropertiesWriter.setPropertyValue(nameToIntegerEntry.getKey(), Integer.toString(nameToIntegerEntry.getValue())));
}
use of org.apache.nifi.toolkit.tls.properties.NiFiPropertiesWriter in project nifi by apache.
the class NifiPropertiesTlsClientConfigWriter method write.
@Override
public void write(TlsClientConfig tlsClientConfig, OutputStreamFactory outputStreamFactory) throws IOException {
NiFiPropertiesWriter niFiPropertiesWriter = niFiPropertiesWriterFactory.create();
updateProperties(niFiPropertiesWriter, tlsClientConfig);
try (OutputStream stream = outputStreamFactory.create(outputFile)) {
niFiPropertiesWriter.writeNiFiProperties(stream);
}
}
use of org.apache.nifi.toolkit.tls.properties.NiFiPropertiesWriter in project nifi by apache.
the class NifiPropertiesTlsClientConfigWriterTest method setup.
@Before
public void setup() throws IOException {
testHostname = "testHostname";
hostNum = 22;
keyStore = "testKeyStore.jks";
keyStoreType = TlsConfig.DEFAULT_KEY_STORE_TYPE;
keyStorePassword = "badKeyStorePassword";
keyPassword = "badKeyPassword";
trustStore = "testTrustStore.jks";
trustStoreType = TlsConfig.DEFAULT_KEY_STORE_TYPE;
trustStorePassword = "badTrustStorePassword";
outputFile = File.createTempFile("temp", "nifi");
outputStream = new ByteArrayOutputStream();
when(outputStreamFactory.create(outputFile)).thenReturn(outputStream);
tlsClientConfig = new TlsClientConfig();
tlsClientConfig.setKeyStore(keyStore);
tlsClientConfig.setKeyStoreType(keyStoreType);
tlsClientConfig.setKeyStorePassword(keyStorePassword);
tlsClientConfig.setKeyPassword(keyPassword);
tlsClientConfig.setTrustStore(trustStore);
tlsClientConfig.setTrustStoreType(trustStoreType);
tlsClientConfig.setTrustStorePassword(trustStorePassword);
niFiPropertiesWriter = new NiFiPropertiesWriter(new ArrayList<>());
when(niFiPropertiesWriterFactory.create()).thenReturn(niFiPropertiesWriter);
nifiPropertiesTlsClientConfigWriter = new NifiPropertiesTlsClientConfigWriter(niFiPropertiesWriterFactory, outputFile, testHostname, hostNum);
overlayProperties = nifiPropertiesTlsClientConfigWriter.getOverlayProperties();
}
use of org.apache.nifi.toolkit.tls.properties.NiFiPropertiesWriter in project nifi by apache.
the class TlsToolkitStandaloneCommandLineTest method getProperties.
private Properties getProperties() throws IOException {
NiFiPropertiesWriter niFiPropertiesWriter = tlsToolkitStandaloneCommandLine.createConfig().getNiFiPropertiesWriterFactory().create();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
niFiPropertiesWriter.writeNiFiProperties(byteArrayOutputStream);
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
return properties;
}
Aggregations