From dc2344fc5754dee739f1db69cc6c16dfe0522ab8 Mon Sep 17 00:00:00 2001 From: Skip Wonnell Date: Thu, 31 Aug 2017 09:27:46 -0500 Subject: Fix sonar blocker in ChefAdpater Issue-ID: APPC-156 Change-Id: Ic2cbb76bb639094386c14bd06e068c9d5ad7bd0d Signed-off-by: Skip Wonnell --- .../appc/adapter/chef/chefclient/Utils.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle') diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java index d20228e04..2fc836cf0 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java @@ -45,7 +45,7 @@ import org.bouncycastle.openssl.PEMKeyPair; public class Utils { private Utils(){} - + public static String sha1AndBase64(String inStr) { MessageDigest md = null; String outStr = null; @@ -59,18 +59,11 @@ public class Utils { } return new String(outbty); } - + public static String signWithRSA(String inStr, String pemPath) { byte[] outStr = null; - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(pemPath)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - Security.addProvider(new BouncyCastleProvider()); - try { - + try ( BufferedReader br = new BufferedReader(new FileReader(pemPath))) { + Security.addProvider(new BouncyCastleProvider()); PEMParser pemParser = new PEMParser(br); JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); Object object = pemParser.readObject(); @@ -79,10 +72,8 @@ public class Utils { Signature instance = Signature.getInstance("RSA"); instance.initSign(privateKey); instance.update(inStr.getBytes()); - byte[] signature = instance.sign(); outStr = Base64.encode(signature); - String tmp = new String(outStr); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (IOException e) { @@ -94,7 +85,7 @@ public class Utils { } return new String(outStr); } - + public static String[] splitAs60(String inStr) { int count = inStr.length() / 60; String[] out = new String[count + 1]; @@ -109,5 +100,4 @@ public class Utils { } return out; } - } -- cgit 1.2.3-korg