diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2019-10-21 09:08:11 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2019-10-21 09:57:09 -0500 |
commit | 1c9e4e6d0d30e937fd0137ba88c30251c653798f (patch) | |
tree | 70b56732f7b44e7ebf53ae24613938b0fd8fc6d6 /utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java | |
parent | 824468c9138700f046e35e1faaf6dc78eef5d98d (diff) |
Add CryptoCoder interface
This is to allow multiple supporting implementations.
Issue-ID: POLICY-1945
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I42491e5671f561fe320f034bf8ffe03848dff43f
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java b/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java index 69d257ec..416c73a6 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java @@ -33,8 +33,8 @@ import org.slf4j.LoggerFactory; /** * AES Encryption Utilities. */ -public class CryptoUtils { - private static Logger logger = LoggerFactory.getLogger(CryptoUtils.class); +public class CryptoUtils implements CryptoCoder { + private static final Logger logger = LoggerFactory.getLogger(CryptoUtils.class); /** * Definition of encryption algorithm. @@ -90,13 +90,13 @@ public class CryptoUtils { * The plain text string * @return The encrypted String */ + @Override public String encrypt(String value) { return encryptValue(value, secretKeySpec); } /** * Encrypt a value based on the Policy Encryption Key. - * * @param value * The plain text string * @param secretKey @@ -140,6 +140,7 @@ public class CryptoUtils { * The encrypted string that must be decrypted using the Policy Encryption Key * @return The String decrypted if string begin with 'enc:' */ + @Override public String decrypt(String value) { return decryptValue(value, secretKeySpec); } @@ -208,10 +209,8 @@ public class CryptoUtils { */ private static SecretKeySpec readSecretKeySpec(String secretKey) { if (secretKey != null && !secretKey.isEmpty()) { - SecretKeySpec keySpec; try { - keySpec = getSecretKeySpec(secretKey); - return keySpec; + return getSecretKeySpec(secretKey); } catch (Exception e) { logger.error("Invalid key - exception: ", e); return null; @@ -254,4 +253,4 @@ public class CryptoUtils { logger.info("Example: CryptoUtils dec enc:112233 1234"); } } -}
\ No newline at end of file +} |