Commit 77e98eb9 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

1. Removed ServletHolder from HttpBindManager

2. Added error logice to http binding configuration
3. Jetty error will now perculate up rather then being caught in the configuration method. This allows the end user to see that there was a problem configuring the ports.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6259 b35dd754-fafc-0310-a699-88a17e54d16e
parent 42559b5b
...@@ -222,6 +222,7 @@ ...@@ -222,6 +222,7 @@
<url>file://$MODULE_DIR$/target/resources</url> <url>file://$MODULE_DIR$/target/resources</url>
</containerElement> </containerElement>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/web/WEB-INF/web.xml" optional="false" version="2.3" /> <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/web/WEB-INF/web.xml" optional="false" version="2.3" />
<deploymentDescriptor name="context.xml" url="file://$MODULE_DIR$/src/web/META-INF/context.xml" optional="false" version="5.x" />
<webroots> <webroots>
<root url="file://$MODULE_DIR$/src/web" relative="/" /> <root url="file://$MODULE_DIR$/src/web" relative="/" />
<root url="file://$MODULE_DIR$/src/web/WEB-INF" relative="/WEB-INF" /> <root url="file://$MODULE_DIR$/src/web/WEB-INF" relative="/WEB-INF" />
......
...@@ -2041,3 +2041,5 @@ profile-settings.info=Wildfire nyn\u00ed pou\u017e\u00edv\u00e1 n\u00e1sleduj\u0 ...@@ -2041,3 +2041,5 @@ profile-settings.info=Wildfire nyn\u00ed pou\u017e\u00edv\u00e1 n\u00e1sleduj\u0
LDAP je mo\u017en\u00e9 zm\u011bnit sou\u010dasn\u00e1 nastaven\u00ed integrace. A\u010dkoliv, pokud chcete zm\u011bnit syst\u00e9m u\u017eivatel\u016f a skupin, LDAP je mo\u017en\u00e9 zm\u011bnit sou\u010dasn\u00e1 nastaven\u00ed integrace. A\u010dkoliv, pokud chcete zm\u011bnit syst\u00e9m u\u017eivatel\u016f a skupin,
budete muset znovu spustit proces nastaven\u00ed. budete muset znovu spustit proces nastaven\u00ed.
profile-settings.ldap_mapping_info=Informace o mapov\u00e1n\u00ed LDAP profile-settings.ldap_mapping_info=Informace o mapov\u00e1n\u00ed LDAP
httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1791,4 +1791,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports ...@@ -1791,4 +1791,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports
httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console
httpbind.settings.label_same=Use Distinct Ports httpbind.settings.label_same=Use Distinct Ports
httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console
httpbind.settings.secure_port=Secure Port httpbind.settings.secure_port=Secure Port
\ No newline at end of file httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -125,23 +125,6 @@ ...@@ -125,23 +125,6 @@
## Added key: 'plugin.enterprise.installing' ## Added key: 'plugin.enterprise.installing'
## Added key: 'plugin.enterprise.installed' ## Added key: 'plugin.enterprise.installed'
## ##
## 3.2.0
## Added key: 'sidebar.http-bind'
## Added key: 'sidebar.http-bind.descr'
## Added key: 'httpbind.settings.enabled.legend'
## Added key: 'httpbind.settings.title'
## Added key: 'httpbind.settings.info'
## Added key: 'httpbind.settings.label_disable'
## Added key: 'httpbind.settings.label_disable_info'
## Added key: 'httpbind.settings.label_enable'
## Added key: 'httpbind.settings.label_enable_info'
## Added key: 'httpbind.settings.vanilla_port'
## Added key: 'httpbind.settings.label_seperate'
## Added key: 'httpbind.settings.label_seperate_info'
## Added key: 'httpbind.settings.label_same'
## Added key: 'httpbind.settings.label_same_info'
## Added key: 'httpbind.settings.secure_port'
##
## 3.1.1 ## 3.1.1
## Added key: 'global.second' ## Added key: 'global.second'
## Added key: 'global.minute' ## Added key: 'global.minute'
...@@ -211,6 +194,23 @@ ...@@ -211,6 +194,23 @@
## Removed key: 'ssl.certificates.error_installing' ## Removed key: 'ssl.certificates.error_installing'
## Removed key: 'ssl.certificates.error_reported' ## Removed key: 'ssl.certificates.error_reported'
## Removed key: 'ssl.certificates.paste_certificate' ## Removed key: 'ssl.certificates.paste_certificate'
## Added key: 'sidebar.http-bind'
## Added key: 'sidebar.http-bind.descr'
## Added key: 'httpbind.settings.enabled.legend'
## Added key: 'httpbind.settings.title'
## Added key: 'httpbind.settings.info'
## Added key: 'httpbind.settings.label_disable'
## Added key: 'httpbind.settings.label_disable_info'
## Added key: 'httpbind.settings.label_enable'
## Added key: 'httpbind.settings.label_enable_info'
## Added key: 'httpbind.settings.vanilla_port'
## Added key: 'httpbind.settings.label_seperate'
## Added key: 'httpbind.settings.label_seperate_info'
## Added key: 'httpbind.settings.label_same'
## Added key: 'httpbind.settings.label_same_info'
## Added key: 'httpbind.settings.secure_port'
## Added key: 'httpbind.settings.error.general'
## Added key: 'httpbind.settings.error.port'
# Wildfire # Wildfire
...@@ -2239,6 +2239,8 @@ httpbind.settings.label_seperate_info=The HTTP bind service will be run on the s ...@@ -2239,6 +2239,8 @@ httpbind.settings.label_seperate_info=The HTTP bind service will be run on the s
httpbind.settings.label_same=Use Distinct Ports httpbind.settings.label_same=Use Distinct Ports
httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console
httpbind.settings.secure_port=SSL Port: httpbind.settings.secure_port=SSL Port:
httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
# Profile Settings # Profile Settings
...@@ -2246,4 +2248,4 @@ profile-settings.title=Profile Settings ...@@ -2246,4 +2248,4 @@ profile-settings.title=Profile Settings
profile-settings.info=Wildfire is currently using the following user and group system. When using \ profile-settings.info=Wildfire is currently using the following user and group system. When using \
LDAP it is possible to alter current integration settings. However, if you want to change the user and group \ LDAP it is possible to alter current integration settings. However, if you want to change the user and group \
system then you will need to re-run the setup process. system then you will need to re-run the setup process.
profile-settings.ldap_mapping_info=LDAP Settings profile-settings.ldap_mapping_info=LDAP Settings
\ No newline at end of file
...@@ -1916,3 +1916,5 @@ profile-settings.info=Wildfire esta utilizando el siguiente sistema de usuarios ...@@ -1916,3 +1916,5 @@ profile-settings.info=Wildfire esta utilizando el siguiente sistema de usuarios
LDAP es posible cambiar la configuraci\u00f3n actual. Sin embargo, si desea modificar el sistema de usuarios y grupos \ LDAP es posible cambiar la configuraci\u00f3n actual. Sin embargo, si desea modificar el sistema de usuarios y grupos \
entonces deber\u00e1 volver a realizar el proceso de configuraci\u00f3n inicial. entonces deber\u00e1 volver a realizar el proceso de configuraci\u00f3n inicial.
profile-settings.ldap_mapping_info=Informaci\u00f3n del Mapeo a LDAP profile-settings.ldap_mapping_info=Informaci\u00f3n del Mapeo a LDAP
httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1628,3 +1628,5 @@ database.upgrade.unknown_db = Attention\: Base de donn\u00E9es de type inconnu\: ...@@ -1628,3 +1628,5 @@ database.upgrade.unknown_db = Attention\: Base de donn\u00E9es de type inconnu\:
group.create.enter_a_group_name = Saisisser un Nom d'affichage pour le Groupe. group.create.enter_a_group_name = Saisisser un Nom d'affichage pour le Groupe.
plugin.admin.refresh_success = Le Plugin a \u00E9t\u00E9 rafra\u00EEchi avec succ\u00E8s. plugin.admin.refresh_success = Le Plugin a \u00E9t\u00E9 rafra\u00EEchi avec succ\u00E8s.
server2server.settings.port = Port\: server2server.settings.port = Port\:
httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1796,4 +1796,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports ...@@ -1796,4 +1796,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports
httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console
httpbind.settings.label_same=Use Distinct Ports httpbind.settings.label_same=Use Distinct Ports
httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console
httpbind.settings.secure_port=Secure Port httpbind.settings.secure_port=Secure Port
\ No newline at end of file httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1767,4 +1767,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports ...@@ -1767,4 +1767,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports
httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console
httpbind.settings.label_same=Use Distinct Ports httpbind.settings.label_same=Use Distinct Ports
httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console
httpbind.settings.secure_port=Secure Port httpbind.settings.secure_port=Secure Port
\ No newline at end of file httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1797,4 +1797,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports ...@@ -1797,4 +1797,6 @@ httpbind.settings.label_seperate=Use Admin Console Ports
httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console httpbind.settings.label_seperate_info=The HTTP bind service will be run on the same ports as the admin console
httpbind.settings.label_same=Use Distinct Ports httpbind.settings.label_same=Use Distinct Ports
httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console httpbind.settings.label_same_info=The HTTP bind service will use distinct ports from those of the admin console
httpbind.settings.secure_port=Secure Port httpbind.settings.secure_port=Secure Port
\ No newline at end of file httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -1850,3 +1850,5 @@ plugin.enterprise.installed = \u4f01\u4e1a\u63d2\u4ef6\u5b89\u88c5\u6210\u529f\u ...@@ -1850,3 +1850,5 @@ plugin.enterprise.installed = \u4f01\u4e1a\u63d2\u4ef6\u5b89\u88c5\u6210\u529f\u
profile-settings.title=\u7279\u6027\u8bbe\u7f6e profile-settings.title=\u7279\u6027\u8bbe\u7f6e
profile-settings.info=Wildfire\u73b0\u5728\u4f7f\u7528\u4e0b\u9762\u7684\u7528\u6237\u548c\u7ec4\u7cfb\u7edf\u3002\u5f53\u4f7f\u7528LDAP\u65f6\u4f1a\u6539\u53d8\u5f53\u524d\u7684\u7efc\u5408\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u5982\u679c\u60a8\u9700\u8981\u6539\u53d8\u7528\u6237\u548c\u7ec4\u7cfb\u7edf\uff0c\u60a8\u9700\u8981\u91cd\u65b0\u8fd0\u884c\u8bbe\u7f6e\u8fc7\u7a0b\u3002 profile-settings.info=Wildfire\u73b0\u5728\u4f7f\u7528\u4e0b\u9762\u7684\u7528\u6237\u548c\u7ec4\u7cfb\u7edf\u3002\u5f53\u4f7f\u7528LDAP\u65f6\u4f1a\u6539\u53d8\u5f53\u524d\u7684\u7efc\u5408\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u5982\u679c\u60a8\u9700\u8981\u6539\u53d8\u7528\u6237\u548c\u7ec4\u7cfb\u7edf\uff0c\u60a8\u9700\u8981\u91cd\u65b0\u8fd0\u884c\u8bbe\u7f6e\u8fc7\u7a0b\u3002
profile-settings.ldap_mapping_info=LDAP\u6620\u5c04\u4fe1\u606f profile-settings.ldap_mapping_info=LDAP\u6620\u5c04\u4fe1\u606f
httpbind.settings.error.general=An error has occured, check the log file for details.
httpbind.settings.error.port=An error has occured configuring the HTTP binding ports, check the error log for more details.
\ No newline at end of file
...@@ -26,6 +26,7 @@ import org.mortbay.jetty.servlet.ServletMapping; ...@@ -26,6 +26,7 @@ import org.mortbay.jetty.servlet.ServletMapping;
import org.mortbay.log.Logger; import org.mortbay.log.Logger;
import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLServerSocketFactory;
import javax.servlet.http.HttpServlet;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -79,7 +80,8 @@ public class HttpServerManager { ...@@ -79,7 +80,8 @@ public class HttpServerManager {
private Server adminServer; private Server adminServer;
private Server httpBindServer; private Server httpBindServer;
private Context adminConsoleContext; private Context adminConsoleContext;
private Map<ServletHolder, String> httpBindContexts; private Map<HttpServlet, String> httpBindServlets;
private List<ServletHolder> httpBindContexts = new ArrayList<ServletHolder>();
private CertificateEventListener certificateListener; private CertificateEventListener certificateListener;
private boolean restartNeeded = false; private boolean restartNeeded = false;
...@@ -111,8 +113,8 @@ public class HttpServerManager { ...@@ -111,8 +113,8 @@ public class HttpServerManager {
* *
* @param contexts a collection of servlets utilized by the HTTP binding service. * @param contexts a collection of servlets utilized by the HTTP binding service.
*/ */
public void setHttpBindContext(Map<ServletHolder,String> contexts) { public void setHttpBindContext(Map<HttpServlet, String> contexts) {
this.httpBindContexts = contexts; this.httpBindServlets = contexts;
} }
/** /**
...@@ -126,11 +128,11 @@ public class HttpServerManager { ...@@ -126,11 +128,11 @@ public class HttpServerManager {
certificateListener = new CertificateListener(); certificateListener = new CertificateListener();
CertificateManager.addListener(certificateListener); CertificateManager.addListener(certificateListener);
if (httpBindContexts != null && isHttpBindServiceEnabled()) { if (httpBindServlets != null && isHttpBindServiceEnabled()) {
bindPort = JiveGlobals.getIntProperty(HTTP_BIND_PORT, ADMIN_CONSOLE_PORT_DEFAULT); bindPort = JiveGlobals.getIntProperty(HTTP_BIND_PORT, ADMIN_CONSOLE_PORT_DEFAULT);
bindSecurePort = JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, bindSecurePort = JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT,
ADMIN_CONSOLE_SECURE_PORT_DEFAULT); ADMIN_CONSOLE_SECURE_PORT_DEFAULT);
startHttpBindServer(bindPort, bindSecurePort); configureHttpBindServer(bindPort, bindSecurePort);
} }
if (adminConsoleContext != null) { if (adminConsoleContext != null) {
createAdminConsoleServer(); createAdminConsoleServer();
...@@ -169,8 +171,8 @@ public class HttpServerManager { ...@@ -169,8 +171,8 @@ public class HttpServerManager {
if (httpBindServer != null && httpBindServer.isRunning()) { if (httpBindServer != null && httpBindServer.isRunning()) {
httpBindServer.stop(); httpBindServer.stop();
} }
if (httpBindContexts != null) { if (httpBindServlets != null) {
for(ServletHolder httpBindContext : httpBindContexts.keySet()) { for(ServletHolder httpBindContext : httpBindContexts) {
httpBindContext.stop(); httpBindContext.stop();
} }
} }
...@@ -255,8 +257,9 @@ public class HttpServerManager { ...@@ -255,8 +257,9 @@ public class HttpServerManager {
* *
* @param unsecurePort the unsecured connection port which clients can connect to. * @param unsecurePort the unsecured connection port which clients can connect to.
* @param securePort the secured connection port which clients can connect to. * @param securePort the secured connection port which clients can connect to.
* @throws Exception when there is an error configuring the HTTP binding ports.
*/ */
public void setHttpBindPorts(int unsecurePort, int securePort) { public void setHttpBindPorts(int unsecurePort, int securePort) throws Exception {
changeHttpBindPorts(unsecurePort, securePort); changeHttpBindPorts(unsecurePort, securePort);
bindPort = unsecurePort; bindPort = unsecurePort;
bindSecurePort = securePort; bindSecurePort = securePort;
...@@ -299,7 +302,7 @@ public class HttpServerManager { ...@@ -299,7 +302,7 @@ public class HttpServerManager {
* @param port the port to start the normal (unsecured) HTTP Bind service on. * @param port the port to start the normal (unsecured) HTTP Bind service on.
* @param securePort the port to start the TLS (secure) HTTP Bind service on. * @param securePort the port to start the TLS (secure) HTTP Bind service on.
*/ */
private void startHttpBindServer(int port, int securePort) { private void configureHttpBindServer(int port, int securePort) {
httpBindServer = new Server(); httpBindServer = new Server();
Connector httpConnector = createConnector(port); Connector httpConnector = createConnector(port);
Connector httpsConnector = createSSLConnector(securePort); Connector httpsConnector = createSSLConnector(securePort);
...@@ -415,9 +418,10 @@ public class HttpServerManager { ...@@ -415,9 +418,10 @@ public class HttpServerManager {
private void addContexts() { private void addContexts() {
if (httpBindServer == adminServer && httpBindServer != null) { if (httpBindServer == adminServer && httpBindServer != null) {
for (Map.Entry<ServletHolder, String> httpBindContext : httpBindContexts.entrySet()) { for (Map.Entry<HttpServlet, String> httpBindContext : httpBindServlets.entrySet()) {
adminConsoleContext.addServlet(httpBindContext.getKey(), ServletHolder holder = new ServletHolder(httpBindContext.getKey());
httpBindContext.getValue()); httpBindContexts.add(holder);
adminConsoleContext.addServlet(holder, httpBindContext.getValue());
} }
if (adminServer.getHandler() == null) { if (adminServer.getHandler() == null) {
adminServer.addHandler(adminConsoleContext); adminServer.addHandler(adminConsoleContext);
...@@ -434,9 +438,10 @@ public class HttpServerManager { ...@@ -434,9 +438,10 @@ public class HttpServerManager {
} }
if (httpBindServer != null) { if (httpBindServer != null) {
ServletHandler servletHandler = new ServletHandler(); ServletHandler servletHandler = new ServletHandler();
for (Map.Entry<ServletHolder, String> httpBindContext : httpBindContexts.entrySet()) { for (Map.Entry<HttpServlet, String> httpBindContext : httpBindServlets.entrySet()) {
servletHandler.addServletWithMapping(httpBindContext.getKey(), ServletHolder holder = new ServletHolder(httpBindContext.getKey());
httpBindContext.getValue()); httpBindContexts.add(holder);
servletHandler.addServletWithMapping(holder, httpBindContext.getValue());
} }
httpBindServer.addHandler(servletHandler); httpBindServer.addHandler(servletHandler);
} }
...@@ -452,9 +457,10 @@ public class HttpServerManager { ...@@ -452,9 +457,10 @@ public class HttpServerManager {
ServletMapping[] servletMappings = handler.getServletMappings(); ServletMapping[] servletMappings = handler.getServletMappings();
List<ServletMapping> toAdd = new ArrayList<ServletMapping>(); List<ServletMapping> toAdd = new ArrayList<ServletMapping>();
List<String> servletNames = new ArrayList<String>(); List<String> servletNames = new ArrayList<String>();
for(ServletHolder holder : httpBindContexts.keySet()) { for(ServletHolder holder : httpBindContexts) {
servletNames.add(holder.getName()); servletNames.add(holder.getName());
} }
for (ServletMapping mapping : servletMappings) { for (ServletMapping mapping : servletMappings) {
if (servletNames.contains(mapping.getServletName())) { if (servletNames.contains(mapping.getServletName())) {
continue; continue;
...@@ -466,7 +472,8 @@ public class HttpServerManager { ...@@ -466,7 +472,8 @@ public class HttpServerManager {
for(ServletHolder holder : handler.getServlets()) { for(ServletHolder holder : handler.getServlets()) {
toAddServlets.add(holder); toAddServlets.add(holder);
} }
toAddServlets.removeAll(httpBindContexts.keySet()); toAddServlets.removeAll(httpBindContexts);
httpBindContexts.clear();
handler.setServletMappings(toAdd.toArray(new ServletMapping[toAdd.size()])); handler.setServletMappings(toAdd.toArray(new ServletMapping[toAdd.size()]));
handler.setServlets(toAddServlets.toArray(new ServletHolder[toAddServlets.size()])); handler.setServlets(toAddServlets.toArray(new ServletHolder[toAddServlets.size()]));
...@@ -506,7 +513,7 @@ public class HttpServerManager { ...@@ -506,7 +513,7 @@ public class HttpServerManager {
return null; return null;
} }
private void changeHttpBindPorts(int unsecurePort, int securePort) { private void changeHttpBindPorts(int unsecurePort, int securePort) throws Exception {
if (unsecurePort < 0 && securePort < 0) { if (unsecurePort < 0 && securePort < 0) {
throw new IllegalArgumentException("At least one port must be greater than zero."); throw new IllegalArgumentException("At least one port must be greater than zero.");
} }
...@@ -542,28 +549,23 @@ public class HttpServerManager { ...@@ -542,28 +549,23 @@ public class HttpServerManager {
} }
if (httpBindServer != adminServer) { if (httpBindServer != adminServer) {
try { httpBindServer.stop();
httpBindServer.stop();
}
catch (Exception e) {
Log.error("Error stopping HTTP bind service", e);
}
} }
startHttpBindServer(unsecurePort, securePort); configureHttpBindServer(unsecurePort, securePort);
addContexts(); addContexts();
try { httpBindServer.start();
httpBindServer.start();
}
catch (Exception e) {
Log.error("Error starting HTTP bind service", e);
}
} }
private void doEnableHttpBind(boolean shouldEnable) { private void doEnableHttpBind(boolean shouldEnable) {
if (shouldEnable && httpBindServer == null) { if (shouldEnable && httpBindServer == null) {
changeHttpBindPorts(JiveGlobals.getIntProperty(HTTP_BIND_PORT, try {
changeHttpBindPorts(JiveGlobals.getIntProperty(HTTP_BIND_PORT,
ADMIN_CONSOLE_PORT_DEFAULT), JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, ADMIN_CONSOLE_PORT_DEFAULT), JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT,
ADMIN_CONSOLE_SECURE_PORT_DEFAULT)); ADMIN_CONSOLE_SECURE_PORT_DEFAULT));
}
catch (Exception e) {
Log.error("Error configuring HTTP binding ports", e);
}
} }
else if (!shouldEnable && httpBindServer != null) { else if (!shouldEnable && httpBindServer != null) {
if (httpBindServer != adminServer) { if (httpBindServer != adminServer) {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
package org.jivesoftware.wildfire.http; package org.jivesoftware.wildfire.http;
import org.mortbay.jetty.servlet.ServletHolder; import javax.servlet.http.HttpServlet;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
...@@ -31,9 +30,9 @@ public class HttpBindManager { ...@@ -31,9 +30,9 @@ public class HttpBindManager {
* *
* @return all the servlets that are part of the http-bind service. * @return all the servlets that are part of the http-bind service.
*/ */
public Map<ServletHolder, String> getServlets() { public Map<HttpServlet, String> getServlets() {
Map<ServletHolder, String> servlets = new HashMap<ServletHolder, String>(); Map<HttpServlet, String> servlets = new HashMap<HttpServlet, String>();
servlets.put(new ServletHolder(new HttpBindServlet(new HttpSessionManager())), servlets.put(new HttpBindServlet(new HttpSessionManager()),
"/http-bind/"); "/http-bind/");
return servlets; return servlets;
......
<%@ page import="org.jivesoftware.wildfire.HttpServerManager" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%-- <%--
- $Revision: $ - $Revision: $
- $Date: $ - $Date: $
...@@ -11,14 +7,19 @@ ...@@ -11,14 +7,19 @@
- This software is published under the terms of the GNU Public License (GPL), - This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution. - a copy of which is included in this distribution.
--%> --%>
<%@ page import="org.jivesoftware.wildfire.HttpServerManager" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.jivesoftware.util.Log" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%! <%!
Map<String, String> errorMap = new HashMap<String, String>();
HttpServerManager serverManager = HttpServerManager.getInstance(); HttpServerManager serverManager = HttpServerManager.getInstance();
void handleUpdate(HttpServletRequest request) { Map<String, String> handleUpdate(HttpServletRequest request) {
Map<String, String> errorMap = new HashMap<String, String>();
boolean isEnabled = ParamUtils.getBooleanParameter(request, "httpBindEnabled"); boolean isEnabled = ParamUtils.getBooleanParameter(request, "httpBindEnabled");
if (isEnabled) { if (isEnabled) {
boolean httpPortsDistinct = ParamUtils.getBooleanParameter(request, "httpPortsDistinct", boolean httpPortsDistinct = ParamUtils.getBooleanParameter(request, "httpPortsDistinct",
...@@ -37,16 +38,21 @@ ...@@ -37,16 +38,21 @@
serverManager.setHttpBindPorts(requestedPort, requestedSecurePort); serverManager.setHttpBindPorts(requestedPort, requestedSecurePort);
} }
catch (Exception e) { catch (Exception e) {
Log.error("An error has occured configuring the HTTP binding ports", e);
errorMap.put("port", e.getMessage()); errorMap.put("port", e.getMessage());
} }
} }
serverManager.setHttpBindEnabled(isEnabled); if (errorMap.size() <= 0) {
serverManager.setHttpBindEnabled(isEnabled);
}
return errorMap;
} }
%> %>
<% <%
Map<String, String> errorMap = new HashMap<String, String>();
if (request.getParameter("update") != null) { if (request.getParameter("update") != null) {
handleUpdate(request); errorMap = handleUpdate(request);
} }
boolean isHttpBindEnabled = serverManager.isHttpBindEnabled(); boolean isHttpBindEnabled = serverManager.isHttpBindEnabled();
...@@ -60,11 +66,34 @@ ...@@ -60,11 +66,34 @@
<fmt:message key="httpbind.settings.title"/> <fmt:message key="httpbind.settings.title"/>
</title> </title>
<meta name="pageID" content="http-bind"/> <meta name="pageID" content="http-bind"/>
<script type="text/javascript">
var enabled = <%=isHttpBindEnabled%>;
var distinct = <%=isHttpBindServerSperate%>
var setEnabled = function() {
$("rb03").disabled = !enabled;
$("rb04").disabled = !enabled;
$("port").disabled = !enabled || !distinct;
$("securePort").disabled = !enabled || !distinct;
}
window.onload = setTimeout("setEnabled()", 500);
</script>
</head> </head>
<body> <body>
<p> <p>
<fmt:message key="httpbind.settings.info"/> <fmt:message key="httpbind.settings.info"/>
</p> </p>
<% if (errorMap.size() > 0) {
for (String key : errorMap.keySet()) { %>
<div class="error" style="width: 400px">
<% if (key.equals("port")) { %>
<fmt:message key="httpbind.settings.error.port"/>
<% }
else { %>
<fmt:message key="httpbind.settings.error.general"/>
<% } %>
</div>
<% }
} %>
<form action="http-bind.jsp" method="post"> <form action="http-bind.jsp" method="post">
<div class="jive-contentBoxHeader"> <div class="jive-contentBoxHeader">
...@@ -76,6 +105,7 @@ ...@@ -76,6 +105,7 @@
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="httpBindEnabled" value="false" id="rb01" <input type="radio" name="httpBindEnabled" value="false" id="rb01"
onclick="enabled = false; setEnabled();"
<%= (!isHttpBindEnabled ? "checked" : "") %>> <%= (!isHttpBindEnabled ? "checked" : "") %>>
</td> </td>
<td width="99%" colspan="2"> <td width="99%" colspan="2">
...@@ -90,6 +120,7 @@ ...@@ -90,6 +120,7 @@
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="httpBindEnabled" value="true" id="rb02" <input type="radio" name="httpBindEnabled" value="true" id="rb02"
onclick="enabled = true; setEnabled();"
<%= (isHttpBindEnabled ? "checked" : "") %>> <%= (isHttpBindEnabled ? "checked" : "") %>>
</td> </td>
<td width="99%" colspan="2"> <td width="99%" colspan="2">
...@@ -107,6 +138,7 @@ ...@@ -107,6 +138,7 @@
</td> </td>
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="httpPortsDistinct" value="false" id="rb03" <input type="radio" name="httpPortsDistinct" value="false" id="rb03"
onclick="distinct = false; setEnabled();"
<%= (!isHttpBindServerSperate ? "checked" : "") %>> <%= (!isHttpBindServerSperate ? "checked" : "") %>>
</td> </td>
<td width="98%"> <td width="98%">
...@@ -124,6 +156,7 @@ ...@@ -124,6 +156,7 @@
</td> </td>
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="httpPortsDistinct" value="true" id="rb04" <input type="radio" name="httpPortsDistinct" value="true" id="rb04"
onclick="distinct = true; setEnabled();"
<%= (isHttpBindServerSperate ? "checked" : "") %>> <%= (isHttpBindServerSperate ? "checked" : "") %>>
</td> </td>
<td width="98%"> <td width="98%">
......
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