public class RepositoryEncryptorUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
CONTENT_HEADER_SIZE |
private static byte[] |
EMPTY_IV |
private static String |
EWAPR_CLASS_NAME |
private static int |
IV_LENGTH |
private static org.slf4j.Logger |
logger |
private static int |
METADATA_DEFAULT_LENGTH |
private static int |
MIN_METADATA_LENGTH |
private static List<String> |
SUPPORTED_VERSIONS |
private static String |
VERSION |
| Constructor and Description |
|---|
RepositoryEncryptorUtils() |
| Modifier and Type | Method and Description |
|---|---|
private static KeyProvider |
buildKeyProvider(NiFiProperties niFiProperties,
RepositoryType repositoryType)
Returns a configured
KeyProvider instance that does not require a master key to use (usually a StaticKeyProvider). |
static KeyProvider |
buildKeyProvider(NiFiProperties niFiProperties,
SecretKey masterKey,
RepositoryType repositoryType)
Returns a configured
KeyProvider instance that requires a master key to use
(usually a FileBasedKeyProvider or an encrypted
StaticKeyProvider). |
static KeyProvider |
buildKeyProviderFromConfig(SecretKey masterKey,
RepositoryEncryptionConfiguration rec)
Returns a configured
KeyProvider instance given the RepositoryEncryptionConfiguration. |
(package private) static String |
determineKeyProviderImplementationClassName(RepositoryType repositoryType)
Utility method which returns the
KeyProvider implementation class name for a given repository type. |
static byte[] |
extractCipherBytes(byte[] encryptedRecord,
RepositoryObjectEncryptionMetadata metadata) |
static RepositoryObjectEncryptionMetadata |
extractEncryptionMetadata(byte[] encryptedRecord) |
static RepositoryObjectEncryptionMetadata |
extractEncryptionMetadata(InputStream encryptedRecord) |
static Cipher |
initCipher(AESKeyedCipherProvider aesKeyedCipherProvider,
EncryptionMethod method,
int mode,
SecretKey key,
byte[] ivBytes) |
(package private) static boolean |
isContentRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
Returns
true if the content repository is correctly configured for an encrypted
implementation. |
(package private) static boolean |
isFlowFileRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
Returns
true if the flowfile repository is correctly configured for an encrypted
implementation. |
(package private) static boolean |
isProvenanceRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
Returns
true if the provenance repository is correctly configured for an
encrypted implementation. |
static boolean |
isRepositoryEncryptionConfigured(NiFiProperties niFiProperties,
RepositoryType repositoryType)
Returns
true if the specified repository is correctly configured for an
encrypted implementation. |
static byte[] |
serializeEncryptionMetadata(RepositoryObjectEncryptionMetadata metadata) |
static KeyProvider |
validateAndBuildRepositoryKeyProvider(NiFiProperties niFiProperties,
RepositoryType repositoryType)
Returns a configured
KeyProvider instance for the specified repository type given the configuration values in nifi.properties. |
static KeyProvider |
validateAndBuildRepositoryKeyProvider(RepositoryEncryptionConfiguration repositoryEncryptionConfiguration)
Returns a configured
KeyProvider instance for the specified repository type given the configuration values. |
private static final org.slf4j.Logger logger
private static final int CONTENT_HEADER_SIZE
private static final int IV_LENGTH
private static final byte[] EMPTY_IV
private static final String VERSION
private static final int MIN_METADATA_LENGTH
private static final int METADATA_DEFAULT_LENGTH
private static final String EWAPR_CLASS_NAME
public static byte[] serializeEncryptionMetadata(RepositoryObjectEncryptionMetadata metadata) throws IOException
IOExceptionpublic static Cipher initCipher(AESKeyedCipherProvider aesKeyedCipherProvider, EncryptionMethod method, int mode, SecretKey key, byte[] ivBytes) throws EncryptionException
EncryptionExceptionpublic static RepositoryObjectEncryptionMetadata extractEncryptionMetadata(byte[] encryptedRecord) throws EncryptionException, IOException, ClassNotFoundException
public static RepositoryObjectEncryptionMetadata extractEncryptionMetadata(InputStream encryptedRecord) throws EncryptionException, IOException, ClassNotFoundException
public static byte[] extractCipherBytes(byte[] encryptedRecord,
RepositoryObjectEncryptionMetadata metadata)
public static boolean isRepositoryEncryptionConfigured(NiFiProperties niFiProperties, RepositoryType repositoryType)
true if the specified repository is correctly configured for an
encrypted implementation. Requires the repository implementation to support encryption
and at least one valid key to be configured.niFiProperties - the NiFiProperties instance to validaterepositoryType - the specific repository configuration to checkstatic boolean isProvenanceRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
true if the provenance repository is correctly configured for an
encrypted implementation. Requires the repository implementation to support encryption
and at least one valid key to be configured.niFiProperties - the NiFiProperties instance to validatestatic boolean isContentRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
true if the content repository is correctly configured for an encrypted
implementation. Requires the repository implementation to support encryption and at least
one valid key to be configured.niFiProperties - the NiFiProperties instance to validatestatic boolean isFlowFileRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
true if the flowfile repository is correctly configured for an encrypted
implementation. Requires the repository implementation to support encryption and at least
one valid key to be configured.niFiProperties - the NiFiProperties instance to validateprivate static KeyProvider buildKeyProvider(NiFiProperties niFiProperties, RepositoryType repositoryType) throws KeyManagementException
KeyProvider instance that does not require a master key to use (usually a StaticKeyProvider).niFiProperties - the NiFiProperties objectrepositoryType - the RepositoryType indicatorKeyManagementException - if there is a problem with the configurationpublic static KeyProvider buildKeyProvider(NiFiProperties niFiProperties, SecretKey masterKey, RepositoryType repositoryType) throws KeyManagementException
KeyProvider instance that requires a master key to use
(usually a FileBasedKeyProvider or an encrypted
StaticKeyProvider).niFiProperties - the NiFiProperties objectmasterKey - the master encryption key used to encrypt the data encryption keys in the key provider configurationrepositoryType - the RepositoryType indicatorKeyManagementException - if there is a problem with the configurationpublic static KeyProvider buildKeyProviderFromConfig(SecretKey masterKey, RepositoryEncryptionConfiguration rec) throws KeyManagementException
KeyProvider instance given the RepositoryEncryptionConfiguration.masterKey - the master encryption key used to encrypt the data encryption keys in the key provider configurationrec - the repository-specific encryption configurationKeyManagementException - if there is a problem with the configurationstatic String determineKeyProviderImplementationClassName(RepositoryType repositoryType)
KeyProvider implementation class name for a given repository type.repositoryType - the RepositoryType indicator"no_such_key_provider_defined" for unsupported repository typespublic static KeyProvider validateAndBuildRepositoryKeyProvider(NiFiProperties niFiProperties, RepositoryType repositoryType) throws IOException
KeyProvider instance for the specified repository type given the configuration values in nifi.properties.niFiProperties - the NiFiProperties objectrepositoryType - the RepositoryType indicatorIOException - if there is a problem reading the properties or they are not valid & completepublic static KeyProvider validateAndBuildRepositoryKeyProvider(RepositoryEncryptionConfiguration repositoryEncryptionConfiguration) throws IOException
KeyProvider instance for the specified repository type given the configuration values.repositoryEncryptionConfiguration - the RepositoryEncryptionConfiguration objectIOException - if there is a problem reading the properties or they are not valid & completeCopyright © 2020 Apache NiFi Project. All rights reserved.