diff options
author | Ojas Dubey <Ojas.Dubey@amdocs.com> | 2019-12-11 12:03:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-12-11 12:03:38 +0000 |
commit | 801d6cec8b8bfdd8b9259ebfbf7714ce430d02ef (patch) | |
tree | e8d8af21143488b5de7baebb2d5d18a0f94b3b1f | |
parent | 51d0a0adc0c7b065fd39a98f1f02ab910271968f (diff) | |
parent | 6137426ec6e7963a150dfc8011198109db730a0b (diff) |
Merge "Fix Sonar issues"
-rw-r--r-- | security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java b/security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java index 27d946f..349e893 100644 --- a/security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java +++ b/security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java @@ -45,7 +45,7 @@ public class SecurityUtil { public static final String ALGORITHM = "AES"; public static final String CHARSET = UTF_8.name(); - public static Key secKey = null; + private final static Key secKey = generateKey(KEY, ALGORITHM); /** * cmd commands >$PROGRAM_NAME decrypt "$ENCRYPTED_MSG" @@ -55,19 +55,16 @@ public class SecurityUtil { private SecurityUtil() { } - static { + + public static Key generateKey(final byte[] KEY, String algorithm) { try { - secKey = generateKey(KEY, ALGORITHM); + return new SecretKeySpec(KEY, algorithm); } catch (Exception e) { - LOG.warn(EcompLoggerErrorCode.PERMISSION_ERROR,"cannot generate key for {}", ALGORITHM); + LOG.warn(EcompLoggerErrorCode.PERMISSION_ERROR, "cannot generate key for {}, message : {} .", ALGORITHM, e.getMessage()); + return null; } } - - public static Key generateKey(final byte[] KEY, String algorithm) { - return new SecretKeySpec(KEY, algorithm); - } - //obfuscates key prefix -> ********** public String obfuscateKey(String sensitiveData) { |