public class CryptoUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
private static String |
FILE_BASED_KEY_PROVIDER_CLASS_NAME |
private static Pattern |
HEX_PATTERN |
static int |
IV_LENGTH |
private static String |
LEGACY_FBKP_FQCN |
private static String |
LEGACY_SKP_FQCN |
private static org.slf4j.Logger |
logger |
private static String |
STATIC_KEY_PROVIDER_CLASS_NAME |
private static List<Integer> |
UNLIMITED_KEY_LENGTHS |
| Constructor and Description |
|---|
CryptoUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
concatByteArrays(byte[]... arrays)
Concatenates multiple byte[] into a single byte[].
|
static SecretKey |
formKeyFromHex(String keyHex)
Returns a
SecretKey formed from the hexadecimal key bytes (validity is checked). |
(package private) static String |
handleLegacyPackages(String implementationClassName) |
static boolean |
isEmpty(String src)
Utility method which returns true if the string is null, empty, or entirely whitespace.
|
static boolean |
isHexString(String hexString)
Returns true if the input is valid hexadecimal (does not enforce length and is case-insensitive).
|
static boolean |
isProvenanceRepositoryEncryptionConfigured(NiFiProperties niFiProperties) |
static boolean |
isUnlimitedStrengthCryptoAvailable() |
static boolean |
isValidKeyProvider(String keyProviderImplementation,
String keyProviderLocation,
String keyId,
Map<String,String> encryptionKeys)
Returns true if the provided configuration values successfully define the specified
KeyProvider. |
static boolean |
keyIsValid(String encryptionKeyHex)
Returns true if the provided key is valid hex and is the correct length for the current system's JCE policies.
|
static Map<String,SecretKey> |
readKeys(String filepath,
SecretKey masterKey)
Returns a map containing the key IDs and the parsed key from a key provider definition file.
|
private static final org.slf4j.Logger logger
private static final String STATIC_KEY_PROVIDER_CLASS_NAME
private static final String FILE_BASED_KEY_PROVIDER_CLASS_NAME
private static final String LEGACY_SKP_FQCN
private static final String LEGACY_FBKP_FQCN
private static final Pattern HEX_PATTERN
public static final int IV_LENGTH
public static boolean isUnlimitedStrengthCryptoAvailable()
public static boolean isEmpty(String src)
src - the string to evaluatepublic static byte[] concatByteArrays(byte[]... arrays)
throws IOException
arrays - the component byte[] in orderIOException - this should never be thrownpublic static boolean isValidKeyProvider(String keyProviderImplementation, String keyProviderLocation, String keyId, Map<String,String> encryptionKeys)
KeyProvider.keyProviderImplementation - the FQ class name of the KeyProvider implementationkeyProviderLocation - the location of the definition (for FileBasedKeyProvider, etc.)keyId - the active key IDencryptionKeys - a map of key IDs to key material in hex formatstatic String handleLegacyPackages(String implementationClassName) throws KeyManagementException
KeyManagementExceptionpublic static boolean keyIsValid(String encryptionKeyHex)
encryptionKeyHex - the key in hexadecimalpublic static boolean isHexString(String hexString)
hexString - the string to evaluatepublic static SecretKey formKeyFromHex(String keyHex) throws KeyManagementException
SecretKey formed from the hexadecimal key bytes (validity is checked).keyHex - the key in hex formKeyManagementExceptionpublic static Map<String,SecretKey> readKeys(String filepath, SecretKey masterKey) throws KeyManagementException
KeyManagementException will be thrown.filepath - the key definition file pathmasterKey - the master key used to decrypt each key definitionKeyManagementException - if the file is missing or invalidpublic static boolean isProvenanceRepositoryEncryptionConfigured(NiFiProperties niFiProperties)
Copyright © 2018 Apache NiFi Project. All rights reserved.