diff options
author | Chou, Joseph <jc2555@att.com> | 2019-03-18 13:10:36 -0400 |
---|---|---|
committer | Chou, Joseph <jc2555@att.com> | 2019-03-18 13:18:14 -0400 |
commit | 146284191ee01ea92441fdf3159e9dcd84a6f11a (patch) | |
tree | 079e48c31b5c6e73228eff7c71d6a918c196d5e5 /utils | |
parent | 1ea998182b78ee8e857aa2974c554ca952f1f68f (diff) |
ONAP password encryption tool sonar fix
Update code to fix sonar scan issues
Change-Id: I5ccf3d774651bd3d8df908c1e7fe83218016a007
Issue-ID: POLICY-1561
Signed-off-by: Chou, Joseph <jc2555@att.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java | 50 |
1 files changed, 25 insertions, 25 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 ade8b467..ebe0483f 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 @@ -64,36 +64,14 @@ public class CryptoUtils { private static final String RANDOM_NUMBER_GENERATOR = "SHA1PRNG"; /** - * This method is used as the main entry point when testing. - * + * CryptoUtils - encryption tool constructor. + * @param secretKey + * AES supports 128, 192 or 256-bit long key size, it can be plain text or generated with key generator */ - public static void main(String[] args) { - if (args.length == 3) { - if (args[0].equals("enc")) { - String encryptedValue = encrypt(args[1], args[2]); - logger.info("original value: " + args[1] + " encrypted value: " + encryptedValue); - } else if (args[0].equals("dec")) { - String decryptedValue = decrypt(args[1], args[2]); - logger.info("original value: " + args[1] + " decrypted value: " + decryptedValue); - } else { - logger.info("Unknown request: " + args[0]); - } - } else { - logger.info("Usage : CryptoUtils enc/dec password secretKey"); - logger.info("Example: CryptoUtils enc HelloWorld 1234"); - logger.info("Example: CryptoUtils dec enc:112233 1234"); - } - } - public CryptoUtils(SecretKeySpec secretKeySpec) { this.secretKeySpec = secretKeySpec; } - /** - * CryptoUtils - encryption tool constructor. - * @param secretKey - * AES supports 128, 192 or 256-bit long key size, it can be plain text or generated with key generator - */ public CryptoUtils(String secretKey) { this.secretKeySpec = readSecretKeySpec(secretKey); } @@ -256,4 +234,26 @@ public class CryptoUtils { public static Boolean isEncrypted(String value) { return (value != null && value.startsWith("enc:")); } + + /** + * This method is used as the main entry point when testing. + * + */ + public static void main(String[] args) { + if (args.length == 3) { + if ("enc".equals(args[0])) { + String encryptedValue = encrypt(args[1], args[2]); + logger.info("original value: " + args[1] + " encrypted value: " + encryptedValue); + } else if ("dec".equals(args[0])) { + String decryptedValue = decrypt(args[1], args[2]); + logger.info("original value: " + args[1] + " decrypted value: " + decryptedValue); + } else { + logger.info("Unknown request: " + args[0]); + } + } else { + logger.info("Usage : CryptoUtils enc/dec password secretKey"); + logger.info("Example: CryptoUtils enc HelloWorld 1234"); + logger.info("Example: CryptoUtils dec enc:112233 1234"); + } + } }
\ No newline at end of file |