Sonar critical fixes in MicroserviceServiceImpl 51/88351/2
authorr.bogacki <r.bogacki@samsung.com>
Thu, 23 May 2019 12:59:56 +0000 (14:59 +0200)
committerRobert Bogacki <r.bogacki@samsung.com>
Mon, 10 Jun 2019 10:10:23 +0000 (10:10 +0000)
Fixed critical issues according to the Sonar analysis:
-Fixed imports.
-Fixed logical comparisons.

Issue-ID: PORTAL-591
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: Icc2b6fb45777582486e1060245cdf94e4f6d685d

ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java

index e90aeb7..6c9161d 100644 (file)
@@ -4,6 +4,8 @@
  * ===================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
  * under the Apache License, Version 2.0 (the "License");
@@ -42,8 +44,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.crypto.BadPaddingException;
-
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Restrictions;
 import org.onap.portalapp.portal.domain.MicroserviceData;
@@ -196,7 +196,7 @@ public class MicroserviceServiceImpl implements MicroserviceService {
 
        private String decryptedPassword(String encryptedPwd) throws Exception {
                String result = "";
-               if (encryptedPwd != null & encryptedPwd.length() > 0) {
+               if (encryptedPwd != null && !encryptedPwd.isEmpty()) {
                        try {
                                result = CipherUtil.decryptPKC(encryptedPwd,
                                                SystemProperties.getProperty(SystemProperties.Decryption_Key));
@@ -210,7 +210,7 @@ public class MicroserviceServiceImpl implements MicroserviceService {
 
        private String encryptedPassword(String decryptedPwd) throws Exception {
                String result = "";
-               if (decryptedPwd != null & decryptedPwd.length() > 0) {
+               if (decryptedPwd != null && !decryptedPwd.isEmpty()) {
                        try {
                                result = CipherUtil.encryptPKC(decryptedPwd,
                                                SystemProperties.getProperty(SystemProperties.Decryption_Key));