Commit 873a5f98 authored by Dele Olajide's avatar Dele Olajide

OF-709: Somewhere between my initial commit, Flow's squashing and the code...

OF-709: Somewhere between my initial commit, Flow's squashing and the code review, this code change was dropped. It is required to enable access to http-bind root folder for static web pages.
parent 2ad60199
...@@ -75,35 +75,35 @@ public final class HttpBindManager { ...@@ -75,35 +75,35 @@ public final class HttpBindManager {
public static final String HTTP_BIND_SECURE_PORT = "httpbind.port.secure"; public static final String HTTP_BIND_SECURE_PORT = "httpbind.port.secure";
public static final int HTTP_BIND_SECURE_PORT_DEFAULT = 7443; public static final int HTTP_BIND_SECURE_PORT_DEFAULT = 7443;
public static final String HTTP_BIND_THREADS = "httpbind.client.processing.threads"; public static final String HTTP_BIND_THREADS = "httpbind.client.processing.threads";
public static final int HTTP_BIND_THREADS_DEFAULT = 254; public static final int HTTP_BIND_THREADS_DEFAULT = 254;
private static final String HTTP_BIND_FORWARDED = "httpbind.forwarded.enabled"; private static final String HTTP_BIND_FORWARDED = "httpbind.forwarded.enabled";
private static final String HTTP_BIND_FORWARDED_FOR = "httpbind.forwarded.for.header"; private static final String HTTP_BIND_FORWARDED_FOR = "httpbind.forwarded.for.header";
private static final String HTTP_BIND_FORWARDED_SERVER = "httpbind.forwarded.server.header"; private static final String HTTP_BIND_FORWARDED_SERVER = "httpbind.forwarded.server.header";
private static final String HTTP_BIND_FORWARDED_HOST = "httpbind.forwarded.host.header"; private static final String HTTP_BIND_FORWARDED_HOST = "httpbind.forwarded.host.header";
private static final String HTTP_BIND_FORWARDED_HOST_NAME = "httpbind.forwarded.host.name"; private static final String HTTP_BIND_FORWARDED_HOST_NAME = "httpbind.forwarded.host.name";
// http binding CORS default properties // http binding CORS default properties
public static final String HTTP_BIND_CORS_ENABLED = "httpbind.CORS.enabled"; public static final String HTTP_BIND_CORS_ENABLED = "httpbind.CORS.enabled";
public static final boolean HTTP_BIND_CORS_ENABLED_DEFAULT = true; public static final boolean HTTP_BIND_CORS_ENABLED_DEFAULT = true;
public static final String HTTP_BIND_CORS_ALLOW_ORIGIN = "httpbind.CORS.domains"; public static final String HTTP_BIND_CORS_ALLOW_ORIGIN = "httpbind.CORS.domains";
public static final String HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT = "*"; public static final String HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT = "*";
public static final String HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT = "PROPFIND, PROPPATCH, COPY, MOVE, DELETE, MKCOL, LOCK, UNLOCK, PUT, GETLIB, VERSION-CONTROL, CHECKIN, CHECKOUT, UNCHECKOUT, REPORT, UPDATE, CANCELUPLOAD, HEAD, OPTIONS, GET, POST"; public static final String HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT = "PROPFIND, PROPPATCH, COPY, MOVE, DELETE, MKCOL, LOCK, UNLOCK, PUT, GETLIB, VERSION-CONTROL, CHECKIN, CHECKOUT, UNCHECKOUT, REPORT, UPDATE, CANCELUPLOAD, HEAD, OPTIONS, GET, POST";
public static final String HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT = "Overwrite, Destination, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control"; public static final String HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT = "Overwrite, Destination, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control";
public static final String HTTP_BIND_CORS_MAX_AGE_DEFAULT = "86400"; public static final String HTTP_BIND_CORS_MAX_AGE_DEFAULT = "86400";
public static Map<String, Boolean> HTTP_BIND_ALLOWED_ORIGINS = new HashMap<String, Boolean>(); public static Map<String, Boolean> HTTP_BIND_ALLOWED_ORIGINS = new HashMap<String, Boolean>();
...@@ -124,10 +124,10 @@ public final class HttpBindManager { ...@@ -124,10 +124,10 @@ public final class HttpBindManager {
private HttpSessionManager httpSessionManager; private HttpSessionManager httpSessionManager;
private ContextHandlerCollection contexts; private ContextHandlerCollection contexts;
// is all orgin allowed flag // is all orgin allowed flag
private boolean allowAllOrigins; private boolean allowAllOrigins;
public static HttpBindManager getInstance() { public static HttpBindManager getInstance() {
return instance; return instance;
} }
...@@ -135,7 +135,7 @@ public final class HttpBindManager { ...@@ -135,7 +135,7 @@ public final class HttpBindManager {
private HttpBindManager() { private HttpBindManager() {
// JSP 2.0 uses commons-logging, so also override that implementation. // JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory"); System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
JiveGlobals.migrateProperty(HTTP_BIND_ENABLED); JiveGlobals.migrateProperty(HTTP_BIND_ENABLED);
JiveGlobals.migrateProperty(HTTP_BIND_PORT); JiveGlobals.migrateProperty(HTTP_BIND_PORT);
JiveGlobals.migrateProperty(HTTP_BIND_SECURE_PORT); JiveGlobals.migrateProperty(HTTP_BIND_SECURE_PORT);
...@@ -151,7 +151,7 @@ public final class HttpBindManager { ...@@ -151,7 +151,7 @@ public final class HttpBindManager {
PropertyEventDispatcher.addListener(new HttpServerPropertyListener()); PropertyEventDispatcher.addListener(new HttpServerPropertyListener());
this.httpSessionManager = new HttpSessionManager(); this.httpSessionManager = new HttpSessionManager();
contexts = new ContextHandlerCollection(); contexts = new ContextHandlerCollection();
// setup the cache for the allowed origins // setup the cache for the allowed origins
this.setupAllowedOriginsMap(); this.setupAllowedOriginsMap();
} }
...@@ -229,7 +229,7 @@ public final class HttpBindManager { ...@@ -229,7 +229,7 @@ public final class HttpBindManager {
// Set policy for checking client certificates // Set policy for checking client certificates
String certPol = JiveGlobals.getProperty("xmpp.client.cert.policy", "disabled"); String certPol = JiveGlobals.getProperty("xmpp.client.cert.policy", "disabled");
if(certPol.equals("needed")) { if(certPol.equals("needed")) {
sslContextFactory.setNeedClientAuth(true); sslContextFactory.setNeedClientAuth(true);
sslContextFactory.setWantClientAuth(true); sslContextFactory.setWantClientAuth(true);
} else if(certPol.equals("wanted")) { } else if(certPol.equals("wanted")) {
...@@ -347,10 +347,10 @@ public final class HttpBindManager { ...@@ -347,10 +347,10 @@ public final class HttpBindManager {
public String getJavaScriptUrl() { public String getJavaScriptUrl() {
return "http://" + XMPPServer.getInstance().getServerInfo().getXMPPDomain() + ":" + return "http://" + XMPPServer.getInstance().getServerInfo().getXMPPDomain() + ":" +
bindPort + "/scripts/"; bindPort + "/scripts/";
} }
// http binding CORS support start // http binding CORS support start
private void setupAllowedOriginsMap() { private void setupAllowedOriginsMap() {
String originString = getCORSAllowOrigin(); String originString = getCORSAllowOrigin();
if (originString.equals(HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT)) { if (originString.equals(HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT)) {
...@@ -365,20 +365,20 @@ public final class HttpBindManager { ...@@ -365,20 +365,20 @@ public final class HttpBindManager {
} }
} }
} }
public boolean isCORSEnabled() { public boolean isCORSEnabled() {
return JiveGlobals.getBooleanProperty(HTTP_BIND_CORS_ENABLED, HTTP_BIND_CORS_ENABLED_DEFAULT); return JiveGlobals.getBooleanProperty(HTTP_BIND_CORS_ENABLED, HTTP_BIND_CORS_ENABLED_DEFAULT);
} }
public void setCORSEnabled(Boolean value) { public void setCORSEnabled(Boolean value) {
if (value != null) if (value != null)
JiveGlobals.setProperty(HTTP_BIND_CORS_ENABLED, String.valueOf(value)); JiveGlobals.setProperty(HTTP_BIND_CORS_ENABLED, String.valueOf(value));
} }
public String getCORSAllowOrigin() { public String getCORSAllowOrigin() {
return JiveGlobals.getProperty(HTTP_BIND_CORS_ALLOW_ORIGIN , HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT); return JiveGlobals.getProperty(HTTP_BIND_CORS_ALLOW_ORIGIN , HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT);
} }
public void setCORSAllowOrigin(String origins) { public void setCORSAllowOrigin(String origins) {
if (origins == null || origins.trim().length() == 0) if (origins == null || origins.trim().length() == 0)
origins = HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT; origins = HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT;
...@@ -388,29 +388,29 @@ public final class HttpBindManager { ...@@ -388,29 +388,29 @@ public final class HttpBindManager {
JiveGlobals.setProperty(HTTP_BIND_CORS_ALLOW_ORIGIN, origins); JiveGlobals.setProperty(HTTP_BIND_CORS_ALLOW_ORIGIN, origins);
setupAllowedOriginsMap(); setupAllowedOriginsMap();
} }
public boolean isAllOriginsAllowed() { public boolean isAllOriginsAllowed() {
return allowAllOrigins; return allowAllOrigins;
} }
public boolean isThisOriginAllowed(String origin) { public boolean isThisOriginAllowed(String origin) {
return HTTP_BIND_ALLOWED_ORIGINS.get(origin) != null; return HTTP_BIND_ALLOWED_ORIGINS.get(origin) != null;
} }
// http binding CORS support end // http binding CORS support end
public boolean isXFFEnabled() { public boolean isXFFEnabled() {
return JiveGlobals.getBooleanProperty(HTTP_BIND_FORWARDED, false); return JiveGlobals.getBooleanProperty(HTTP_BIND_FORWARDED, false);
} }
public void setXFFEnabled(boolean enabled) { public void setXFFEnabled(boolean enabled) {
JiveGlobals.setProperty(HTTP_BIND_FORWARDED, String.valueOf(enabled)); JiveGlobals.setProperty(HTTP_BIND_FORWARDED, String.valueOf(enabled));
} }
public String getXFFHeader() { public String getXFFHeader() {
return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_FOR); return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_FOR);
} }
public void setXFFHeader(String header) { public void setXFFHeader(String header) {
if (header == null || header.trim().length() == 0) { if (header == null || header.trim().length() == 0) {
JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_FOR); JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_FOR);
...@@ -418,11 +418,11 @@ public final class HttpBindManager { ...@@ -418,11 +418,11 @@ public final class HttpBindManager {
JiveGlobals.setProperty(HTTP_BIND_FORWARDED_FOR, header); JiveGlobals.setProperty(HTTP_BIND_FORWARDED_FOR, header);
} }
} }
public String getXFFServerHeader() { public String getXFFServerHeader() {
return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_SERVER); return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_SERVER);
} }
public void setXFFServerHeader(String header) { public void setXFFServerHeader(String header) {
if (header == null || header.trim().length() == 0) { if (header == null || header.trim().length() == 0) {
JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_SERVER); JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_SERVER);
...@@ -430,11 +430,11 @@ public final class HttpBindManager { ...@@ -430,11 +430,11 @@ public final class HttpBindManager {
JiveGlobals.setProperty(HTTP_BIND_FORWARDED_SERVER, header); JiveGlobals.setProperty(HTTP_BIND_FORWARDED_SERVER, header);
} }
} }
public String getXFFHostHeader() { public String getXFFHostHeader() {
return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_HOST); return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_HOST);
} }
public void setXFFHostHeader(String header) { public void setXFFHostHeader(String header) {
if (header == null || header.trim().length() == 0) { if (header == null || header.trim().length() == 0) {
JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_HOST); JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_HOST);
...@@ -442,11 +442,11 @@ public final class HttpBindManager { ...@@ -442,11 +442,11 @@ public final class HttpBindManager {
JiveGlobals.setProperty(HTTP_BIND_FORWARDED_HOST, header); JiveGlobals.setProperty(HTTP_BIND_FORWARDED_HOST, header);
} }
} }
public String getXFFHostName() { public String getXFFHostName() {
return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_HOST_NAME); return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_HOST_NAME);
} }
public void setXFFHostName(String name) { public void setXFFHostName(String name) {
if (name == null || name.trim().length() == 0) { if (name == null || name.trim().length() == 0) {
JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_HOST_NAME); JiveGlobals.deleteProperty(HTTP_BIND_FORWARDED_HOST_NAME);
...@@ -454,7 +454,7 @@ public final class HttpBindManager { ...@@ -454,7 +454,7 @@ public final class HttpBindManager {
JiveGlobals.setProperty(HTTP_BIND_FORWARDED_HOST_NAME, name); JiveGlobals.setProperty(HTTP_BIND_FORWARDED_HOST_NAME, name);
} }
} }
public void setHttpBindEnabled(boolean isEnabled) { public void setHttpBindEnabled(boolean isEnabled) {
JiveGlobals.setProperty(HTTP_BIND_ENABLED, String.valueOf(isEnabled)); JiveGlobals.setProperty(HTTP_BIND_ENABLED, String.valueOf(isEnabled));
} }
...@@ -536,7 +536,7 @@ public final class HttpBindManager { ...@@ -536,7 +536,7 @@ public final class HttpBindManager {
} }
createBoshHandler(contexts, "/http-bind"); createBoshHandler(contexts, "/http-bind");
createCrossDomainHandler(contexts, "/"); createCrossDomainHandler(contexts, "/crossdomain.xml");
loadStaticDirectory(contexts); loadStaticDirectory(contexts);
HandlerCollection collection = new HandlerCollection(); HandlerCollection collection = new HandlerCollection();
...@@ -553,7 +553,7 @@ public final class HttpBindManager { ...@@ -553,7 +553,7 @@ public final class HttpBindManager {
private void createCrossDomainHandler(ContextHandlerCollection contexts, String crossPath) private void createCrossDomainHandler(ContextHandlerCollection contexts, String crossPath)
{ {
ServletContextHandler context = new ServletContextHandler(contexts, crossPath, ServletContextHandler.SESSIONS); ServletContextHandler context = new ServletContextHandler(contexts, crossPath, ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new FlashCrossDomainServlet()),"/crossdomain.xml"); context.addServlet(new ServletHolder(new FlashCrossDomainServlet()),"");
} }
private void loadStaticDirectory(ContextHandlerCollection contexts) { private void loadStaticDirectory(ContextHandlerCollection contexts) {
...@@ -726,7 +726,7 @@ public final class HttpBindManager { ...@@ -726,7 +726,7 @@ public final class HttpBindManager {
} }
else if (property.equalsIgnoreCase(HTTP_BIND_SECURE_PORT)) { else if (property.equalsIgnoreCase(HTTP_BIND_SECURE_PORT)) {
setSecureHttpBindPort(HTTP_BIND_SECURE_PORT_DEFAULT); setSecureHttpBindPort(HTTP_BIND_SECURE_PORT_DEFAULT);
} }
} }
public void xmlPropertySet(String property, Map<String, Object> params) { public void xmlPropertySet(String property, Map<String, Object> params) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment