summaryrefslogtreecommitdiffstats
path: root/security-util-lib/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'security-util-lib/src/main/java/org/onap')
-rw-r--r--security-util-lib/src/main/java/org/onap/sdc/security/SecurityUtil.java15
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) {