summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java')
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java42
1 files changed, 39 insertions, 3 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
index 9d13e431..49b3deaa 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
@@ -164,6 +164,21 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
} else {
// User ID obtained from request
try {
+ String appUserName = "";
+ String appPassword = "";
+ String appName = "";
+
+ for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
+
+ if (entry.getKey().equalsIgnoreCase("username")) {
+ appUserName = entry.getValue();
+ } else if (entry.getKey().equalsIgnoreCase("password")) {
+ appPassword = entry.getValue();
+ } else {
+ appName = entry.getValue();
+ }
+ }
+
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
String requestBody = readRequestBody(request);
@@ -173,7 +188,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
bodyMap.put("userid", userId);
requestBody = mapper.writeValueAsString(bodyMap);
responseJson = RestWebServiceClient.getInstance().postPortalContent(storeAnalyticsContextPath,
- userId, credential, null, credential, credential, "application/json", requestBody, true);
+ userId, appName, null, appUserName, appPassword, "application/json", requestBody, true);
logger.debug("doPost: postPortalContent returns " + responseJson);
response.setStatus(HttpServletResponse.SC_OK);
} catch (Exception ex) {
@@ -346,12 +361,27 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
} else {
// User ID obtained from request
try {
+ String appUserName = "";
+ String appPassword = "";
+ String appName = "";
+
+ for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
+
+ if (entry.getKey().equalsIgnoreCase("username")) {
+ appUserName = entry.getValue();
+ } else if (entry.getKey().equalsIgnoreCase("password")) {
+ appPassword = entry.getValue();
+ } else {
+ appName = entry.getValue();
+ }
+ }
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
contentType = "text/javascript";
responseString = RestWebServiceClient.getInstance().getPortalContent(webAnalyticsContextPath,
- userId, credential, null, credential, credential, true);
+ userId, appName, null, appUserName, appPassword, true);
+
if (logger.isDebugEnabled())
logger.debug("doGet: " + webAnalyticsContextPath + ": " + responseString);
response.setStatus(HttpServletResponse.SC_OK);
@@ -465,7 +495,8 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doGet: getUserRoles: caught exception", ex);
}
- } else {
+ }
+ else {
logger.warn("doGet: no match found for request");
responseJson = buildJsonResponse(false, "No match for request");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
@@ -647,5 +678,10 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
public static void setPortalRestApiServiceImpl(IPortalRestAPIService portalRestApiServiceImpl) {
PortalRestAPIProxy.portalRestApiServiceImpl = portalRestApiServiceImpl;
}
+
+ @Override
+ public Map<String, String> getCredentials() throws PortalAPIException {
+ return portalRestApiServiceImpl.getCredentials();
+ }
}