Search in sources :

Example 1 with MissingCryptoKeyException

use of org.apache.nifi.registry.security.crypto.MissingCryptoKeyException 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)1 SensitivePropertyProtectionException (org.apache.nifi.registry.properties.SensitivePropertyProtectionException)1 MissingCryptoKeyException (org.apache.nifi.registry.security.crypto.MissingCryptoKeyException)1