aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main
diff options
context:
space:
mode:
authorSkip Wonnell <skip@att.com>2017-08-31 09:27:46 -0500
committerRanda Maher <rx196w@att.com>2017-08-31 16:16:57 +0000
commitdc2344fc5754dee739f1db69cc6c16dfe0522ab8 (patch)
treeaaf495f6cdb32c7c1dac4dae6bd268210ee26d0d /appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main
parent102de988205cccf31e30db6d7f4c27af21404d48 (diff)
Fix sonar blocker in ChefAdpater
Issue-ID: APPC-156 Change-Id: Ic2cbb76bb639094386c14bd06e068c9d5ad7bd0d Signed-off-by: Skip Wonnell <skip@att.com>
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main')
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java20
1 files changed, 5 insertions, 15 deletions
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;
}
-
}