diff options
author | Fiachra Corcoran <fiachra.corcoran@est.tech> | 2022-04-04 15:48:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-04-04 15:48:13 +0000 |
commit | 65cdebe21011e11405c6959ccd750bf1f8ddba49 (patch) | |
tree | e9e31ae24483ad0de50e7d643fc947e2b07c3250 /datarouter-prov/src/main | |
parent | 60f8c04c87612da4fe0c8b6e08bd1c26a964c5e3 (diff) | |
parent | d70c2ca145d2b3eac7ed6a4f16d41e322962cf59 (diff) |
Merge "DMAAP-1714 - DR Making TLS Configurable"
Diffstat (limited to 'datarouter-prov/src/main')
3 files changed, 41 insertions, 15 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java index 35205aa9..949019d1 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java @@ -45,6 +45,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.Poker; import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.IngressRoute;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
+import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
/**
* This servlet handles redirects for the <publishURL> on the provisioning server, which is generated by the
@@ -158,9 +159,15 @@ public class PublishServlet extends BaseServlet { } else {
// Generate new URL
String nextnode = getRedirectNode(feedid, req);
- nextnode = nextnode + ":" + ProvRunner.getProvProperties().getProperty(
- "org.onap.dmaap.datarouter.provserver.https.port", "8443");
- String newurl = "https://" + nextnode + "/publish" + req.getPathInfo();
+ if (Boolean.parseBoolean(ProvRunner.getProvProperties()
+ .getProperty("org.onap.dmaap.datarouter.provserver.tlsenabled", "true"))) {
+ nextnode = nextnode + ":" + ProvRunner.getProvProperties().getProperty(
+ "org.onap.dmaap.datarouter.nodeserver.https.port", "8443");
+ } else {
+ nextnode = nextnode + ":" + ProvRunner.getProvProperties().getProperty(
+ "org.onap.dmaap.datarouter.nodeserver.http.port", "8080");
+ }
+ String newurl = URLUtilities.getUrlSecurityOption() + nextnode + "/publish" + req.getPathInfo();
String qs = req.getQueryString();
if (qs != null) {
newurl += "?" + qs;
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java index 2e000027..988b576f 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java @@ -28,8 +28,8 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager;
import java.net.InetAddress;
import java.net.UnknownHostException;
-
import org.onap.dmaap.datarouter.provisioning.BaseServlet;
+import org.onap.dmaap.datarouter.provisioning.ProvRunner;
/**
* Utility functions used to generate the different URLs used by the Data Router.
@@ -39,9 +39,7 @@ import org.onap.dmaap.datarouter.provisioning.BaseServlet; */
public class URLUtilities {
-
private static final EELFLogger utilsLogger = EELFManager.getInstance().getLogger("UtilsLog");
- private static final String HTTPS = "https://";
private static String otherPod;
private URLUtilities() {
@@ -54,7 +52,7 @@ public class URLUtilities { * @return the URL
*/
public static String generateFeedURL(int feedid) {
- return HTTPS + BaseServlet.getProvName() + "/feed/" + feedid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/feed/" + feedid;
}
/**
@@ -64,7 +62,7 @@ public class URLUtilities { * @return the URL
*/
public static String generatePublishURL(int feedid) {
- return HTTPS + BaseServlet.getProvName() + "/publish/" + feedid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/publish/" + feedid;
}
/**
@@ -74,7 +72,7 @@ public class URLUtilities { * @return the URL
*/
public static String generateSubscribeURL(int feedid) {
- return HTTPS + BaseServlet.getProvName() + "/subscribe/" + feedid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/subscribe/" + feedid;
}
/**
@@ -84,7 +82,7 @@ public class URLUtilities { * @return the URL
*/
public static String generateFeedLogURL(int feedid) {
- return HTTPS + BaseServlet.getProvName() + "/feedlog/" + feedid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/feedlog/" + feedid;
}
/**
@@ -94,7 +92,7 @@ public class URLUtilities { * @return the URL
*/
public static String generateSubscriptionURL(int subid) {
- return HTTPS + BaseServlet.getProvName() + "/subs/" + subid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/subs/" + subid;
}
/**
@@ -104,7 +102,7 @@ public class URLUtilities { * @return the URL
*/
public static String generateSubLogURL(int subid) {
- return HTTPS + BaseServlet.getProvName() + "/sublog/" + subid;
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/sublog/" + subid;
}
/**
@@ -113,7 +111,7 @@ public class URLUtilities { * @return the URL
*/
public static String generatePeerProvURL() {
- return HTTPS + getPeerPodName() + "/internal/prov";
+ return getUrlSecurityOption() + getPeerPodName() + getAppropriateUrlPort() + "/internal/prov";
}
/**
@@ -128,7 +126,7 @@ public class URLUtilities { return "";
}
- return HTTPS + peerPodUrl + "/internal/drlogs/";
+ return getUrlSecurityOption() + peerPodUrl + getAppropriateUrlPort() + "/internal/drlogs/";
}
/**
@@ -154,4 +152,21 @@ public class URLUtilities { return otherPod;
}
+ public static String getUrlSecurityOption() {
+ if (Boolean.parseBoolean(ProvRunner.getProvProperties()
+ .getProperty("org.onap.dmaap.datarouter.provserver.tlsenabled", "true"))) {
+ return "https://";
+ }
+ return "http://";
+ }
+
+ private static String getAppropriateUrlPort() {
+ if (Boolean.parseBoolean(ProvRunner.getProvProperties()
+ .getProperty("org.onap.dmaap.datarouter.provserver.tlsenabled", "true")))
+ return "";
+
+ return ":" + ProvRunner.getProvProperties()
+ .getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080");
+
+ }
}
diff --git a/datarouter-prov/src/main/resources/provserver.properties b/datarouter-prov/src/main/resources/provserver.properties index ad9a19e3..642088ff 100755 --- a/datarouter-prov/src/main/resources/provserver.properties +++ b/datarouter-prov/src/main/resources/provserver.properties @@ -56,4 +56,8 @@ org.onap.dmaap.datarouter.provserver.aaf.feed.type = org.onap.dmaap-dr.fe org.onap.dmaap.datarouter.provserver.aaf.sub.type = org.onap.dmaap-dr.sub org.onap.dmaap.datarouter.provserver.aaf.instance = legacy org.onap.dmaap.datarouter.provserver.aaf.action.publish = publish -org.onap.dmaap.datarouter.provserver.aaf.action.subscribe = subscribe
\ No newline at end of file +org.onap.dmaap.datarouter.provserver.aaf.action.subscribe = subscribe + +org.onap.dmaap.datarouter.provserver.tlsenabled = true +org.onap.dmaap.datarouter.nodeserver.https.port = 8443 +org.onap.dmaap.datarouter.nodeserver.http.port = 8080
\ No newline at end of file |