Commit bef17ad9 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Refactored use of Jetty, upgraded to latest Jetty release.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6692 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6ab03a8a
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
</not> </not>
</condition> </condition>
<fail if="ant.not.ok" message="Must use Ant 1.6.x or 1.7.x to build Wildfire"/> <fail if="ant.not.ok" message="Must use Ant 1.6.x or 1.7.x to build Wildfire"/>
<fail if="java.not.ok" message="Must use JDK 1.5.x to build Wildfire"/> <fail if="java.not.ok" message="Must use JDK 1.5.x or higher to build Wildfire"/>
<tstamp/> <tstamp/>
<tstamp> <tstamp>
......
Name | Version Name | Version
--------------------------------------------- ---------------------------------------------
ant.jar | Jetty 6.0.1 (1.6.5) ant.jar | Jetty 6.1.0 (1.6.5)
ant-contrib.jar | 1.0b1 ant-contrib.jar | 1.0b1
ant-subdirtask.jar | Revision 1.4 (CVS) ant-subdirtask.jar | Revision 1.4 (CVS)
bouncycastle.jar | JDK 1.5, 134 (bcprov-jdk15-134.jar) bouncycastle.jar | JDK 1.5, 134 (bcprov-jdk15-134.jar)
...@@ -11,10 +11,10 @@ commons-codec.jar | 1.3 ...@@ -11,10 +11,10 @@ commons-codec.jar | 1.3
dom4j.jar | 1.6.1 dom4j.jar | 1.6.1
dbutil.jar | Jive Code, no release version. dbutil.jar | Jive Code, no release version.
hsqldb.jar | 1.8.0.5 hsqldb.jar | 1.8.0.5
jetty.jar | Jetty 6.1.0 SVN SNAPSHOT (11/15/2006) jetty.jar | Jetty 6.1.0
jetty-util.jar | Jetty 6.1.0 SVN SNAPSHOT (11/16/2006) jetty-util.jar | Jetty 6.1.0
jasper-compiler.jar | Jetty 6.0.1 (5.5.15) jasper-compiler.jar | Jetty 6.1.0 (5.5.15)
jasper-runtime.jar | Jetty 6.0.1 (5.5.15) jasper-runtime.jar | Jetty 6.1.0 (5.5.15)
jaxen.jar | 1.1 beta 4 (from DOM4J 1.6.1) jaxen.jar | 1.1 beta 4 (from DOM4J 1.6.1)
junit.jar | 3.8.1 junit.jar | 3.8.1
jdic.jar | 0.9.1 (for windows only) jdic.jar | 0.9.1 (for windows only)
...@@ -27,7 +27,7 @@ mail.jar | 1.4.0 (JavaMail) ...@@ -27,7 +27,7 @@ mail.jar | 1.4.0 (JavaMail)
mysql.jar | 3.1.13 mysql.jar | 3.1.13
pack200task.jar | August 5, 2004 pack200task.jar | August 5, 2004
postgres.jar | 8.1-404 JDBC 3 postgres.jar | 8.1-404 JDBC 3
servlet.jar | Jetty 6.0.1 (2.5) servlet.jar | Jetty 6.1.0 (2.5)
shaj.jar | 0.5 shaj.jar | 0.5
sitemesh.jar | 2.2.1 sitemesh.jar | 2.2.1
standard.jar | Jakarta standard taglib 1.1.2 standard.jar | Jakarta standard taglib 1.1.2
......
/**
* $RCSfile$
* $Revision: $
* $Date: $
*
* Copyright (C) 2006-2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire;
import org.jivesoftware.util.*;
import org.jivesoftware.wildfire.net.SSLConfig;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.servlet.Context;
import javax.net.ssl.SSLServerSocketFactory;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.List;
/**
* Manages the instances of Jetty which provides the admin console funtionality.
*
* @author Alexander Wenckus
*/
public class HttpServerManager {
private static final HttpServerManager instance = new HttpServerManager();
public static final String ADMIN_CONSOLE_PORT = "adminConsole.port";
public static final int ADMIN_CONSOLE_PORT_DEFAULT = 9090;
public static final String ADMIN_CONOSLE_SECURE_PORT = "adminConsole.securePort";
public static final int ADMIN_CONSOLE_SECURE_PORT_DEFAULT = 9091;
/**
* Returns an HTTP server manager instance (singleton).
*
* @return an HTTP server manager instance.
*/
public static HttpServerManager getInstance() {
return instance;
}
private int adminPort;
private int adminSecurePort;
private Server adminServer;
private Context adminConsoleContext;
private CertificateEventListener certificateListener;
private boolean restartNeeded = false;
/**
* Constructs a new HTTP server manager.
*/
private HttpServerManager() {
// Configure Jetty logging to a more reasonable default.
System.setProperty("org.mortbay.log.class", "org.jivesoftware.util.log.util.JettyLog");
// JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory",
"org.jivesoftware.util.log.util.CommonsLogFactory");
}
/**
* Sets the Jetty context which provides the functionality for the admin console.
*
* @param context the web-app context which provides functionality for the admin console.
*/
public void setAdminConsoleContext(Context context) {
this.adminConsoleContext = context;
}
/**
* Starts the Jetty instance.
*/
public void startup() {
restartNeeded = false;
// Add listener for certificate events
certificateListener = new CertificateListener();
CertificateManager.addListener(certificateListener);
if (adminConsoleContext != null) {
createAdminConsoleServer();
}
if (adminServer != null) {
adminServer.addHandler(adminConsoleContext);
}
if (adminServer != null) {
try {
adminServer.start();
}
catch (Exception e) {
Log.error("Could not start admin conosle server", e);
}
}
}
/**
* Shuts down the Jetty server.
* */
public void shutdown() {
// Remove listener for certificate events
if (certificateListener != null) {
CertificateManager.removeListener(certificateListener);
}
//noinspection ConstantConditions
try {
if (adminServer != null && adminServer.isRunning()) {
adminServer.stop();
}
if (adminConsoleContext != null && adminConsoleContext.isRunning()) {
adminConsoleContext.stop();
}
}
catch (Exception e) {
Log.error("Error stopping admin console server", e);
}
adminServer = null;
}
/**
* Returns true if the Jetty server needs to be restarted. This is usually required when
* certificates are added, deleted or modified or when server ports were modified.
*
* @return true if the Jetty server needs to be restarted.
*/
public boolean isRestartNeeded() {
return restartNeeded;
}
/**
* Returns the non-SSL port on which the admin console is currently operating.
*
* @return the non-SSL port on which the admin console is currently operating.
*/
public int getAdminUnsecurePort() {
return JiveGlobals.getXMLProperty(ADMIN_CONSOLE_PORT, ADMIN_CONSOLE_PORT_DEFAULT);
}
/**
* Returns the SSL port on which the admin console is current operating.
*
* @return the SSL port on which the admin console is current operating.
*/
public int getAdminSecurePort() {
return JiveGlobals.getXMLProperty(ADMIN_CONOSLE_SECURE_PORT,
ADMIN_CONSOLE_SECURE_PORT_DEFAULT);
}
private void createAdminConsoleServer() {
adminPort = JiveGlobals.getXMLProperty(ADMIN_CONSOLE_PORT, ADMIN_CONSOLE_PORT_DEFAULT);
adminSecurePort = JiveGlobals.getXMLProperty(ADMIN_CONOSLE_SECURE_PORT,
ADMIN_CONSOLE_SECURE_PORT_DEFAULT);
adminServer = new Server();
Connector httpConnector = createConnector(adminPort);
Connector httpsConnector = createSSLConnector(adminSecurePort);
if (httpConnector == null && httpsConnector == null) {
adminServer = null;
// Log warning.
log(LocaleUtils.getLocalizedString("admin.console.warning"));
return;
}
if (httpConnector != null) {
adminServer.addConnector(httpConnector);
}
if (httpsConnector != null) {
adminServer.addConnector(httpsConnector);
}
logAdminConsolePorts();
}
private void log(String string) {
Log.info(string);
System.out.println(string);
}
private void logAdminConsolePorts() {
// Log what ports the admin console is running on.
String listening = LocaleUtils.getLocalizedString("admin.console.listening");
boolean isPlainStarted = false;
boolean isSecureStarted = false;
for (Connector connector : adminServer.getConnectors()) {
if (connector.getPort() == adminPort) {
isPlainStarted = true;
}
else if (connector.getPort() == adminSecurePort) {
isSecureStarted = true;
}
}
if (isPlainStarted && isSecureStarted) {
log(listening + ":" + System.getProperty("line.separator") +
" http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
adminPort + System.getProperty("line.separator") +
" https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
adminSecurePort);
}
else if (isSecureStarted) {
log(listening + " https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + adminSecurePort);
}
else if (isPlainStarted) {
log(listening + " http://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + adminPort);
}
}
private Connector createConnector(int port) {
if (port > 0) {
SelectChannelConnector connector = new SelectChannelConnector();
// Listen on a specific network interface if it has been set.
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
String bindInterface = null;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = interfaceName;
}
}
connector.setHost(bindInterface);
connector.setPort(port);
return connector;
}
return null;
}
private Connector createSSLConnector(int securePort) {
try {
if (securePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(),
XMPPServer.getInstance().getServerInfo().getName())) {
SslSocketConnector sslConnector = new JiveSslConnector();
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
String bindInterface = null;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = interfaceName;
}
}
sslConnector.setHost(bindInterface);
sslConnector.setPort(securePort);
sslConnector.setTrustPassword(SSLConfig.getTrustPassword());
sslConnector.setTruststoreType(SSLConfig.getStoreType());
sslConnector.setTruststore(SSLConfig.getTruststoreLocation());
sslConnector.setNeedClientAuth(false);
sslConnector.setWantClientAuth(false);
sslConnector.setKeyPassword(SSLConfig.getKeyPassword());
sslConnector.setKeystoreType(SSLConfig.getStoreType());
sslConnector.setKeystore(SSLConfig.getKeystoreLocation());
return sslConnector;
}
}
catch (Exception e) {
Log.error(e);
}
return null;
}
private class CertificateListener implements CertificateEventListener {
public void certificateCreated(KeyStore keyStore, String alias, X509Certificate cert) {
// If new certificate is RSA then (re)start the HTTPS service
if ("RSA".equals(cert.getPublicKey().getAlgorithm())) {
restartNeeded = true;
}
}
public void certificateDeleted(KeyStore keyStore, String alias) {
restartNeeded = true;
}
public void certificateSigned(KeyStore keyStore, String alias,
List<X509Certificate> certificates) {
// If new certificate is RSA then (re)start the HTTPS service
if ("RSA".equals(certificates.get(0).getPublicKey().getAlgorithm())) {
restartNeeded = true;
}
}
/*private void stopSSLService() throws Exception {
if (adminServer != null && adminSSLConnector != null) {
adminSSLConnector.stop();
adminServer.removeConnector(adminSSLConnector);
adminSSLConnector = null;
}
// HTTP binding SSL service
if (httpBindServer != null && httpBindServer != adminServer &&
bindSSLConnector != null) {
bindSSLConnector.stop();
httpBindServer.removeConnector(bindSSLConnector);
bindSSLConnector = null;
}
}
private void startSSLService() throws Exception {
if (adminServer != null && adminSecurePort > 0) {
adminSSLConnector = createSSLConnector(adminSecurePort);
adminServer.addConnector(adminSSLConnector);
adminServer.setHandlers(adminServer.getHandlers());
adminSSLConnector.start();
/*adminServer.stop();
adminServer.start();
}
// HTTP binding SSL service
if (httpBindServer != null && httpBindServer != adminServer && bindSecurePort > 0) {
bindSSLConnector = createSSLConnector(bindSecurePort);
httpBindServer.addConnector(bindSSLConnector);
adminServer.setHandlers(adminServer.getHandlers());
bindSSLConnector.start();
/*httpBindServer.stop();
httpBindServer.start(); }
}*/
}
private class JiveSslConnector extends SslSocketConnector {
@Override
protected SSLServerSocketFactory createFactory() throws Exception {
return SSLConfig.getServerSocketFactory();
}
}
}
\ No newline at end of file
...@@ -19,10 +19,7 @@ import org.jivesoftware.wildfire.audit.AuditManager; ...@@ -19,10 +19,7 @@ import org.jivesoftware.wildfire.audit.AuditManager;
import org.jivesoftware.wildfire.audit.spi.AuditManagerImpl; import org.jivesoftware.wildfire.audit.spi.AuditManagerImpl;
import org.jivesoftware.wildfire.commands.AdHocCommandHandler; import org.jivesoftware.wildfire.commands.AdHocCommandHandler;
import org.jivesoftware.wildfire.component.InternalComponentManager; import org.jivesoftware.wildfire.component.InternalComponentManager;
import org.jivesoftware.wildfire.container.Module; import org.jivesoftware.wildfire.container.*;
import org.jivesoftware.wildfire.container.Plugin;
import org.jivesoftware.wildfire.container.PluginListener;
import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.disco.IQDiscoInfoHandler; import org.jivesoftware.wildfire.disco.IQDiscoInfoHandler;
import org.jivesoftware.wildfire.disco.IQDiscoItemsHandler; import org.jivesoftware.wildfire.disco.IQDiscoItemsHandler;
import org.jivesoftware.wildfire.disco.ServerFeaturesProvider; import org.jivesoftware.wildfire.disco.ServerFeaturesProvider;
...@@ -127,7 +124,6 @@ public class XMPPServer { ...@@ -127,7 +124,6 @@ public class XMPPServer {
"org.jivesoftware.wildfire.starter.ServerStarter"; "org.jivesoftware.wildfire.starter.ServerStarter";
private static final String WRAPPER_CLASSNAME = private static final String WRAPPER_CLASSNAME =
"org.tanukisoftware.wrapper.WrapperManager"; "org.tanukisoftware.wrapper.WrapperManager";
private HttpServerManager httpServerManager;
/** /**
* Returns a singleton instance of XMPPServer. * Returns a singleton instance of XMPPServer.
...@@ -297,7 +293,6 @@ public class XMPPServer { ...@@ -297,7 +293,6 @@ public class XMPPServer {
} }
loader = Thread.currentThread().getContextClassLoader(); loader = Thread.currentThread().getContextClassLoader();
httpServerManager = HttpServerManager.getInstance();
initialized = true; initialized = true;
} }
...@@ -352,9 +347,8 @@ public class XMPPServer { ...@@ -352,9 +347,8 @@ public class XMPPServer {
// Otherwise, the page that requested the setup finish won't // Otherwise, the page that requested the setup finish won't
// render properly! // render properly!
Thread.sleep(1000); Thread.sleep(1000);
httpServerManager.shutdown(); ((AdminConsolePlugin) pluginManager.getPlugin("admin")).shutdown();
httpServerManager.startup(); ((AdminConsolePlugin) pluginManager.getPlugin("admin")).startup();
} }
verifyDataSource(); verifyDataSource();
...@@ -408,19 +402,6 @@ public class XMPPServer { ...@@ -408,19 +402,6 @@ public class XMPPServer {
ServerTrafficCounter.initStatistics(); ServerTrafficCounter.initStatistics();
// Load plugins (when in setup mode only the admin console will be loaded) // Load plugins (when in setup mode only the admin console will be loaded)
pluginManager.addPluginListener(new PluginListener() {
public void pluginCreated(String pluginName, Plugin plugin) {
if("admin".equals(pluginName)) {
httpServerManager.startup();
}
}
public void pluginDestroyed(String pluginName, Plugin plugin) {
if ("admin".equals(pluginName)) {
httpServerManager.shutdown();
}
}
});
pluginManager.start(); pluginManager.start();
// Log that the server has been started // Log that the server has been started
...@@ -591,8 +572,8 @@ public class XMPPServer { ...@@ -591,8 +572,8 @@ public class XMPPServer {
// Otherwise, this page won't render properly! // Otherwise, this page won't render properly!
try { try {
Thread.sleep(1000); Thread.sleep(1000);
httpServerManager.shutdown(); ((AdminConsolePlugin) pluginManager.getPlugin("admin")).shutdown();
httpServerManager.startup(); ((AdminConsolePlugin) pluginManager.getPlugin("admin")).startup();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -10,11 +10,23 @@ ...@@ -10,11 +10,23 @@
package org.jivesoftware.wildfire.container; package org.jivesoftware.wildfire.container;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.*;
import org.jivesoftware.util.Log; import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.HttpServerManager; import org.jivesoftware.wildfire.net.SSLConfig;
import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.handler.HandlerCollection;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import javax.net.ssl.SSLServerSocketFactory;
import java.io.File; import java.io.File;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.List;
/** /**
* The admin console plugin. It starts a Jetty instance on the configured * The admin console plugin. It starts a Jetty instance on the configured
...@@ -24,45 +36,266 @@ import java.io.File; ...@@ -24,45 +36,266 @@ import java.io.File;
*/ */
public class AdminConsolePlugin implements Plugin { public class AdminConsolePlugin implements Plugin {
private int adminPort;
private int adminSecurePort;
private Server adminServer;
private ContextHandlerCollection contexts;
private CertificateEventListener certificateListener;
private boolean restartNeeded = false;
private File pluginDir; private File pluginDir;
private HttpServerManager serverManager;
/** /**
* Create a jetty module. * Create a Jetty module.
*/ */
public AdminConsolePlugin() { public AdminConsolePlugin() {
serverManager = HttpServerManager.getInstance(); // Configure Jetty logging to a more reasonable default.
System.setProperty("org.mortbay.log.class", "org.jivesoftware.util.log.util.JettyLog");
// JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
}
/**
* Starts the Jetty instance.
*/
public void startup() {
restartNeeded = false;
// Add listener for certificate events
certificateListener = new CertificateListener();
CertificateManager.addListener(certificateListener);
adminPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
adminSecurePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
adminServer = new Server();
// Create connector for http traffic if it's enabled.
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
// Listen on a specific network interface if it has been set.
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
String bindInterface = null;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = interfaceName;
}
}
httpConnector.setHost(bindInterface);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
// Create a connector for https traffic if it's enabled.
try {
if (adminSecurePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(),
XMPPServer.getInstance().getServerInfo().getName()))
{
JiveSslConnector httpsConnector = new JiveSslConnector();
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
String bindInterface = null;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = interfaceName;
}
}
httpsConnector.setHost(bindInterface);
httpsConnector.setPort(adminSecurePort);
httpsConnector.setTrustPassword(SSLConfig.getTrustPassword());
httpsConnector.setTruststoreType(SSLConfig.getStoreType());
httpsConnector.setTruststore(SSLConfig.getTruststoreLocation());
httpsConnector.setNeedClientAuth(false);
httpsConnector.setWantClientAuth(false);
httpsConnector.setKeyPassword(SSLConfig.getKeyPassword());
httpsConnector.setKeystoreType(SSLConfig.getStoreType());
httpsConnector.setKeystore(SSLConfig.getKeystoreLocation());
adminServer.addConnector(httpsConnector);
}
}
catch (Exception e) {
Log.error(e);
}
// Make sure that at least one connector was registered.
if (adminServer.getConnectors() == null || adminServer.getConnectors().length == 0) {
adminServer = null;
// Log warning.
log(LocaleUtils.getLocalizedString("admin.console.warning"));
return;
}
adminServer.setHandler(contexts);
try {
adminServer.start();
}
catch (Exception e) {
Log.error("Could not start admin conosle server", e);
}
// Log the ports that the admin server is listening on.
logAdminConsolePorts();
}
/**
* Shuts down the Jetty server.
* */
public void shutdown() {
// Remove listener for certificate events
if (certificateListener != null) {
CertificateManager.removeListener(certificateListener);
}
//noinspection ConstantConditions
try {
if (adminServer != null && adminServer.isRunning()) {
adminServer.stop();
}
}
catch (Exception e) {
Log.error("Error stopping admin console server", e);
}
adminServer = null;
} }
public void initializePlugin(PluginManager manager, File pluginDir) { public void initializePlugin(PluginManager manager, File pluginDir) {
this.pluginDir = pluginDir; this.pluginDir = pluginDir;
contexts = new ContextHandlerCollection();
createWebAppContext(contexts);
startup();
}
public void destroyPlugin() {
shutdown();
}
/**
* Returns true if the Jetty server needs to be restarted. This is usually required when
* certificates are added, deleted or modified or when server ports were modified.
*
* @return true if the Jetty server needs to be restarted.
*/
public boolean isRestartNeeded() {
return restartNeeded;
}
/**
* Returns the non-SSL port on which the admin console is currently operating.
*
* @return the non-SSL port on which the admin console is currently operating.
*/
public int getAdminUnsecurePort() {
return adminPort;
}
/**
* Returns the SSL port on which the admin console is current operating.
*
* @return the SSL port on which the admin console is current operating.
*/
public int getAdminSecurePort() {
return adminSecurePort;
}
public ContextHandlerCollection getContexts() {
return contexts;
}
public void restart() {
try { try {
serverManager.setAdminConsoleContext(createWebAppContext()); adminServer.stop();
adminServer.start();
} }
catch (Exception e) { catch (Exception e) {
System.err.println("Error starting admin console: " + e.getMessage()); Log.error(e);
Log.error("Trouble initializing admin console", e);
} }
} }
private WebAppContext createWebAppContext() { private void createWebAppContext(ContextHandlerCollection contexts) {
WebAppContext context; WebAppContext context;
// Add web-app. Check to see if we're in development mode. If so, we don't // Add web-app. Check to see if we're in development mode. If so, we don't
// add the normal web-app location, but the web-app in the project directory. // add the normal web-app location, but the web-app in the project directory.
if (Boolean.getBoolean("developmentMode")) { if (Boolean.getBoolean("developmentMode")) {
System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode")); System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode"));
context = new WebAppContext( context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() +
pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + File.separator + "src" + File.separator + "web", "/");
"src" + File.separator + "web", "/");
} }
else { else {
context = new WebAppContext(pluginDir.getAbsoluteFile() + File.separator + "webapp", context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp",
"/"); "/");
} }
context.setWelcomeFiles(new String[]{"index.jsp"}); context.setWelcomeFiles(new String[]{"index.jsp"});
return context;
} }
public void destroyPlugin() { private void log(String string) {
Log.info(string);
System.out.println(string);
}
private void logAdminConsolePorts() {
// Log what ports the admin console is running on.
String listening = LocaleUtils.getLocalizedString("admin.console.listening");
boolean isPlainStarted = false;
boolean isSecureStarted = false;
for (Connector connector : adminServer.getConnectors()) {
if (connector.getPort() == adminPort) {
isPlainStarted = true;
}
else if (connector.getPort() == adminSecurePort) {
isSecureStarted = true;
}
}
if (isPlainStarted && isSecureStarted) {
log(listening + ":" + System.getProperty("line.separator") +
" http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
adminPort + System.getProperty("line.separator") +
" https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
adminSecurePort);
}
else if (isSecureStarted) {
log(listening + " https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + adminSecurePort);
}
else if (isPlainStarted) {
log(listening + " http://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + adminPort);
}
}
/**
* Listens for security certificates being created and destroyed so we can track when the
* admin console needs to be restarted.
*/
private class CertificateListener implements CertificateEventListener {
public void certificateCreated(KeyStore keyStore, String alias, X509Certificate cert) {
// If new certificate is RSA then (re)start the HTTPS service
if ("RSA".equals(cert.getPublicKey().getAlgorithm())) {
restartNeeded = true;
}
}
public void certificateDeleted(KeyStore keyStore, String alias) {
restartNeeded = true;
}
public void certificateSigned(KeyStore keyStore, String alias,
List<X509Certificate> certificates) {
// If new certificate is RSA then (re)start the HTTPS service
if ("RSA".equals(certificates.get(0).getPublicKey().getAlgorithm())) {
restartNeeded = true;
}
}
}
private class JiveSslConnector extends SslSocketConnector {
@Override
protected SSLServerSocketFactory createFactory() throws Exception {
return SSLConfig.getServerSocketFactory();
}
} }
} }
\ No newline at end of file
...@@ -63,6 +63,11 @@ public final class HttpBindManager { ...@@ -63,6 +63,11 @@ public final class HttpBindManager {
} }
private HttpBindManager() { private HttpBindManager() {
// Configure Jetty logging to a more reasonable default.
System.setProperty("org.mortbay.log.class", "org.jivesoftware.util.log.util.JettyLog");
// JSP 2.0 uses commons-logging, so also override that implementation.
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
PropertyEventDispatcher.addListener(new HttpServerPropertyListener()); PropertyEventDispatcher.addListener(new HttpServerPropertyListener());
this.httpSessionManager = new HttpSessionManager(); this.httpSessionManager = new HttpSessionManager();
} }
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
<%@ page import="java.util.Enumeration" %> <%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %> <%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.wildfire.HttpServerManager" %> <%@ page import="org.jivesoftware.wildfire.container.PluginManager" %>
<%@ page import="org.jivesoftware.wildfire.container.AdminConsolePlugin" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -84,6 +85,8 @@ ...@@ -84,6 +85,8 @@
} }
} }
} }
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
%> %>
<html> <html>
...@@ -93,7 +96,7 @@ ...@@ -93,7 +96,7 @@
</head> </head>
<body> <body>
<% if (HttpServerManager.getInstance().isRestartNeeded()) { %> <% if (((AdminConsolePlugin) pluginManager.getPlugin("admin")).isRestartNeeded()) { %>
<div class="warning"> <div class="warning">
<table cellpadding="0" cellspacing="0" border="0"> <table cellpadding="0" cellspacing="0" border="0">
<tbody> <tbody>
......
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