- // <Private Hex Key> -iv <16 Bytes IV extracted from Encrypted String>
- private static final String ALGORITHM = "AES";
- private static final String ALGORYTHM_DETAILS = ALGORITHM + "/CBC/PKCS5PADDING";
- private static final int BLOCK_SIZE = 128;
- private static final String KEY_PARAM = "org.onap.clamp.encryption.aes.key";
- private static SecretKeySpec secretKeySpec = null;
- private IvParameterSpec ivspec;
- static {
- Properties props = new Properties();
- try {
- props.load(ResourceFileUtil.getResourceAsStream("clds/key.properties"));
- secretKeySpec = getSecretKeySpec(props.getProperty(KEY_PARAM));
- } catch (IOException | DecoderException e) {
- logger.error("Exception occurred during the key reading", e);
- }
+ // <Private Hex Key> -iv <16 Bytes IV extracted from Encrypted String, be
+ // careful it's 32 Hex Chars>
+ /**
+ * Definition of encryption algorithm.
+ */
+ private static final String ALGORITHM = "AES";
+
+ /**
+ * AES Encryption Key environment variable for external configuration.
+ */
+ private static final String AES_ENCRYPTION_KEY = "AES_ENCRYPTION_KEY";
+
+ /**
+ * Detailed definition of encryption algorithm.
+ */
+ private static final String ALGORITHM_DETAILS = ALGORITHM + "/CBC/PKCS5PADDING";
+ private static final int IV_BLOCK_SIZE_IN_BITS = 128;
+ /**
+ * An Initial Vector of 16 Bytes, so 32 Hexadecimal Chars.
+ */
+ private static final int IV_BLOCK_SIZE_IN_BYTES = IV_BLOCK_SIZE_IN_BITS / 8;
+ /**
+ * Key to read in the key.properties file.
+ */
+ private static final String KEY_PARAM = "org.onap.clamp.encryption.aes.key";
+ private static final String PROPERTIES_FILE_NAME = "clds/key.properties";
+ /**
+ * The SecretKeySpec created from the Base 64 String key.
+ */
+ private static final SecretKeySpec SECRET_KEY_SPEC = readSecretKeySpec(PROPERTIES_FILE_NAME);
+
+ /**
+ * Private constructor to avoid creating instances of util class.
+ */
+ private CryptoUtils() {