diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-11-17 12:08:32 +0100 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-11-17 12:08:32 +0100 |
commit | f73e0b1ff4282aca2e7cb186be7acb12d3ed446b (patch) | |
tree | 757f2aeba530f8bc45245c50c2e685f83c6360ec /src/main/java | |
parent | 98344de96ed80b839929be0bd272753675009a5d (diff) |
Fix for Checkstyle
Fix the checkstyle issues reported by the tool
Change-Id: Ia330dcf6eead508b0c250d85617ea599c3ce42aa
Issue-ID: CLAMP-74
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/util/CryptoUtils.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java index 8dbdc77d3..efd72515a 100644 --- a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java +++ b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java @@ -46,7 +46,8 @@ import org.apache.commons.lang3.ArrayUtils; * */ public final class CryptoUtils { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CryptoUtils.class); + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CryptoUtils.class); // Openssl commands: // Encrypt: echo -n "123456" | openssl aes-128-cbc -e -K <Private Hex key> // -iv <16 Hex Bytes iv> | xxd -u -g100 @@ -56,12 +57,14 @@ public final class CryptoUtils { // Decrypt: echo -n 'Encrypted string' | xxd -r -ps | openssl aes-128-cbc -d // -K // <Private Hex Key> -iv <16 Bytes IV extracted from Encrypted String> - private static final String ALGORITHM = "AES"; - private static final String ALGORYTHM_DETAILS = ALGORITHM + "/CBC/PKCS5PADDING"; - private static final int BLOCK_SIZE = 128; - private static final String KEY_PARAM = "org.onap.clamp.encryption.aes.key"; - private static SecretKeySpec secretKeySpec = null; - private IvParameterSpec ivspec; + private static final String ALGORITHM = "AES"; + private static final String ALGORYTHM_DETAILS = ALGORITHM + "/CBC/PKCS5PADDING"; + private static final int BLOCK_SIZE = 128; + private static final String KEY_PARAM = "org.onap.clamp.encryption.aes.key"; + private static SecretKeySpec secretKeySpec = null; + private IvParameterSpec ivspec; + + // Static init static { Properties props = new Properties(); try { @@ -76,6 +79,7 @@ public final class CryptoUtils { * Encrypt a value based on the Clamp Encryption Key. * * @param value + * The value to encrypt * @return The encrypted string * @throws GeneralSecurityException * In case of issue with the encryption @@ -84,16 +88,16 @@ public final class CryptoUtils { */ public String encrypt(String value) throws GeneralSecurityException, UnsupportedEncodingException { Cipher cipher = Cipher.getInstance(CryptoUtils.ALGORYTHM_DETAILS, "SunJCE"); - SecureRandom r = SecureRandom.getInstance("SHA1PRNG"); + SecureRandom randomNumber = SecureRandom.getInstance("SHA1PRNG"); byte[] iv = new byte[BLOCK_SIZE / 8]; - r.nextBytes(iv); + randomNumber.nextBytes(iv); ivspec = new IvParameterSpec(iv); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivspec); return Hex.encodeHexString(ArrayUtils.addAll(iv, cipher.doFinal(value.getBytes("UTF-8")))); } /** - * Decrypt a value based on the Clamp Encryption Key + * Decrypt a value based on the Clamp Encryption Key. * * @param message * The encrypted string that must be decrypted using the Clamp |