summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-10-05 22:34:31 +0300
committerVaadin Code Review <review@vaadin.com>2015-10-07 06:54:22 +0000
commit1a0d6f759ff9f87942bedc3d4491f13a42acf60a (patch)
treed57ec5950bdba4c2eae3b715598c2acf2e7ba0fc
parent2d2418516ab34bc90de1f910dfa2e0c64f093431 (diff)
downloadvaadin-framework-1a0d6f759ff9f87942bedc3d4491f13a42acf60a.tar.gz
vaadin-framework-1a0d6f759ff9f87942bedc3d4491f13a42acf60a.zip
Fix server side browser detection in Weblogic Portal (#7449)
Change-Id: I9622b92d58971ea55bc0e3cbde9300226fa2b18b
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java74
-rw-r--r--server/src/com/vaadin/server/WebBrowser.java4
2 files changed, 69 insertions, 9 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 77a1b18d10..043f95fd7b 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.portlet.ActionRequest;
@@ -103,7 +104,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Override
public String getParameter(String name) {
String parameter = super.getParameter(name);
- if (parameter == null) {
+ if (parameter == null && getOriginalRequest() != null) {
parameter = getOriginalRequest().getParameter(name);
}
return parameter;
@@ -111,23 +112,36 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Override
public String getRemoteAddr() {
- return getOriginalRequest().getRemoteAddr();
+ if (getOriginalRequest() != null) {
+ return getOriginalRequest().getRemoteAddr();
+ } else {
+ return super.getRemoteAddr();
+ }
+
}
@Override
public String getRemoteHost() {
- return getOriginalRequest().getRemoteHost();
+ if (getOriginalRequest() != null) {
+ return getOriginalRequest().getRemoteHost();
+ } else {
+ return super.getRemoteHost();
+ }
}
@Override
public int getRemotePort() {
- return getOriginalRequest().getRemotePort();
+ if (getOriginalRequest() != null) {
+ return getOriginalRequest().getRemotePort();
+ } else {
+ return super.getRemotePort();
+ }
}
@Override
public String getHeader(String name) {
String header = super.getHeader(name);
- if (header == null) {
+ if (header == null && getOriginalRequest() != null) {
header = getOriginalRequest().getHeader(name);
}
return header;
@@ -136,7 +150,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Override
public Enumeration<String> getHeaderNames() {
Enumeration<String> headerNames = super.getHeaderNames();
- if (headerNames == null) {
+ if (headerNames == null && getOriginalRequest() != null) {
headerNames = getOriginalRequest().getHeaderNames();
}
return headerNames;
@@ -145,7 +159,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Override
public Enumeration<String> getHeaders(String name) {
Enumeration<String> headers = super.getHeaders(name);
- if (headers == null) {
+ if (headers == null && getOriginalRequest() != null) {
headers = getOriginalRequest().getHeaders(name);
}
return headers;
@@ -154,7 +168,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
@Override
public Map<String, String[]> getParameterMap() {
Map<String, String[]> parameterMap = super.getParameterMap();
- if (parameterMap == null) {
+ if (parameterMap == null && getOriginalRequest() != null) {
parameterMap = getOriginalRequest().getParameterMap();
}
return parameterMap;
@@ -307,6 +321,47 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
}
/**
+ * Portlet request for WebSphere Portal.
+ */
+ public static class VaadinWebLogicPortalRequest extends
+ VaadinHttpAndPortletRequest {
+ private static boolean warningLogged = false;
+
+ private static Method servletRequestMethod = null;
+
+ public VaadinWebLogicPortalRequest(PortletRequest request,
+ VaadinPortletService vaadinService) {
+ super(request, vaadinService);
+ }
+
+ @Override
+ protected HttpServletRequest getServletRequest(PortletRequest request) {
+ try {
+ if (servletRequestMethod == null) {
+ Class<?> portletRequestClass = Class
+ .forName("com.bea.portlet.container.PortletRequestImpl");
+ servletRequestMethod = portletRequestClass
+ .getDeclaredMethod("getInternalRequest",
+ new Class[] {});
+ servletRequestMethod.setAccessible(true);
+ }
+
+ return (HttpServletRequest) servletRequestMethod
+ .invoke(request);
+ } catch (Exception e) {
+ if (!warningLogged) {
+ warningLogged = true;
+ getLogger()
+ .log(Level.WARNING,
+ "Could not determine underlying servlet request for WebLogic Portal portlet request",
+ e);
+ }
+ return null;
+ }
+ }
+ }
+
+ /**
* @deprecated As of 7.0. Will likely change or be removed in a future
* version
*/
@@ -499,6 +554,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
if (portalInfo.contains("websphere portal")) {
return new VaadinWebSpherePortalRequest(request, service);
}
+ if (portalInfo.contains("weblogic portal")) {
+ return new VaadinWebLogicPortalRequest(request, service);
+ }
return new VaadinPortletRequest(request, service);
}
diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java
index 9bf30cb3db..1205fece74 100644
--- a/server/src/com/vaadin/server/WebBrowser.java
+++ b/server/src/com/vaadin/server/WebBrowser.java
@@ -496,7 +496,9 @@ public class WebBrowser implements Serializable {
locale = request.getLocale();
address = request.getRemoteAddr();
secureConnection = request.isSecure();
- String agent = request.getHeader("user-agent");
+ // Headers are case insensitive according to the specifiation but are
+ // case sensitive in Weblogic portal...
+ String agent = request.getHeader("User-Agent");
if (agent != null) {
browserApplication = agent;