Change-Id: I14c0f9b59229e32de45b1652e64c01dd6c1d39e3
Issue-ID: PORTAL-914
Signed-off-by: krutbhat@att.com
13 files changed:
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.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;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
import org.onap.portalsdk.core.util.SystemProperties;
String result = "";
if (encrypted != null && encrypted.length() > 0) {
try {
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
throw e;
if (decryptedPwd != null && decryptedPwd.length() > 0) {
try {
result = CipherUtil.encryptPKC(decryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e);
throw e;
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.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;
import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
if(!encriptedPwd.isEmpty() || encriptedPwd != null || StringUtils.isEmpty(encriptedPwd)){
try {
decreptedAppPwd = CipherUtil.decryptPKC(encriptedPwd,
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);
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e);
}
String decreptedexternalAppPwd = StringUtils.EMPTY;
try {
decreptedexternalAppPwd = CipherUtil.decryptPKC(password,
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);
}
} catch (CipherUtilException e) {
logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e);
}
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.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;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
if (encryptedPwd != null && encryptedPwd.length() > 0) {
try {
result = CipherUtil.decryptPKC(encryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword() failed", e);
throw e;
if (decryptedPwd != null && decryptedPwd.length() > 0) {
try {
result = CipherUtil.encryptPKC(decryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e);
throw e;
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.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;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
import org.onap.portalsdk.core.service.DataAccessService;
if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) {
try {
result = CipherUtil.decryptPKC(encryptedAppPwd,
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);
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed for app " + app.getName(), e);
}
if (decryptedAppPwd != null && !decryptedAppPwd.isEmpty()) {
try {
result = CipherUtil.encryptPKC(decryptedAppPwd,
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);
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed for app " + app.getName(), e);
}
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.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;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
if (encryptedPwd != null && encryptedPwd.length() > 0) {
try {
result = CipherUtil.decryptPKC(encryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
throw e;
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.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;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
if (encryptedPwd != null && !encryptedPwd.isEmpty()) {
try {
result = CipherUtil.decryptPKC(encryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
throw e;
if (decryptedPwd != null && !decryptedPwd.isEmpty()) {
try {
result = CipherUtil.encryptPKC(decryptedPwd,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed", e);
throw e;
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.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;
import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.http.HttpHeaders;
if (encrypted != null && encrypted.length() > 0) {
try {
result = CipherUtil.decryptPKC(encrypted,
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;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
throw e;
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.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;
import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
String decreptedexternalAppPwd = StringUtils.EMPTY;
try {
decreptedexternalAppPwd = CipherUtil.decryptPKC(password,
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);
}
} catch (CipherUtilException e) {
logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e);
}
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.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;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.service.DataAccessServiceImpl;
import org.onap.portalsdk.core.util.SystemProperties;
@RunWith(PowerMockRunner.class)
@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();
public class BasicAuthAccountServiceImplTest {
@Mock
DataAccessService dataAccessService = new DataAccessServiceImpl();
@Test
public void saveBasicAuthAccountTest_password() throws Exception{
PowerMockito.mockStatic(CipherUtil.class);
@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;
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);
}
basicAuthAccountServiceImpl.saveBasicAuthAccount(credentials);
}
@Test
public void getAccountDataTest_password() throws Exception {
PowerMockito.mockStatic(CipherUtil.class);
@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");
List<BasicAuthCredentials> list = new ArrayList<>();
BasicAuthCredentials basicAuthCredentials = new BasicAuthCredentials();
basicAuthCredentials.setPassword("password");
Mockito.when((List<BasicAuthCredentials>) dataAccessService.getList(BasicAuthCredentials.class, null))
.thenReturn(list);
String result = null;
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);
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.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;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.service.DataAccessServiceImpl;
import org.onap.portalsdk.core.util.SystemProperties;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
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";
public class MicroserviceServiceImplTest {
private static final String TEST="test";
PowerMockito.mockStatic(CipherUtil.class);
PowerMockito.mockStatic(Restrictions.class);
PowerMockito.mockStatic(Criterion.class);
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();
List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
MicroserviceData microserviceData = new MicroserviceData();
MicroserviceParameter microserviceParameter = new MicroserviceParameter();
Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
restrictionsList2.add(serviceIdCriterion);
Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters);
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);
}
List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData();
assertNotNull(actual);
}
PowerMockito.mockStatic(CipherUtil.class);
PowerMockito.mockStatic(Restrictions.class);
PowerMockito.mockStatic(Criterion.class);
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();
List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
MicroserviceData microserviceData = new MicroserviceData();
MicroserviceParameter microserviceParameter = new MicroserviceParameter();
Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
restrictionsList2.add(serviceIdCriterion);
Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters);
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);
}
List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData();
assertNotNull(actual);
}
PowerMockito.mockStatic(CipherUtil.class);
Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
restrictionsList.add(serviceIdCriterion);
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(CipherUtil.encryptPKC(TEST, TEST)).thenReturn(TEST);
Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters);
microserviceServiceImpl.updateMicroservice(1l, buildData());
Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters);
microserviceServiceImpl.updateMicroservice(1l, buildData());
package org.onap.portalapp.service;
import java.util.List;
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.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.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;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey);
return false;
}
logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey);
return false;
}
String encryptedPwdDB = appRecord.getAppBasicAuthPassword();
String appUserName = appRecord.getAppBasicAuthUsername();
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
if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName))
return true;
else
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
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{
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,
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);
Cookie cookie1 = new Cookie(USER_ID, userId);
cookie1.setSecure(true);
cookie1.setMaxAge(cookieMaxAge);
userIdcookie = cookie;
if(userIdcookie!=null){
userId = CipherUtil.decrypt(userIdcookie.getValue(),
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");
}
logger.info("************** session cookie util set up EP cookie completed");
import org.onap.portalapp.portal.framework.MockitoTestSuite;
import org.onap.portalapp.service.RemoteWebServiceCallServiceImpl;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
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;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
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 {
public class RemoteWebServiceCallServiceImplTest {
public void verifyRESTCredentialTest() throws Exception
{
PowerMockito.mockStatic(CipherUtil.class);
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();
String criteria= " where ueb_key = 'requestUebKey'";
List<EPApp> appList = new ArrayList<>();
EPApp app = new EPApp();
appList.add(app);
Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
String secretKey = null;
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"));
}
assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","requestPassword"));
}
public void verifyRESTCredentialExceptionTest() throws Exception
{
PowerMockito.mockStatic(CipherUtil.class);
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();
String criteria= " where ueb_key = 'requestUebKey'";
List<EPApp> appList = new ArrayList<>();
EPApp app = new EPApp();
appList.add(app);
Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
String secretKey = null;
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"));
}
assertTrue(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
}
{
PowerMockito.mockStatic(CipherUtil.class);
PowerMockito.mockStatic(SystemProperties.class);
{
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();
String criteria= " where ueb_key = 'requestUebKey'";
List<EPApp> appList = new ArrayList<>();
EPApp app = new EPApp();
appList.add(app);
Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null);
String secretKey = null;
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"));
}
assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
}