From 096c0fee2751a8bac1e67b21867e5b23f6a93b63 Mon Sep 17 00:00:00 2001 From: ajay priyadarshi Date: Wed, 14 Mar 2018 12:05:08 +0530 Subject: sonar fix:cbam serialization VimInfoType cbam/bo/entity/VimInfoType.java file name: OpenstackV2Info.java, OpenstackV3Info.java ... Change-Id: I10e90b59851513406e06d6f6701c7371ce6d3c5a Issue-ID: VFC-813 Signed-off-by: ajay priyadarshi --- .../vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java | 7 ++--- .../vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java | 5 ++- .../vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java | 5 ++- .../vnfm/svnfm/cbam/bo/entity/VimInfoType.java | 36 +++++++++------------- .../svnfm/cbam/bo/entity/VmwareVcloudInfo.java | 3 +- 5 files changed, 23 insertions(+), 33 deletions(-) (limited to 'nokia/vnfmdriver/vfcadaptorservice') diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java index 3ffa0fb0..1f1eb1ca 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java @@ -14,10 +14,10 @@ * limitations under the License. */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity; - +import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonProperty; -public class OpenstackV2Info { +public class OpenstackV2Info implements Serializable { @JsonProperty("vimInfoType") private VimInfoType vimInfoType; @@ -52,7 +52,4 @@ public class OpenstackV2Info { this.accessInfo = accessInfo; } - - - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java index 22de770e..7d4c53e6 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java @@ -16,8 +16,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity; import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; -public class OpenstackV3Info { +public class OpenstackV3Info implements Serializable { @JsonProperty("vimInfoType") private VimInfoType vimInfoType; @@ -52,6 +53,4 @@ public class OpenstackV3Info { this.accessInfo = accessInfo; } - - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java index 4b7fb072..1cedf98b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java @@ -15,9 +15,10 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity; +import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonProperty; -public class OtherVimInfo { +public class OtherVimInfo implements Serializable { @JsonProperty("vimInfoType") private VimInfoType vimInfoType; @@ -40,6 +41,4 @@ public class OtherVimInfo { this.id = id; } - - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java index 779e2659..5be96a88 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java @@ -14,28 +14,22 @@ * limitations under the License. */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity; +import java.io.Serializable; -public enum VimInfoType { - - OPENSTACK_V2_INFO { +public enum VimInfoType implements Serializable{ + + OPENSTACK_V2_INFO { private OpenstackV2Info openstackv2; - - }, - OPENSTACK_V3_INFO{ - private OpenstackV3Info openstackv3; - }, - VMWARE_VCLOUD_INFO{ - private VmwareVcloudInfo vmwareInfo; - }, - OTHER_VIM_INFO{ - private OtherVimInfo other; - } - - - - - - - + + }, + OPENSTACK_V3_INFO{ + private OpenstackV3Info openstackv3; + }, + VMWARE_VCLOUD_INFO{ + private VmwareVcloudInfo vmwareInfo; + }, + OTHER_VIM_INFO{ + private OtherVimInfo other; + } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java index 746cb007..73446461 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java @@ -15,9 +15,10 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity; +import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonProperty; -public class VmwareVcloudInfo { +public class VmwareVcloudInfo implements Serializable{ @JsonProperty("vimInfoType") private VimInfoType vimInfoType; -- cgit 1.2.3-korg From 5c76dfc8933c0c1b51c4c72865b4b05628130178 Mon Sep 17 00:00:00 2001 From: ajay priyadarshi Date: Wed, 14 Mar 2018 12:56:15 +0530 Subject: sonar fix:R&E handling in MultipartUtility cbam/impl/MultipartUtility.java file name: MultipartUtility.java Change-Id: Ie54ef11b5bae5d56cc9b045325af7c0ddbace825 Issue-ID: VFC-814 Signed-off-by: ajay priyadarshi --- .../vnfm/svnfm/cbam/impl/MultipartUtility.java | 40 ++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'nokia/vnfmdriver/vfcadaptorservice') diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java index f8f0c400..834c2a7b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java @@ -32,6 +32,8 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; +import java.security.NoSuchAlgorithmException; +import java.security.KeyManagementException; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -74,7 +76,7 @@ public class MultipartUtility { * @throws IOException */ public MultipartUtility(String requestURL, String charset) - throws Exception { + throws CertificateException, IOException, NoSuchAlgorithmException, KeyManagementException{ this.charset = charset; // creates a unique boundary based on time stamp @@ -165,10 +167,10 @@ public class MultipartUtility { KEY_STORE_TYPE = sslConf.getKeyStoreType(); } // load jks file - FileInputStream f_certStore = new FileInputStream(CommonUtil.getAppRoot() + CERT_STORE); - KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); - ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); - f_certStore.close(); + try(FileInputStream f_certStore = new FileInputStream(CommonUtil.getAppRoot() + CERT_STORE)){ + KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); + ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); + // init and create String alg = KeyManagerFactory.getDefaultAlgorithm(); @@ -176,6 +178,7 @@ public class MultipartUtility { kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray()); kms = kmFact.getKeyManagers(); + } } catch(Exception e) { logger.error("create KeyManager fail!", e); } @@ -196,15 +199,16 @@ public class MultipartUtility { } String jksFilePath1 =CommonUtil.getAppRoot() + TRUST_STORE; logger.info("jks path is " + jksFilePath1); - FileInputStream f_trustStore = new FileInputStream(jksFilePath1); - KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); - ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); - f_trustStore.close(); + try(FileInputStream f_trustStore = new FileInputStream(jksFilePath1)){ + KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); + ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); + String alg = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg); tmFact.init(ks); tms = tmFact.getTrustManagers(); + } } catch(Exception e) { logger.error("create TrustManager fail!", e); @@ -235,14 +239,14 @@ public class MultipartUtility { writer.append(LINE_FEED); writer.flush(); - FileInputStream inputStream = new FileInputStream(uploadFile); - byte[] buffer = new byte[4096]; - int bytesRead = -1; - while ((bytesRead = inputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, bytesRead); - } - outputStream.flush(); - inputStream.close(); + try(FileInputStream inputStream = new FileInputStream(uploadFile)){ + byte[] buffer = new byte[4096]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.flush(); + } writer.append(LINE_FEED); writer.flush(); @@ -289,4 +293,4 @@ public class MultipartUtility { return response; } -} \ No newline at end of file +} -- cgit 1.2.3-korg