aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-fe/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-fe/src/main')
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java17
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java38
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java196
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java8
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java14
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java14
6 files changed, 191 insertions, 96 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
index a64ba08d69..e42644466e 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
@@ -22,15 +22,14 @@ package org.openecomp.sdc.fe;
public class Constants {
- public static String HTTP_IV_USER = "HTTP_IV_USER";
- public static String USER_ID = "USER_ID";
- public static String ECOMP_PORTAL_COOKIE = "UserId";
- public static String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME";
- public static String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME";
- public static String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS";
- public static String HTTP_CSP_WSTYPE = "HTTP_CSP_WSTYPE";
- public static String HTTP_CSP_EMAIL = "HTTP_CSP_EMAIL";
-
+ public static final String HTTP_IV_USER = "HTTP_IV_USER";
+ public static final String USER_ID = "USER_ID";
+ public static final String ECOMP_PORTAL_COOKIE = "UserId";
+ public static final String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME";
+ public static final String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME";
+ public static final String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS";
+ public static final String HTTP_CSP_WSTYPE = "HTTP_CSP_WSTYPE";
+ public static final String HTTP_CSP_EMAIL = "HTTP_CSP_EMAIL";
public static final String WEBSEAL_USER_ID_HEADER = "csp-attuid";
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java
new file mode 100644
index 0000000000..aa78a89eaf
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.fe.mdc;
+
+public class MdcData {
+ private String serviceInstanceID;
+ private String userId;
+ private String remoteAddr;
+ private String localAddr;
+ private Long transactionStartTime;
+
+ public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
+ super();
+ this.serviceInstanceID = serviceInstanceID;
+ this.userId = userId;
+ this.remoteAddr = remoteAddr;
+ this.localAddr = localAddr;
+ this.transactionStartTime = transactionStartTime;
+ }
+
+ public Long getTransactionStartTime() {
+ return transactionStartTime;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public String getRemoteAddr() {
+ return remoteAddr;
+ }
+
+ public String getLocalAddr() {
+ return localAddr;
+ }
+
+ public String getServiceInstanceID() {
+ return serviceInstanceID;
+ }
+}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
index f9ac666933..511592afe2 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.fe.servlets;
-import java.net.URI;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
@@ -28,10 +27,11 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Response;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.config.EcompErrorName;
import org.openecomp.sdc.fe.config.Configuration;
import org.openecomp.sdc.fe.config.ConfigurationManager;
import org.openecomp.sdc.fe.config.FeEcompErrorManager;
+import org.openecomp.sdc.fe.mdc.MdcData;
+import org.openecomp.sdc.fe.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -41,12 +41,30 @@ import com.google.common.cache.CacheBuilder;
public class FeProxyServlet extends SSLProxyServlet {
private static final long serialVersionUID = 1L;
- private static final String URL = "%s://%s:%s%s";
- private static Logger log = LoggerFactory.getLogger(FeProxyServlet.class.getName());
+ private static final String URL = "%s://%s%s%s";
+ private static final String ONBOARDING_CONTEXT = "/onboarding-api";
+ private static final String DCAED_CONTEXT = "/dcae-api";
+ private static final Logger log = LoggerFactory.getLogger(FeProxyServlet.class.getName());
private static Cache<String, MdcData> mdcDataCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build();
+// @Override
+// public URI rewriteURI(HttpServletRequest request) {
+// try {
+// logFeRequest(request);
+// } catch (Exception e) {
+// FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Request");
+// log.error("Unexpected FE request logging error :", e);
+// }
+// String originalUrl = request.getRequestURL().toString();
+// String redirectedUrl = getModifiedUrl(request);
+//
+// log.debug("FeProxyServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl);
+//
+// return URI.create(redirectedUrl);
+// }
+
@Override
- public URI rewriteURI(HttpServletRequest request) {
+ protected String rewriteTarget(HttpServletRequest request) {
try {
logFeRequest(request);
} catch (Exception e) {
@@ -58,18 +76,29 @@ public class FeProxyServlet extends SSLProxyServlet {
log.debug("FeProxyServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl);
- return URI.create(redirectedUrl);
+ return redirectedUrl;
}
+// @Override
+// protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) {
+// try {
+// logFeResponse(request, proxyResponse);
+// } catch (Exception e) {
+// FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
+// log.error("Unexpected FE response logging error :", e);
+// }
+// super.onResponseSuccess(request, response, proxyResponse);
+// }
+//protected void onProxyResponseSuccess(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Response serverResponse) {
@Override
- protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) {
+ protected void onProxyResponseSuccess(HttpServletRequest request, HttpServletResponse proxyResponse, Response response) {
try {
- logFeResponse(request, proxyResponse);
+ logFeResponse(request, response);
} catch (Exception e) {
FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
log.error("Unexpected FE response logging error :", e);
}
- super.onResponseSuccess(request, response, proxyResponse);
+ super.onProxyResponseSuccess(request, proxyResponse, response);
}
private void logFeRequest(HttpServletRequest httpRequest) {
@@ -135,79 +164,104 @@ public class FeProxyServlet extends SSLProxyServlet {
MDC.put("timer", transactionStartTime);
}
- private class MdcData {
- private String serviceInstanceID;
- private String userId;
- private String remoteAddr;
- private String localAddr;
- private Long transactionStartTime;
-
- public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
- super();
- this.serviceInstanceID = serviceInstanceID;
- this.userId = userId;
- this.remoteAddr = remoteAddr;
- this.localAddr = localAddr;
- this.transactionStartTime = transactionStartTime;
+ private String getModifiedUrl(HttpServletRequest request) {
+ Configuration config = getConfiguration(request);
+ if (config == null) {
+ log.error("failed to retrive configuration.");
+ throw new RuntimeException("failed to read FE configuration");
}
-
- public Long getTransactionStartTime() {
- return transactionStartTime;
+ String uri = request.getRequestURI();
+ String protocol;
+ String host;
+ String port;
+ if (uri.contains(ONBOARDING_CONTEXT)){
+ uri = uri.replace("/sdc1/feProxy"+ONBOARDING_CONTEXT,ONBOARDING_CONTEXT);
+ protocol = config.getOnboarding().getProtocolBe();
+ host = config.getOnboarding().getHostBe();
+ port = config.getOnboarding().getPortBe().toString();
}
-
- public String getUserId() {
- return userId;
+ else if(uri.contains(DCAED_CONTEXT)){
+ uri = uri.replace("/sdc1/feProxy"+DCAED_CONTEXT,DCAED_CONTEXT);
+ protocol = config.getBeProtocol();
+ host = config.getBeHost();
+ if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+ port = config.getBeHttpPort().toString();
+ } else {
+ port = config.getBeSslPort().toString();
+ }
}
+ else{
+ uri = uri.replace("/sdc1/feProxy","/sdc2");
+ protocol = config.getBeProtocol();
+ host = config.getBeHost();
+ if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+ port = config.getBeHttpPort().toString();
+ } else {
+ port = config.getBeSslPort().toString();
+ }
- public String getRemoteAddr() {
- return remoteAddr;
}
- public String getLocalAddr() {
- return localAddr;
- }
+ String authority = getAuthority(host, port);
+ String queryString = getQueryString(request);
+ return String.format(URL,protocol,authority,uri,queryString);
+
+
+
+
+// String scheme = config.getBeProtocol();
+// String uri = request.getRequestURI().toString();
+// StringBuilder url = new StringBuilder();
+// url.append(scheme).append("://").append(config.getBeHost());
+// url.append(":");
+// if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+// url.append(config.getBeHttpPort());
+// } else {
+// url.append(config.getBeSslPort());
+// }
+// url.append(uri);
+// String queryString = request.getQueryString(); // d=789
+// if (queryString != null) {
+// url.append("?").append(queryString);
+// }
+//
+// String redirectedUrl = url.toString();
+// String onboardingForwardContext = config.getOnboardingForwardContext();
+// if (onboardingForwardContext == null || onboardingForwardContext.isEmpty()) {
+// onboardingForwardContext = "/onboarding-api";
+// }
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/dcae-api", "/dcae");
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/onboarding-api", onboardingForwardContext);
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy", "/sdc2");
+// return redirectedUrl;
- public String getServiceInstanceID() {
- return serviceInstanceID;
- }
}
- public String getModifiedUrl(HttpServletRequest request) {
- Configuration config = getConfiguration(request);
- if (config == null) {
- log.error("failed to retrive configuration.");
- }
- String scheme = config.getBeProtocol();
- String uri = request.getRequestURI().toString();
- StringBuilder url = new StringBuilder();
- url.append(scheme).append("://").append(config.getBeHost());
- url.append(":");
- if (config.getBeProtocol().equals(BE_PROTOCOL.HTTP.getProtocolName())) {
- url.append(config.getBeHttpPort());
- } else {
- url.append(config.getBeSslPort());
- }
- url.append(uri);
- String queryString = request.getQueryString(); // d=789
- if (queryString != null) {
- url.append("?").append(queryString);
- }
-
- String redirectedUrl = url.toString();
- String onboardingForwardContext = config.getOnboardingForwardContext();
- if (onboardingForwardContext == null || onboardingForwardContext.isEmpty()) {
- onboardingForwardContext = "/onboarding-api";
- }
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/dcae-api", "/dcae");
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/onboarding-api", onboardingForwardContext);
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy", "/sdc2");
- return redirectedUrl;
+ private Configuration getConfiguration(HttpServletRequest request) {
+ return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
}
- private Configuration getConfiguration(HttpServletRequest request) {
- Configuration config = ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
- return config;
- }
+ private String getAuthority(String host, String port) {
+ String authority;
+ if (port==null){
+ authority=host;
+ }
+ else{
+ authority=host+":"+port;
+ }
+ return authority;
+ }
+
+ private String getQueryString(HttpServletRequest request) {
+ String queryString = request.getQueryString();
+ if (queryString != null) {
+ queryString="?"+queryString;
+ }
+ else{
+ queryString="";
+ }
+ return queryString;
+ }
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
index fce5d35d20..7f5ea06b97 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
@@ -295,10 +295,10 @@ public class HealthCheckService {
Configuration.OnboardingConfig onboardingConfig = config.getOnboarding();
if (onboardingConfig != null) {
- String protocol = onboardingConfig.getProtocol();
- String host = onboardingConfig.getHost();
- Integer port = onboardingConfig.getPort();
- String uri = onboardingConfig.getHealthCheckUri();
+ String protocol = onboardingConfig.getProtocolFe();
+ String host = onboardingConfig.getHostFe();
+ Integer port = onboardingConfig.getPortFe();
+ String uri = onboardingConfig.getHealthCheckUriFe();
return protocol + "://" + host + ":" + port + uri;
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
index c3ba279c8c..4edcfe1286 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
@@ -33,6 +33,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.fe.config.Configuration;
import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.openecomp.sdc.fe.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,18 +42,7 @@ public abstract class SSLProxyServlet extends ProxyServlet {
private static final long serialVersionUID = 1L;
private static Logger log = LoggerFactory.getLogger(SSLProxyServlet.class.getName());
- public enum BE_PROTOCOL {
- HTTP("http"), SSL("ssl");
- private String protocolName;
- public String getProtocolName() {
- return protocolName;
- }
-
- BE_PROTOCOL(String protocolName) {
- this.protocolName = protocolName;
- }
- };
@Override
public void customizeProxyRequest(Request proxyRequest, HttpServletRequest request) {
@@ -77,7 +67,7 @@ public abstract class SSLProxyServlet extends ProxyServlet {
protected HttpClient createHttpClient() throws ServletException {
Configuration config = ((ConfigurationManager) getServletConfig().getServletContext()
.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
- boolean isSecureClient = !config.getBeProtocol().equals(BE_PROTOCOL.HTTP.getProtocolName());
+ boolean isSecureClient = !config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName());
HttpClient client = (isSecureClient) ? getSecureHttpClient() : super.createHttpClient();
setTimeout(600000);
client.setIdleTimeout(600000);
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java
new file mode 100644
index 0000000000..923728672e
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.fe.utils;
+
+public enum BeProtocol {
+ HTTP("http"), SSL("ssl");
+ private String protocolName;
+
+ public String getProtocolName() {
+ return protocolName;
+ }
+
+ BeProtocol(String protocolName) {
+ this.protocolName = protocolName;
+ }
+ }; \ No newline at end of file