summaryrefslogtreecommitdiffstats
path: root/ansible-adapter/ansible-adapter-bundle
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2018-10-26 15:24:33 +0900
committerParshad Patel <pars.patel@samsung.com>2018-10-26 15:24:47 +0900
commitdf4a7a3530a0c52c17b1cb9a412de0c5b3fd01b3 (patch)
tree5d58c61aa6c8cbfd976549412ceb7d83f4dcd831 /ansible-adapter/ansible-adapter-bundle
parentf9865fbaaffa841172ca0ae8e5c05cb95d1c7d0c (diff)
Fix sonar blocker issue in sli/adapters
Fix use try-with-resources issues in ansible-adapter,salstack-adapter Issue-ID: CCSDK-629 Change-Id: Ie8457751c155aa95fdfcdf2faad4cd8089a58ad3 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'ansible-adapter/ansible-adapter-bundle')
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
index fbc77346c..645a7baf3 100644
--- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
@@ -79,22 +79,22 @@ public class ConnectionBuilder {
KeyManagementException, NoSuchAlgorithmException, SvcLogicException {
/* Point to the certificate */
- FileInputStream fs = new FileInputStream(certFile);
+ try(FileInputStream fs = new FileInputStream(certFile)){
+ /* Generate a certificate from the X509 */
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate) cf.generateCertificate(fs);
- /* Generate a certificate from the X509 */
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate) cf.generateCertificate(fs);
+ /* Create a keystore object and load the certificate there */
+ KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ keystore.load(null, null);
+ keystore.setCertificateEntry("cacert", cert);
- /* Create a keystore object and load the certificate there */
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- keystore.load(null, null);
- keystore.setCertificateEntry("cacert", cert);
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
- SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
- SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
- SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- httpClient = HttpClients.custom().setSSLSocketFactory(factory).build();
+ httpClient = HttpClients.custom().setSSLSocketFactory(factory).build();
+ }
}
/**