Search in sources :

Example 6 with NiFiRegistryProperties

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;
}
Also used : IntegrationTestBase.loadNiFiRegistryProperties(org.apache.nifi.registry.web.api.IntegrationTestBase.loadNiFiRegistryProperties) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Bean(org.springframework.context.annotation.Bean)

Example 7 with NiFiRegistryProperties

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;
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties)

Example 8 with NiFiRegistryProperties

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);
    }
}
Also used : CryptoKeyProvider(org.apache.nifi.registry.security.crypto.CryptoKeyProvider) BootstrapFileCryptoKeyProvider(org.apache.nifi.registry.security.crypto.BootstrapFileCryptoKeyProvider) BootstrapFileCryptoKeyProvider(org.apache.nifi.registry.security.crypto.BootstrapFileCryptoKeyProvider) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties)

Example 9 with NiFiRegistryProperties

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);
    }
}
Also used : SensitivePropertyProtectionException(org.apache.nifi.registry.properties.SensitivePropertyProtectionException) MissingCryptoKeyException(org.apache.nifi.registry.security.crypto.MissingCryptoKeyException) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties)

Aggregations

NiFiRegistryProperties (org.apache.nifi.registry.properties.NiFiRegistryProperties)9 Test (org.junit.Test)5 ExtensionManager (org.apache.nifi.registry.extension.ExtensionManager)4 Properties (java.util.Properties)1 FlowPersistenceProvider (org.apache.nifi.registry.flow.FlowPersistenceProvider)1 SensitivePropertyProtectionException (org.apache.nifi.registry.properties.SensitivePropertyProtectionException)1 AuthorizerConfigurationContext (org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext)1 BootstrapFileCryptoKeyProvider (org.apache.nifi.registry.security.crypto.BootstrapFileCryptoKeyProvider)1 CryptoKeyProvider (org.apache.nifi.registry.security.crypto.CryptoKeyProvider)1 MissingCryptoKeyException (org.apache.nifi.registry.security.crypto.MissingCryptoKeyException)1 StandardPropertyValue (org.apache.nifi.registry.util.StandardPropertyValue)1 IntegrationTestBase.loadNiFiRegistryProperties (org.apache.nifi.registry.web.api.IntegrationTestBase.loadNiFiRegistryProperties)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Bean (org.springframework.context.annotation.Bean)1