diff options
author | shrek2000 <oren.kleks@amdocs.com> | 2019-12-04 12:02:27 +0200 |
---|---|---|
committer | Oren Kleks <oren.kleks@amdocs.com> | 2019-12-05 09:58:24 +0000 |
commit | 6137426ec6e7963a150dfc8011198109db730a0b (patch) | |
tree | 95ac84b4bd76945a7ec5a5df3dfca97fa2d2cbe7 /security-util-lib | |
parent | 819c911738e5a982956831c021641d62cc3ea74b (diff) |
Fix Sonar issues
Public class variable fields do not respect the ncapsulation principle
https://sonar.onap.org/project/issues?id=org.onap.sdc.sdc-be-common%3Asdc-be-common-parent%3Amaster&open=AW6fpbQilnf4Fh92BMWX&resolved=false&types=VULNERABILITY
Issue-ID: SDC-2697
Signed-off-by: shrek2000 <oren.kleks@amdocs.com>
Change-Id: I82f9aa980d8a2eb283a11c05a86095a27fad71ab
Signed-off-by: shrek2000 <oren.kleks@amdocs.com>
Diffstat (limited to 'security-util-lib')
-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) { |