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

Fixed newlines.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1172 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4c4dfdf5
...@@ -18,357 +18,182 @@ ...@@ -18,357 +18,182 @@
*/ */
package org.jivesoftware.messenger.container; package org.jivesoftware.messenger.container;
import org.jivesoftware.messenger.JiveGlobals; import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.XMPPServer; import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.mortbay.http.SunJsseListener; import org.mortbay.http.SunJsseListener;
import org.mortbay.jetty.Server; import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.WebApplicationContext; import org.mortbay.jetty.servlet.WebApplicationContext;
import org.mortbay.log.Factory; import org.mortbay.log.Factory;
import org.mortbay.log.LogImpl; import org.mortbay.log.LogImpl;
import org.mortbay.log.OutputStreamLogSink; import org.mortbay.log.OutputStreamLogSink;
import org.mortbay.util.InetAddrPort; import org.mortbay.util.InetAddrPort;
import java.io.File; import java.io.File;
/** /**
* The admin console plugin. It starts a Jetty instance on the configured * The admin console plugin. It starts a Jetty instance on the configured
* port and loads the admin console web application. * port and loads the admin console web application.
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class AdminConsolePlugin implements Plugin { public class AdminConsolePlugin implements Plugin {
private static Server jetty = null; private static Server jetty = null;
private String interfaceName; private String interfaceName;
private int port; private int port;
private int securePort; private int securePort;
/** /**
* Create a jetty module. * Create a jetty module.
*/ */
public AdminConsolePlugin() { public AdminConsolePlugin() {
} }
public String getName() { public String getName() {
return "Admin Console"; return "Admin Console";
} }
public String getDescription() { public String getDescription() {
return "Web-based admin console for Jive Messenger."; return "Web-based admin console for Jive Messenger.";
} }
public String getAuthor() { public String getAuthor() {
return "Jive Software"; return "Jive Software";
} }
public String getVersion() { public String getVersion() {
return "2.0"; return "2.0";
} }
public void initializePlugin(PluginManager manager, File pluginDir) { public void initializePlugin(PluginManager manager, File pluginDir) {
try { try {
// Configure logging to a file, creating log dir if needed // Configure logging to a file, creating log dir if needed
System.setProperty("org.apache.commons.logging.LogFactory", "org.mortbay.log.Factory"); System.setProperty("org.apache.commons.logging.LogFactory", "org.mortbay.log.Factory");
File logDir = new File(JiveGlobals.getMessengerHome(), "logs"); File logDir = new File(JiveGlobals.getMessengerHome(), "logs");
if (!logDir.exists()) { if (!logDir.exists()) {
logDir.mkdirs(); logDir.mkdirs();
} }
File logFile = new File(logDir, "admin-console.log"); File logFile = new File(logDir, "admin-console.log");
OutputStreamLogSink logSink = new OutputStreamLogSink(logFile.toString()); OutputStreamLogSink logSink = new OutputStreamLogSink(logFile.toString());
logSink.start(); logSink.start();
LogImpl log = (LogImpl) Factory.getFactory().getInstance(""); LogImpl log = (LogImpl) Factory.getFactory().getInstance("");
// Ignore INFO logs. // Ignore INFO logs.
log.setVerbose(-1); log.setVerbose(-1);
log.add(logSink); log.add(logSink);
jetty = new Server(); jetty = new Server();
// Configure HTTP socket listener // Configure HTTP socket listener
boolean plainStarted = false; boolean plainStarted = false;
// Setting this property to a not null value will imply that the Jetty server will only // Setting this property to a not null value will imply that the Jetty server will only
// accept connect requests to that IP address // accept connect requests to that IP address
interfaceName = JiveGlobals.getXMLProperty("adminConsole.inteface"); interfaceName = JiveGlobals.getXMLProperty("adminConsole.inteface");
port = JiveGlobals.getXMLProperty("adminConsole.port", 9090); port = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
InetAddrPort address = new InetAddrPort(interfaceName, port); InetAddrPort address = new InetAddrPort(interfaceName, port);
if (port > 0) { if (port > 0) {
jetty.addListener(address); jetty.addListener(address);
plainStarted = true; plainStarted = true;
} }
boolean secureStarted = false; boolean secureStarted = false;
try { try {
securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091); securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
if (securePort > 0) { if (securePort > 0) {
SunJsseListener listener = new SunJsseListener(); SunJsseListener listener = new SunJsseListener();
// Get the keystore location. The default location is security/keystore // Get the keystore location. The default location is security/keystore
String keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore", String keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore",
"resources" + File.separator + "security" + File.separator + "keystore"); "resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation; keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation;
// Get the keystore password. The default password is "changeit". // Get the keystore password. The default password is "changeit".
String keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit"); String keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
keypass = keypass.trim(); keypass = keypass.trim();
// Get the truststore location; default at security/truststore // Get the truststore location; default at security/truststore
String trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore", String trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore",
"resources" + File.separator + "security" + File.separator + "truststore"); "resources" + File.separator + "security" + File.separator + "truststore");
trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator + trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator +
trustStoreLocation; trustStoreLocation;
// Get the truststore passwprd; default is "changeit". // Get the truststore passwprd; default is "changeit".
String trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit"); String trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit");
trustpass = trustpass.trim(); trustpass = trustpass.trim();
listener.setKeystore(keyStoreLocation); listener.setKeystore(keyStoreLocation);
listener.setKeyPassword(keypass); listener.setKeyPassword(keypass);
listener.setPassword(keypass); listener.setPassword(keypass);
listener.setHost(interfaceName); listener.setHost(interfaceName);
listener.setPort(securePort); listener.setPort(securePort);
jetty.addListener(listener); jetty.addListener(listener);
secureStarted = true; secureStarted = true;
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
} }
// Add web-app // Add web-app
WebApplicationContext webAppContext = jetty.addWebApplication("/", WebApplicationContext webAppContext = jetty.addWebApplication("/",
pluginDir.getAbsoluteFile() + File.separator + "webapp"); pluginDir.getAbsoluteFile() + File.separator + "webapp");
webAppContext.setWelcomeFiles(new String[]{"index.jsp"}); webAppContext.setWelcomeFiles(new String[]{"index.jsp"});
jetty.start(); jetty.start();
if (!plainStarted && !secureStarted) { if (!plainStarted && !secureStarted) {
Log.info("Warning: admin console not started due to configuration settings."); Log.info("Warning: admin console not started due to configuration settings.");
System.out.println("Warning: admin console not started due to configuration settings."); System.out.println("Warning: admin console not started due to configuration settings.");
} }
else if (!plainStarted && secureStarted) { else if (!plainStarted && secureStarted) {
Log.info("Admin console listening at https://" + Log.info("Admin console listening at https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort); XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
System.out.println("Admin console listening at https://" + System.out.println("Admin console listening at https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort); XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
} }
else if (!secureStarted && plainStarted) { else if (!secureStarted && plainStarted) {
Log.info("Admin console listening at http://" + Log.info("Admin console listening at http://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + port); XMPPServer.getInstance().getServerInfo().getName() + ":" + port);
System.out.println("Admin console listening at http://" + System.out.println("Admin console listening at http://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + port); XMPPServer.getInstance().getServerInfo().getName() + ":" + port);
} }
else { else {
String msg = "Admin console listening at:\n" + String msg = "Admin console listening at:\n" +
" http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" + " http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
port + "\n" + port + "\n" +
" https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" + " https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
securePort; securePort;
Log.info(msg); Log.info(msg);
System.out.println(msg); System.out.println(msg);
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error("Trouble initializing admin console", e); Log.error("Trouble initializing admin console", e);
} }
} }
public void destroyPlugin() { public void destroyPlugin() {
try { try {
if (jetty != null) { if (jetty != null) {
jetty.stop(); jetty.stop();
jetty = null; jetty = null;
} }
} }
catch (InterruptedException e) { catch (InterruptedException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
/** /**
* Returns the Jetty instance started by this plugin. * Returns the Jetty instance started by this plugin.
* *
* @return the Jetty server instance. * @return the Jetty server instance.
*/ */
public static Server getJettyServer() { public static Server getJettyServer() {
return jetty; return jetty;
} }
} }
\ No newline at end of file
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