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

Allow admin console ports to be disabled (JM-209).


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1123 b35dd754-fafc-0310-a699-88a17e54d16e
parent 0cad5b7f
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<!-- root element, all properties must be under this element --> <!-- root element, all properties must be under this element -->
<jive> <jive>
<adminConsole> <adminConsole>
<!-- Disable either port by setting the value to -1 -->
<port>9090</port> <port>9090</port>
<securePort>9091</securePort> <securePort>9091</securePort>
<!-- By default, only the user with the username "admin" can login <!-- By default, only the user with the username "admin" can login
......
...@@ -329,7 +329,7 @@ public class JiveGlobals { ...@@ -329,7 +329,7 @@ public class JiveGlobals {
* @return the property value specified by name or <tt>defaultValue</tt>. * @return the property value specified by name or <tt>defaultValue</tt>.
*/ */
public static int getXMLProperty(String name, int defaultValue) { public static int getXMLProperty(String name, int defaultValue) {
String value = getProperty(name); String value = getXMLProperty(name);
if (value != null) { if (value != null) {
try { try {
return Integer.parseInt(value); return Integer.parseInt(value);
......
...@@ -77,38 +77,46 @@ public class AdminConsolePlugin implements Plugin { ...@@ -77,38 +77,46 @@ public class AdminConsolePlugin implements Plugin {
jetty = new Server(); jetty = new Server();
// Configure HTTP socket listener // Configure HTTP socket listener
boolean plainStarted = false;
port = JiveGlobals.getXMLProperty("adminConsole.port", 9090); port = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
jetty.addListener(Integer.toString(port)); if (port > 0) {
jetty.addListener(Integer.toString(port));
plainStarted = true;
}
boolean secureStarted = false; boolean secureStarted = false;
try { try {
SunJsseListener listener = new SunJsseListener();
// Get the keystore location. The default location is security/keystore
String keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore",
"resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation;
// Get the keystore password. The default password is "changeit".
String keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
keypass = keypass.trim();
// Get the truststore location; default at security/truststore
String trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore",
"resources" + File.separator + "security" + File.separator + "truststore");
trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator + trustStoreLocation;
// Get the truststore passwprd; default is "changeit".
String trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit");
trustpass = trustpass.trim();
listener.setKeystore(keyStoreLocation);
listener.setKeyPassword(keypass);
listener.setPassword(keypass);
securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091); securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
listener.setPort(securePort); if (securePort > 0) {
SunJsseListener listener = new SunJsseListener();
jetty.addListener(listener); // Get the keystore location. The default location is security/keystore
secureStarted = true; String keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore",
"resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation;
// Get the keystore password. The default password is "changeit".
String keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
keypass = keypass.trim();
// Get the truststore location; default at security/truststore
String trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore",
"resources" + File.separator + "security" + File.separator + "truststore");
trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator +
trustStoreLocation;
// Get the truststore passwprd; default is "changeit".
String trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit");
trustpass = trustpass.trim();
listener.setKeystore(keyStoreLocation);
listener.setKeyPassword(keypass);
listener.setPassword(keypass);
listener.setPort(securePort);
jetty.addListener(listener);
secureStarted = true;
}
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
...@@ -121,18 +129,30 @@ public class AdminConsolePlugin implements Plugin { ...@@ -121,18 +129,30 @@ public class AdminConsolePlugin implements Plugin {
jetty.start(); jetty.start();
Log.info("Started admin console on port: " + port); if (!plainStarted && !secureStarted) {
if (!secureStarted) { Log.info("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) {
Log.info("Admin console listening at https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
System.out.println("Admin console listening at https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
}
else if (!secureStarted && plainStarted) {
Log.info("Admin console listening at http://" +
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 {
Log.info("Started secure admin console on port: " + securePort); String msg = "Admin console listening at:\n" +
System.out.println("Admin console listening at:"); " http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
System.out.println(" http://" + port + "\n" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + port); " https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
System.out.println(" https://" + securePort;
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort); Log.info(msg);
System.out.println(msg);
} }
} }
catch (Exception e) { catch (Exception e) {
......
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