You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/02/28 16:10:45 UTC
svn commit: r1784771 - in /ofbiz/branches/release13.07/framework:
common/src/org/ofbiz/common/email/NotificationServices.java
webapp/src/org/ofbiz/webapp/control/RequestHandler.java
webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java
Author: jleroux
Date: Tue Feb 28 16:10:45 2017
New Revision: 1784771
URL: http://svn.apache.org/viewvc?rev=1784771&view=rev
Log:
Reverts revision(s) 1784745 from ofbiz/branches/release13.07:
"Partially backport the fix idea from trunk framework for revision: 1784549 "
------------------------------------------------------------------------
r1784549 | jleroux | 2017-02-27 13:33:42 +0100 (lun. 27 fev. 2017) | 26 lignes
Here, unlike in r1784549, I kept getDefaultServerRootUrl() and did no changes in url.properties. URL properties will be, for instance, used to specify the ports used in demos (18443/18080)
Fixed: "Login and logout process in demos shows a certificate issue"
(OFBIZ-9206)
Also fixes "16.11 ofbizUrl include host+port and break some reverse-proxy/docker
setups"
(OFBIZ-9224)
The idea is to use the port initially passed by a successful login request as it's done
since WebSiteProperties class exists. I also don't add twice the portOffset when it's build
from the request, and only then. Keep it as is when it's build from a WebSite GenericValue.
We then trust the user and don't rely on the request.
Thanks: Pierre Smits and Leonard Lin for reports
------------------------------------------------------------------------
........
Modified:
ofbiz/branches/release13.07/framework/common/src/org/ofbiz/common/email/NotificationServices.java
ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java
Modified: ofbiz/branches/release13.07/framework/common/src/org/ofbiz/common/email/NotificationServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/common/src/org/ofbiz/common/email/NotificationServices.java?rev=1784771&r1=1784770&r2=1784771&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/common/src/org/ofbiz/common/email/NotificationServices.java (original)
+++ ofbiz/branches/release13.07/framework/common/src/org/ofbiz/common/email/NotificationServices.java Tue Feb 28 16:10:45 2017
@@ -27,6 +27,8 @@ import java.net.UnknownHostException;
import java.util.Locale;
import java.util.Map;
+import javolution.util.FastMap;
+
import org.ofbiz.base.container.ClassLoaderContainer;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilGenerics;
@@ -46,7 +48,6 @@ import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceUtil;
import freemarker.template.TemplateException;
-import javolution.util.FastMap;
/**
* Provides generic services related to preparing and
@@ -266,7 +267,6 @@ public class NotificationServices {
String httpPort = null;
String httpServer = null;
Boolean enableHttps = null;
- Boolean dontAdd = false;
try {
// using just the IP address of localhost if we don't have a defined server
@@ -296,10 +296,7 @@ public class NotificationServices {
// fill in any missing properties with fields from the global file
if (UtilValidate.isEmpty(httpsPort)) {
- httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "8443", delegator);
- if ("8443" != httpsPort) {
- dontAdd = true; // Here we can't initialise the port from a request, so we assume it's set in properties or DB, we don't add the portOffset anyway
- }
+ httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "443", delegator);
}
if (UtilValidate.isEmpty(httpsServer)) {
httpsServer = EntityUtilProperties.getPropertyValue("url.properties", "force.https.host", localServer, delegator);
@@ -318,13 +315,9 @@ public class NotificationServices {
Integer httpPortValue = Integer.valueOf(httpPort);
httpPortValue += ClassLoaderContainer.portOffset;
httpPort = httpPortValue.toString();
- if (!dontAdd) {
- Integer httpsPortValue = Integer.valueOf(httpsPort);
- if (!httpsPort.isEmpty()) {
- httpsPortValue += ClassLoaderContainer.portOffset;
- }
- httpsPort = httpsPortValue.toString();
- }
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
}
// prepare the (non-secure) URL
Modified: ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1784771&r1=1784770&r2=1784771&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Tue Feb 28 16:10:45 2017
@@ -34,6 +34,8 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javolution.util.FastMap;
+
import org.ofbiz.base.container.ClassLoaderContainer;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.SSLUtil;
@@ -59,8 +61,6 @@ import org.ofbiz.webapp.view.ViewHandler
import org.ofbiz.webapp.website.WebSiteWorker;
import org.owasp.esapi.errors.EncodingException;
-import javolution.util.FastMap;
-
/**
* RequestHandler - Request Processor Object
*/
@@ -942,12 +942,7 @@ public class RequestHandler {
public static String getDefaultServerRootUrl(HttpServletRequest request, boolean secure) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
- Boolean dontAdd = false;
- String httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "8443", delegator);
- if (httpsPort.isEmpty() ) {
- httpsPort = String.valueOf(request.getServerPort());
- dontAdd = true; // We take the port from the request, don't add the portOffset
- }
+ String httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "443", delegator);
String httpsServer = EntityUtilProperties.getPropertyValue("url.properties", "force.https.host", delegator);
String httpPort = EntityUtilProperties.getPropertyValue("url.properties", "port.http", "80", delegator);
String httpServer = EntityUtilProperties.getPropertyValue("url.properties", "force.http.host", delegator);
@@ -957,13 +952,9 @@ public class RequestHandler {
Integer httpPortValue = Integer.valueOf(httpPort);
httpPortValue += ClassLoaderContainer.portOffset;
httpPort = httpPortValue.toString();
- if (!dontAdd) {
- Integer httpsPortValue = Integer.valueOf(httpsPort);
- if (!httpsPort.isEmpty()) {
- httpsPortValue += ClassLoaderContainer.portOffset;
- }
- httpsPort = httpsPortValue.toString();
- }
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
}
StringBuilder newURL = new StringBuilder();
@@ -1073,7 +1064,6 @@ public class RequestHandler {
String httpPort = null;
String httpServer = null;
Boolean enableHttps = null;
- Boolean dontAdd = false;
// load the properties from the website entity
GenericValue webSite;
@@ -1094,11 +1084,7 @@ public class RequestHandler {
// fill in any missing properties with fields from the global file
if (UtilValidate.isEmpty(httpsPort)) {
- httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "8443", delegator);
- if (httpsPort.isEmpty() ) {
- httpsPort = String.valueOf(request.getServerPort());
- dontAdd = true; // We take the port from the request, don't add the portOffset
- }
+ httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "443", delegator);
}
if (UtilValidate.isEmpty(httpsServer)) {
httpsServer = EntityUtilProperties.getPropertyValue("url.properties", "force.https.host", delegator);
@@ -1117,13 +1103,9 @@ public class RequestHandler {
Integer httpPortValue = Integer.valueOf(httpPort);
httpPortValue += ClassLoaderContainer.portOffset;
httpPort = httpPortValue.toString();
- if (!dontAdd) {
- Integer httpsPortValue = Integer.valueOf(httpsPort);
- if (!httpsPort.isEmpty()) {
- httpsPortValue += ClassLoaderContainer.portOffset;
- }
- httpsPort = httpsPortValue.toString();
- }
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
}
// create the path the the control servlet
Modified: ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java?rev=1784771&r1=1784770&r2=1784771&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java (original)
+++ ofbiz/branches/release13.07/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java Tue Feb 28 16:10:45 2017
@@ -104,7 +104,6 @@ public class OfbizUrlTransform implement
BeanModel res = (BeanModel) env.getVariable("response");
Object prefix = env.getVariable("urlPrefix");
if (UtilValidate.isNotEmpty(webSiteId)) {
- Boolean dontAdd = false;
HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
Delegator delegator = (Delegator) request.getAttribute("delegator");
String httpsPort = null;
@@ -128,11 +127,7 @@ public class OfbizUrlTransform implement
}
// fill in any missing properties with fields from the global file
if (UtilValidate.isEmpty(httpsPort)) {
- httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "8443", delegator);
- if (httpsPort.isEmpty() ) {
- httpsPort = String.valueOf(request.getServerPort());
- dontAdd = true; // We take the port from the request, don't add the portOffset
- }
+ httpsPort = EntityUtilProperties.getPropertyValue("url.properties", "port.https", "443", delegator);
}
if (UtilValidate.isEmpty(httpsServer)) {
httpsServer = EntityUtilProperties.getPropertyValue("url.properties", "force.https.host", delegator);
@@ -151,14 +146,11 @@ public class OfbizUrlTransform implement
Integer httpPortValue = Integer.valueOf(httpPort);
httpPortValue += ClassLoaderContainer.portOffset;
httpPort = httpPortValue.toString();
- if (!dontAdd) {
- Integer httpsPortValue = Integer.valueOf(httpsPort);
- if (!httpsPort.isEmpty()) {
- httpsPortValue += ClassLoaderContainer.portOffset;
- }
- httpsPort = httpsPortValue.toString();
- }
+ Integer httpsPortValue = Integer.valueOf(httpsPort);
+ httpsPortValue += ClassLoaderContainer.portOffset;
+ httpsPort = httpsPortValue.toString();
}
+
if (secure && enableHttps) {
String server = httpsServer;
if (UtilValidate.isEmpty(server)) {