Resubmitting KeyProperty code change since tests failed 71/108771/4
author“Kruthi <krutbhat@att.com>
Thu, 4 Jun 2020 14:04:07 +0000 (19:34 +0530)
committer“Kruthi <krutbhat@att.com>
Tue, 9 Jun 2020 20:04:23 +0000 (01:34 +0530)
Change-Id: I14c0f9b59229e32de45b1652e64c01dd6c1d39e3
Issue-ID: PORTAL-914
Signed-off-by: krutbhat@att.com
13 files changed:
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/service/RemoteWebServiceCallServiceImpl.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/util/SessionCookieUtil.java
ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java

index 5a57e09..e96485d 100644 (file)
@@ -72,6 +72,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
 import org.onap.portalsdk.core.onboarding.util.AuthUtil;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
 import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
@@ -370,7 +372,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
                String result = "";
                if (encrypted != null && encrypted.length() > 0) {
                        try {
-                               result = CipherUtil.decryptPKC(encrypted, SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                               result = CipherUtil.decryptPKC(encrypted, KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
                                throw e;
@@ -384,7 +386,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
                if (decryptedPwd != null && decryptedPwd.length() > 0) {
                        try {
                                result = CipherUtil.encryptPKC(decryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e);
                                throw e;
index 959e392..ab504fb 100644 (file)
@@ -67,6 +67,8 @@ import org.onap.portalapp.util.SystemType;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -194,7 +196,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                        if(!encriptedPwd.isEmpty() || encriptedPwd != null || StringUtils.isEmpty(encriptedPwd)){
                        try {
                                decreptedAppPwd = CipherUtil.decryptPKC(encriptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e);
                        }
@@ -215,7 +217,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
                                String decreptedexternalAppPwd = StringUtils.EMPTY;
                                try {
                                        decreptedexternalAppPwd = CipherUtil.decryptPKC(password,
-                                                       SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                                       KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                                } catch (CipherUtilException e) {
                                        logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e);
                                }
index 98b0f12..151430d 100644 (file)
@@ -52,6 +52,8 @@ import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
 import org.onap.portalapp.validation.DataValidator;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -229,7 +231,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{
                if (encryptedPwd != null && encryptedPwd.length() > 0) {
                        try {
                                result = CipherUtil.decryptPKC(encryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword() failed", e);
                                throw e;
@@ -243,7 +245,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{
                if (decryptedPwd != null && decryptedPwd.length() > 0) {
                        try {
                                result = CipherUtil.encryptPKC(decryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e);
                                throw e;
index 539ada2..0e8bdee 100644 (file)
@@ -94,6 +94,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.ueb.Helper;
 import org.onap.portalsdk.core.onboarding.ueb.TopicManager;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
 import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
@@ -1630,7 +1632,7 @@ public class EPAppCommonServiceImpl implements EPAppService {
                if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) {
                        try {
                                result = CipherUtil.decryptPKC(encryptedAppPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed for app " + app.getName(), e);
                        }
@@ -1643,7 +1645,7 @@ public class EPAppCommonServiceImpl implements EPAppService {
                if (decryptedAppPwd != null && !decryptedAppPwd.isEmpty()) {
                        try {
                                result = CipherUtil.encryptPKC(decryptedAppPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed for app " + app.getName(), e);
                        }
index 31cb8a4..df8b59d 100644 (file)
@@ -50,6 +50,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
 import org.onap.portalapp.portal.utils.EcompPortalUtils;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -177,7 +179,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService {
                if (encryptedPwd != null && encryptedPwd.length() > 0) {
                        try {
                                result = CipherUtil.decryptPKC(encryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
                                throw e;
index 451500d..9d9fde3 100644 (file)
@@ -52,6 +52,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
 import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -197,7 +199,7 @@ public class MicroserviceServiceImpl implements MicroserviceService {
                if (encryptedPwd != null && !encryptedPwd.isEmpty()) {
                        try {
                                result = CipherUtil.decryptPKC(encryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
                                throw e;
@@ -211,7 +213,7 @@ public class MicroserviceServiceImpl implements MicroserviceService {
                if (decryptedPwd != null && !decryptedPwd.isEmpty()) {
                        try {
                                result = CipherUtil.encryptPKC(decryptedPwd,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed", e);
                                throw e;
index e5543a3..3fc8c39 100644 (file)
@@ -61,6 +61,8 @@ import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
 import org.onap.portalapp.portal.logging.logic.EPLogUtil;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.slf4j.MDC;
 import org.springframework.http.HttpHeaders;
@@ -435,7 +437,7 @@ public class EcompPortalUtils {
                if (encrypted != null && encrypted.length() > 0) {
                        try {
                                result = CipherUtil.decryptPKC(encrypted,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
                                throw e;
index 441e99a..f65199c 100644 (file)
@@ -61,6 +61,8 @@ import org.onap.portalsdk.core.exception.UrlAccessRestrictedException;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -344,7 +346,7 @@ public class SessionCommunication {
                        String decreptedexternalAppPwd = StringUtils.EMPTY;
                        try {
                                decreptedexternalAppPwd = CipherUtil.decryptPKC(password,
-                                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                        } catch (CipherUtilException e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e);
                        }
index 6382bef..a905ca8 100644 (file)
@@ -42,6 +42,8 @@ import org.onap.portalapp.portal.domain.EPEndpoint;
 import org.onap.portalapp.portal.domain.EPEndpointAccount;
 import org.onap.portalapp.portal.framework.MockitoTestSuite;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.service.DataAccessServiceImpl;
 import org.onap.portalsdk.core.util.SystemProperties;
@@ -51,7 +53,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
 
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ CipherUtil.class , SystemProperties.class})
+@PrepareForTest({ CipherUtil.class , SystemProperties.class, KeyProperties.class, KeyConstants.class})
 public class BasicAuthAccountServiceImplTest {
        @Mock
        DataAccessService dataAccessService = new DataAccessServiceImpl();
@@ -92,11 +94,12 @@ public class BasicAuthAccountServiceImplTest {
        @Test
        public void saveBasicAuthAccountTest_password() throws Exception{
                PowerMockito.mockStatic(CipherUtil.class);
-               PowerMockito.mockStatic(SystemProperties.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                BasicAuthCredentials credentials = new BasicAuthCredentials();
                credentials.setPassword("password");
                String result = null;
-               Mockito.when(CipherUtil.encryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result);
+               Mockito.when(CipherUtil.encryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result);
                basicAuthAccountServiceImpl.saveBasicAuthAccount(credentials);
        }
        
@@ -163,7 +166,8 @@ public class BasicAuthAccountServiceImplTest {
        @Test
        public void getAccountDataTest_password() throws Exception {
                PowerMockito.mockStatic(CipherUtil.class);
-               PowerMockito.mockStatic(SystemProperties.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                List<BasicAuthCredentials> list = new ArrayList<>();
                BasicAuthCredentials basicAuthCredentials = new BasicAuthCredentials();
                basicAuthCredentials.setPassword("password");
@@ -171,7 +175,7 @@ public class BasicAuthAccountServiceImplTest {
                Mockito.when((List<BasicAuthCredentials>) dataAccessService.getList(BasicAuthCredentials.class, null))
                .thenReturn(list);
                String result = null;
-               Mockito.when(CipherUtil.decryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result);
+               Mockito.when(CipherUtil.decryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result);
                
        }
 
index ae81315..bc8d454 100644 (file)
@@ -58,6 +58,8 @@ import org.onap.portalapp.portal.domain.MicroserviceData;
 import org.onap.portalapp.portal.domain.MicroserviceParameter;
 import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.service.DataAccessServiceImpl;
 import org.onap.portalsdk.core.util.SystemProperties;
@@ -66,7 +68,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, Restrictions.class})
+@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, KeyProperties.class, KeyConstants.class})
 public class MicroserviceServiceImplTest {
        
        private static final String TEST="test";
@@ -150,6 +152,8 @@ public class MicroserviceServiceImplTest {
                PowerMockito.mockStatic(CipherUtil.class);
                PowerMockito.mockStatic(Restrictions.class);
                PowerMockito.mockStatic(Criterion.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
                MicroserviceData microserviceData = new MicroserviceData();
                MicroserviceParameter microserviceParameter = new MicroserviceParameter();
@@ -168,8 +172,7 @@ public class MicroserviceServiceImplTest {
                Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
                restrictionsList2.add(serviceIdCriterion);
                Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters);
-               Mockito.when(CipherUtil.decryptPKC("xyz",
-                               SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn("abc");
+               Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn("abc");
                List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData();
                assertNotNull(actual);
        }
@@ -181,6 +184,8 @@ public class MicroserviceServiceImplTest {
                PowerMockito.mockStatic(CipherUtil.class);
                PowerMockito.mockStatic(Restrictions.class);
                PowerMockito.mockStatic(Criterion.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
                MicroserviceData microserviceData = new MicroserviceData();
                MicroserviceParameter microserviceParameter = new MicroserviceParameter();
@@ -199,8 +204,7 @@ public class MicroserviceServiceImplTest {
                Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
                restrictionsList2.add(serviceIdCriterion);
                Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters);
-               Mockito.when(CipherUtil.decryptPKC("xyz",
-                               SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenThrow(BadPaddingException.class);
+               Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenThrow(BadPaddingException.class);
                List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData();
                assertNotNull(actual);
        }
@@ -220,10 +224,10 @@ public class MicroserviceServiceImplTest {
                PowerMockito.mockStatic(CipherUtil.class);
                Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
                restrictionsList.add(serviceIdCriterion);
-               PowerMockito.mockStatic(SystemProperties.class);
-               Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(TEST);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
+               Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(TEST);
                Mockito.when(CipherUtil.encryptPKC(TEST, TEST)).thenReturn(TEST);
-               
                Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters);
                microserviceServiceImpl.updateMicroservice(1l, buildData());
                
index 8b92b58..59c4f7a 100644 (file)
 package org.onap.portalapp.service;
 
 import java.util.List;
-
 import org.onap.portalapp.portal.domain.EPApp;
 import org.onap.portalapp.service.RemoteWebServiceCallService;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.WebServiceCallServiceImpl;
-import org.onap.portalsdk.core.util.SystemProperties;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -68,11 +68,10 @@ public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl i
                        logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey);
                        return false;
                }
-               
+
                String encryptedPwdDB = appRecord.getAppBasicAuthPassword();
                String appUserName = appRecord.getAppBasicAuthUsername();
-               String decryptedPwd = CipherUtil.decryptPKC(encryptedPwdDB,
-                               secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey);
+               String decryptedPwd = CipherUtil.decryptPKC(encryptedPwdDB,secretKey == null ? KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY) : secretKey);
                if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName))
                        return true;
                else
index 1a347e0..0576502 100644 (file)
@@ -43,7 +43,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
-import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 
 public class SessionCookieUtil extends CommonSessionCookieUtil{
        
@@ -72,7 +73,7 @@ public class SessionCookieUtil extends CommonSessionCookieUtil{
                        HttpServletResponse response,String userId) throws Exception {
                logger.info("************** session cookie util set up UserId cookie begins");
                userId = CipherUtil.encrypt(userId,
-                               SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                               KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                Cookie cookie1 = new Cookie(USER_ID, userId);
                cookie1.setSecure(true);
                cookie1.setMaxAge(cookieMaxAge);
@@ -93,7 +94,7 @@ public class SessionCookieUtil extends CommonSessionCookieUtil{
                                        userIdcookie = cookie;
                if(userIdcookie!=null){
                        userId = CipherUtil.decrypt(userIdcookie.getValue(),
-                                       SystemProperties.getProperty(SystemProperties.Decryption_Key));
+                                       KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
                }
                
                logger.info("************** session cookie util set up EP cookie completed");
index 5b7f7d4..1f34645 100644 (file)
@@ -57,6 +57,8 @@ import org.onap.portalapp.portal.domain.EPApp;
 import org.onap.portalapp.portal.framework.MockitoTestSuite;
 import org.onap.portalapp.service.RemoteWebServiceCallServiceImpl;
 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.powermock.api.mockito.PowerMockito;
@@ -64,7 +66,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ CipherUtil.class , SystemProperties.class})
+@PrepareForTest({ CipherUtil.class , SystemProperties.class, KeyProperties.class, KeyConstants.class})
 public class RemoteWebServiceCallServiceImplTest {
        
 
@@ -93,7 +95,8 @@ public class RemoteWebServiceCallServiceImplTest {
        public void verifyRESTCredentialTest() throws Exception
        {
                PowerMockito.mockStatic(CipherUtil.class);
-               PowerMockito.mockStatic(SystemProperties.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                String criteria= " where ueb_key = 'requestUebKey'";
                List<EPApp> appList = new ArrayList<>();
                EPApp app = new EPApp();
@@ -101,9 +104,8 @@ public class RemoteWebServiceCallServiceImplTest {
                appList.add(app);
                Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
                String secretKey = null;
-               Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
-               Mockito.when(CipherUtil.decryptPKC("password",
-                               secretKey == null ? null : secretKey)).thenReturn("pwd");
+               Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey);
+               Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd");
                assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","requestPassword"));
        }
        
@@ -111,7 +113,8 @@ public class RemoteWebServiceCallServiceImplTest {
        public void verifyRESTCredentialExceptionTest() throws Exception
        {
                PowerMockito.mockStatic(CipherUtil.class);
-               PowerMockito.mockStatic(SystemProperties.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                String criteria= " where ueb_key = 'requestUebKey'";
                List<EPApp> appList = new ArrayList<>();
                EPApp app = new EPApp();
@@ -120,9 +123,8 @@ public class RemoteWebServiceCallServiceImplTest {
                appList.add(app);
                Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
                String secretKey = null;
-               Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
-               Mockito.when(CipherUtil.decryptPKC("password",
-                               secretKey == null ? null : secretKey)).thenReturn("pwd");
+               Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey);
+               Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd");
                assertTrue(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
        }
        
@@ -131,6 +133,8 @@ public class RemoteWebServiceCallServiceImplTest {
        {
                PowerMockito.mockStatic(CipherUtil.class);
                PowerMockito.mockStatic(SystemProperties.class);
+               PowerMockito.mockStatic(KeyProperties.class);
+               PowerMockito.mockStatic(KeyConstants.class);
                String criteria= " where ueb_key = 'requestUebKey'";
                List<EPApp> appList = new ArrayList<>();
                EPApp app = new EPApp();
@@ -139,9 +143,8 @@ public class RemoteWebServiceCallServiceImplTest {
                appList.add(app);
                Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null);
                String secretKey = null;
-               Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
-               Mockito.when(CipherUtil.decryptPKC("password",
-                               secretKey == null ? null : secretKey)).thenReturn("pwd");
+               Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey);
+               Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd");
                assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
        }