use of org.eclipse.scout.rt.server.commons.servlet.HttpClientInfo in project scout.rt by eclipse.
the class HtmlFileLoader method loadResource.
@Override
public HttpCacheObject loadResource(HttpCacheKey cacheKey) throws IOException {
String pathInfo = cacheKey.getResourcePath();
BinaryResource content = loadResource(pathInfo);
if (content == null) {
return null;
}
// no cache-control, only E-Tag checks to make sure that a session with timeout is correctly
// forwarded to the login using a GET request BEFORE the first json POST request
HttpCacheObject httpCacheObject = new HttpCacheObject(cacheKey, content);
// Suppress automatic "compatibility mode" in IE in intranet zone
httpCacheObject.addHttpResponseInterceptor(new HttpResponseHeaderContributor("X-UA-Compatible", "IE=edge") {
private static final long serialVersionUID = 1L;
@Override
public void intercept(HttpServletRequest req, HttpServletResponse resp) {
HttpClientInfo httpClientInfo = HttpClientInfo.get(req);
if (httpClientInfo.isMshtml()) {
// Send headers only for IE
super.intercept(req, resp);
}
}
});
return httpCacheObject;
}
use of org.eclipse.scout.rt.server.commons.servlet.HttpClientInfo in project scout.rt by eclipse.
the class BrowserFieldContentHttpResponseInterceptor method intercept.
@Override
public void intercept(HttpServletRequest req, HttpServletResponse resp) {
ContentSecurityPolicy csp = BEANS.get(ContentSecurityPolicy.class).appendScriptSrc("'unsafe-inline'");
// Bug in Chrome: CSP 'self' is not interpreted correctly in sandboxed iframes, see https://bugs.chromium.org/p/chromium/issues/detail?id=443444
// Workaround: Add resolved URI to image and style CSP directive to allow loading of images and styles from same origin as nested iframe in browser field
HttpClientInfo httpClientInfo = HttpClientInfo.get(req);
if (httpClientInfo.isWebkit()) {
String resolvedSelfUri = m_browserUri.toString();
csp.appendImgSrc(resolvedSelfUri).appendStyleSrc(resolvedSelfUri);
}
String cspToken = csp.toToken();
if (httpClientInfo.isMshtml()) {
resp.setHeader(HttpServletControl.HTTP_HEADER_CSP_LEGACY, cspToken);
} else {
resp.setHeader(HttpServletControl.HTTP_HEADER_CSP, cspToken);
}
}
use of org.eclipse.scout.rt.server.commons.servlet.HttpClientInfo in project scout.rt by eclipse.
the class UiSession method createUserAgent.
protected UserAgent createUserAgent(JsonStartupRequest jsonStartupReq) {
HttpClientInfo httpClientInfo = HttpClientInfo.get(currentHttpRequest());
UserAgents userAgentBuilder = UserAgents.create().withUiLayer(UiLayer.HTML).withUiDeviceType(UiDeviceType.DESKTOP).withUiEngineType(httpClientInfo.getEngineType()).withUiSystem(httpClientInfo.getSystem()).withDeviceId(httpClientInfo.getUserAgent());
JSONObject userAgent = jsonStartupReq.getUserAgent();
if (userAgent != null) {
// TODO [7.0] cgu: it would be great if UserAgent could be changed dynamically, to switch from mobile to tablet mode on the fly, should be done as event in JsonClientSession
String uiDeviceTypeStr = userAgent.optString("deviceType", null);
if (uiDeviceTypeStr != null) {
userAgentBuilder.withUiDeviceType(UiDeviceType.createByIdentifier(uiDeviceTypeStr));
}
String uiLayerStr = userAgent.optString("uiLayer", null);
if (uiLayerStr != null) {
userAgentBuilder.withUiLayer(UiLayer.createByIdentifier(uiLayerStr));
}
boolean touch = userAgent.optBoolean("touch", false);
userAgentBuilder.withTouch(touch);
boolean standalone = userAgent.optBoolean("standalone", false);
userAgentBuilder.withStandalone(standalone);
}
return userAgentBuilder.build();
}
Aggregations