use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class SecureITClientConfiguration method getNiFiRegistryClientConfig.
@Bean
public NiFiRegistryClientConfig getNiFiRegistryClientConfig() {
readLock.lock();
try {
if (clientConfig == null) {
final NiFiRegistryProperties clientProperties = loadNiFiRegistryProperties(clientPropertiesFileLocation);
clientConfig = createNiFiRegistryClientConfig(clientProperties);
}
} finally {
readLock.unlock();
}
return clientConfig;
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class LdapUserGroupProviderTest method getNiFiProperties.
private NiFiRegistryProperties getNiFiProperties(final Properties properties) {
final NiFiRegistryProperties registryProperties = Mockito.mock(NiFiRegistryProperties.class);
when(registryProperties.getPropertyKeys()).thenReturn(properties.stringPropertyNames());
when(registryProperties.getProperty(anyString())).then(invocationOnMock -> properties.getProperty((String) invocationOnMock.getArguments()[0]));
return registryProperties;
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class NiFiRegistry method main.
/**
* Main entry point of the application.
*
* @param args things which are ignored
*/
public static void main(String[] args) {
LOGGER.info("Launching NiFi Registry...");
final CryptoKeyProvider masterKeyProvider;
final NiFiRegistryProperties properties;
try {
masterKeyProvider = new BootstrapFileCryptoKeyProvider(REGISTRY_BOOTSTRAP_FILE_LOCATION);
LOGGER.info("Read property protection key from {}", REGISTRY_BOOTSTRAP_FILE_LOCATION);
properties = initializeProperties(masterKeyProvider);
} catch (final IllegalArgumentException iae) {
throw new RuntimeException("Unable to load properties: " + iae, iae);
}
try {
new NiFiRegistry(properties, masterKeyProvider);
} catch (final Throwable t) {
LOGGER.error("Failure to launch NiFi Registry due to " + t, t);
}
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class NiFiRegistry method initializeProperties.
private static NiFiRegistryProperties initializeProperties(CryptoKeyProvider masterKeyProvider) {
String key = CryptoKeyProvider.EMPTY_KEY;
try {
key = masterKeyProvider.getKey();
} catch (MissingCryptoKeyException e) {
LOGGER.debug("CryptoKeyProvider provided to initializeProperties method was empty - did not contain a key.");
// Do nothing. The key can be empty when it is passed to the loader as the loader will only use it if any properties are protected.
}
try {
try {
// Load properties using key. If properties are protected and key missing, throw RuntimeException
NiFiRegistryProperties properties = NiFiRegistryPropertiesLoader.withKey(key).load(REGISTRY_PROPERTIES_FILE_LOCATION);
LOGGER.info("Loaded {} properties", properties.size());
return properties;
} catch (SensitivePropertyProtectionException e) {
final String msg = "There was an issue decrypting protected properties";
LOGGER.error(msg, e);
throw new IllegalArgumentException(msg);
}
} catch (IllegalArgumentException e) {
final String msg = "The bootstrap process did not provide a valid key and there are protected properties present in the properties file";
LOGGER.error(msg, e);
throw new IllegalArgumentException(msg);
}
}
Aggregations