Fixed: Missing Security and Cache Headers in CMS Events

(OFBIZ-10597)
Instead of having multiple null checks for viewMap separately for each security header we can have a single combined null check at the top in setResponseBrowserDefaultSecurityHeaders() method.

With increasing security headers these may become expensive.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1846632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aditya Sharma
2018-11-15 10:40:55 +00:00
parent 0af9ffe58e
commit 780cc1af3e
@@ -985,8 +985,11 @@ public final class UtilHttp {
public static void setResponseBrowserDefaultSecurityHeaders(HttpServletResponse resp, ConfigXMLReader.ViewMap viewMap) {
// See https://cwiki.apache.org/confluence/display/OFBIZ/How+to+Secure+HTTP+Headers for details and how to test
String xFrameOption = null;
// HTTP Strict-Transport-Security (HSTS) enforces secure (HTTP over SSL/TLS) connections to the server.
String strictTransportSecurity = null;
if (viewMap != null) {
xFrameOption = viewMap.xFrameOption;
strictTransportSecurity = viewMap.strictTransportSecurity;
}
// Default to sameorigin
if (UtilValidate.isNotEmpty(xFrameOption)) {
@@ -997,12 +1000,6 @@ public final class UtilHttp {
resp.addHeader("x-frame-options", "sameorigin");
}
// HTTP Strict-Transport-Security (HSTS) enforces secure (HTTP over SSL/TLS) connections to the server.
String strictTransportSecurity = null;
if (viewMap != null) {
strictTransportSecurity = viewMap.strictTransportSecurity;
}
// Default to "max-age=31536000; includeSubDomains" 31536000 secs = 1 year
if (UtilValidate.isNotEmpty(strictTransportSecurity)) {
if (!"none".equals(strictTransportSecurity)) {