Commit 67730f24 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Enabling or modifying listeners ports does not require a server restart. JM-320


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1583 b35dd754-fafc-0310-a699-88a17e54d16e
parent 657a0189
...@@ -40,4 +40,134 @@ public interface ConnectionManager { ...@@ -40,4 +40,134 @@ public interface ConnectionManager {
*/ */
public void addSocket(Socket socket, boolean isSecure, ServerPort serverPort) public void addSocket(Socket socket, boolean isSecure, ServerPort serverPort)
throws XmlPullParserException; throws XmlPullParserException;
/**
* Sets if the port listener for unsecured clients will be available or not. When disabled
* there won't be a port listener active. Therefore, new clients won't be able to connect to
* the server.
*
* @param enabled true if new unsecured clients will be able to connect to the server.
*/
public void enableClientListener(boolean enabled);
/**
* Returns true if the port listener for unsecured clients is available. When disabled
* there won't be a port listener active. Therefore, new clients won't be able to connect to
* the server.
*
* @return true if the port listener for unsecured clients is available.
*/
public boolean isClientListenerEnabled();
/**
* Sets if the port listener for secured clients will be available or not. When disabled
* there won't be a port listener active. Therefore, new secured clients won't be able to
* connect to the server.
*
* @param enabled true if new secured clients will be able to connect to the server.
*/
public void enableClientSSLListener(boolean enabled);
/**
* Returns true if the port listener for secured clients is available. When disabled
* there won't be a port listener active. Therefore, new secured clients won't be able to
* connect to the server.
*
* @return true if the port listener for unsecured clients is available.
*/
public boolean isClientSSLListenerEnabled();
/**
* Sets if the port listener for external components will be available or not. When disabled
* there won't be a port listener active. Therefore, new external components won't be able to
* connect to the server.
*
* @param enabled true if new external components will be able to connect to the server.
*/
public void enableComponentListener(boolean enabled);
/**
* Returns true if the port listener for external components is available. When disabled
* there won't be a port listener active. Therefore, new external components won't be able to
* connect to the server.
*
* @return true if the port listener for external components is available.
*/
public boolean isComponentListenerEnabled();
/**
* Sets if the port listener for remote servers will be available or not. When disabled
* there won't be a port listener active. Therefore, new remote servers won't be able to
* connect to the server.
*
* @param enabled true if new remote servers will be able to connect to the server.
*/
public void enableServerListener(boolean enabled);
/**
* Returns true if the port listener for remote servers is available. When disabled
* there won't be a port listener active. Therefore, new remote servers won't be able to
* connect to the server.
*
* @return true if the port listener for remote servers is available.
*/
public boolean isServerListenerEnabled();
/**
* Sets the port to use for unsecured clients. Default port: 5222.
*
* @param port the port to use for unsecured clients.
*/
public void setClientListenerPort(int port);
/**
* Returns the port to use for unsecured clients. Default port: 5222.
*
* @return the port to use for unsecured clients.
*/
public int getClientListenerPort();
/**
* Sets the port to use for secured clients. Default port: 5223.
*
* @param port the port to use for secured clients.
*/
public void setClientSSLListenerPort(int port);
/**
* Returns the port to use for secured clients. Default port: 5223.
*
* @return the port to use for secured clients.
*/
public int getClientSSLListenerPort();
/**
* Sets the port to use for external components.
*
* @param port the port to use for external components.
*/
public void setComponentListenerPort(int port);
/**
* Returns the port to use for external components.
*
* @return the port to use for external components.
*/
public int getComponentListenerPort();
/**
* Sets the port to use for remote servers. This port is used for remote servers to connect
* to this server. Default port: 5269.
*
* @param port the port to use for remote servers.
*/
public void setServerListenerPort(int port);
/**
* Returns the port to use for remote servers. This port is used for remote servers to connect
* to this server. Default port: 5269.
*
* @return the port to use for remote servers.
*/
public int getServerListenerPort();
} }
...@@ -123,17 +123,10 @@ public class XMPPServer { ...@@ -123,17 +123,10 @@ public class XMPPServer {
* @return the server information current at the time of the method call. * @return the server information current at the time of the method call.
*/ */
public XMPPServerInfo getServerInfo() { public XMPPServerInfo getServerInfo() {
Iterator ports;
if (getConnectionManager() == null) {
ports = Collections.EMPTY_LIST.iterator();
}
else {
ports = getConnectionManager().getPorts();
}
if (!initialized) { if (!initialized) {
throw new IllegalStateException("Not initialized yet"); throw new IllegalStateException("Not initialized yet");
} }
return new XMPPServerInfoImpl(name, version, startDate, stopDate, ports); return new XMPPServerInfoImpl(name, version, startDate, stopDate, getConnectionManager());
} }
/** /**
......
...@@ -102,6 +102,15 @@ public class SSLSocketAcceptThread extends Thread { ...@@ -102,6 +102,15 @@ public class SSLSocketAcceptThread extends Thread {
return serverSocket.getLocalPort(); return serverSocket.getLocalPort();
} }
/**
* Returns information about the port on which the server is listening for connections.
*
* @return information about the port on which the server is listening for connections.
*/
public ServerPort getServerPort() {
return serverPort;
}
/** /**
* Unblock the thread and force it to terminate. * Unblock the thread and force it to terminate.
*/ */
......
...@@ -90,6 +90,15 @@ public class SocketAcceptThread extends Thread { ...@@ -90,6 +90,15 @@ public class SocketAcceptThread extends Thread {
return serverPort.getPort(); return serverPort.getPort();
} }
/**
* Returns information about the port on which the server is listening for connections.
*
* @return information about the port on which the server is listening for connections.
*/
public ServerPort getServerPort() {
return serverPort;
}
/** /**
* Unblock the thread and force it to terminate. * Unblock the thread and force it to terminate.
*/ */
......
...@@ -39,6 +39,12 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -39,6 +39,12 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
private PacketRouter router; private PacketRouter router;
private String serverName; private String serverName;
private XMPPServer server; private XMPPServer server;
private String localIPAddress = null;
// Used to know if the sockets can be started (the connection manager has been started)
private boolean isStarted = false;
// Used to know if the sockets have been started
private boolean isSocketStarted = false;
public ConnectionManagerImpl() { public ConnectionManagerImpl() {
super("Connection Manager"); super("Connection Manager");
...@@ -55,7 +61,6 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -55,7 +61,6 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
isSocketStarted = true; isSocketStarted = true;
// Setup port info // Setup port info
String localIPAddress = null;
try { try {
localIPAddress = InetAddress.getLocalHost().getHostAddress(); localIPAddress = InetAddress.getLocalHost().getHostAddress();
} }
...@@ -70,13 +75,14 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -70,13 +75,14 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
startComponentListener(localIPAddress); startComponentListener(localIPAddress);
// Start the port listener for clients // Start the port listener for clients
startClientListeners(localIPAddress); startClientListeners(localIPAddress);
// Start the port listener for secured clients
startClientSSLListeners(localIPAddress);
} }
private void startServerListener(String localIPAddress) { private void startServerListener(String localIPAddress) {
// Start servers socket unless it's been disabled. // Start servers socket unless it's been disabled.
if (JiveGlobals.getBooleanProperty("xmpp.server.socket.active", true)) { if (isServerListenerEnabled()) {
int port = JiveGlobals.getIntProperty("xmpp.server.socket.port", int port = getServerListenerPort();
SocketAcceptThread.DEFAULT_SERVER_PORT);
String interfaceName = JiveGlobals.getProperty("xmpp.server.socket.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.server.socket.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress, ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
false, null, ServerPort.Type.server); false, null, ServerPort.Type.server);
...@@ -98,11 +104,18 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -98,11 +104,18 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
} }
} }
private void stopServerListener() {
if (serverSocketThread != null) {
serverSocketThread.shutdown();
ports.remove(serverSocketThread.getServerPort());
serverSocketThread = null;
}
}
private void startComponentListener(String localIPAddress) { private void startComponentListener(String localIPAddress) {
// Start components socket unless it's been disabled. // Start components socket unless it's been disabled.
if (JiveGlobals.getBooleanProperty("xmpp.component.socket.active", true)) { if (isComponentListenerEnabled()) {
int port = JiveGlobals.getIntProperty("xmpp.component.socket.port", int port = getComponentListenerPort();
SocketAcceptThread.DEFAULT_COMPONENT_PORT);
String interfaceName = JiveGlobals.getProperty("xmpp.component.socket.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.component.socket.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress, ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
false, null, ServerPort.Type.component); false, null, ServerPort.Type.component);
...@@ -124,11 +137,18 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -124,11 +137,18 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
} }
} }
private void stopComponentListener() {
if (componentSocketThread != null) {
componentSocketThread.shutdown();
ports.remove(componentSocketThread.getServerPort());
componentSocketThread = null;
}
}
private void startClientListeners(String localIPAddress) { private void startClientListeners(String localIPAddress) {
// Start clients plain socket unless it's been disabled. // Start clients plain socket unless it's been disabled.
if (JiveGlobals.getBooleanProperty("xmpp.socket.plain.active", true)) { if (isClientListenerEnabled()) {
int port = JiveGlobals.getIntProperty("xmpp.socket.plain.port", int port = getClientListenerPort();
SocketAcceptThread.DEFAULT_PORT);
String interfaceName = JiveGlobals.getProperty("xmpp.socket.plain.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.socket.plain.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress, ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
false, null, ServerPort.Type.client); false, null, ServerPort.Type.client);
...@@ -148,10 +168,20 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -148,10 +168,20 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
Log.error(LocaleUtils.getLocalizedString("admin.error.socket-setup"), e); Log.error(LocaleUtils.getLocalizedString("admin.error.socket-setup"), e);
} }
} }
}
private void stopClientListeners() {
if (socketThread != null) {
socketThread.shutdown();
ports.remove(socketThread.getServerPort());
socketThread = null;
}
}
private void startClientSSLListeners(String localIPAddress) {
// Start clients SSL unless it's been disabled. // Start clients SSL unless it's been disabled.
if (JiveGlobals.getBooleanProperty("xmpp.socket.ssl.active", true)) { if (isClientSSLListenerEnabled()) {
int port = JiveGlobals.getIntProperty("xmpp.socket.ssl.port", int port = getClientSSLListenerPort();
SSLSocketAcceptThread.DEFAULT_PORT);
String interfaceName = JiveGlobals.getProperty("xmpp.socket.ssl.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.socket.ssl.interface");
String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm"); String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm");
if ("".equals(algorithm) || algorithm == null) { if ("".equals(algorithm) || algorithm == null) {
...@@ -177,6 +207,14 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -177,6 +207,14 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
} }
} }
private void stopClientSSLListeners() {
if (sslSocketThread != null) {
sslSocketThread.shutdown();
ports.remove(sslSocketThread.getServerPort());
sslSocketThread = null;
}
}
public Iterator<ServerPort> getPorts() { public Iterator<ServerPort> getPorts() {
return ports.iterator(); return ports.iterator();
} }
...@@ -216,10 +254,165 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -216,10 +254,165 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
sessionManager = server.getSessionManager(); sessionManager = server.getSessionManager();
} }
// Used to know if the sockets can be started (the connection manager has been started) public void enableClientListener(boolean enabled) {
private boolean isStarted = false; if (enabled == isClientListenerEnabled()) {
// Used to know if the sockets have been started // Ignore new setting
private boolean isSocketStarted = false; return;
}
if (enabled) {
JiveGlobals.setProperty("xmpp.socket.plain.active", "true");
// Start the port listener for clients
startClientListeners(localIPAddress);
}
else {
JiveGlobals.setProperty("xmpp.socket.plain.active", "false");
// Stop the port listener for clients
stopClientListeners();
}
}
public boolean isClientListenerEnabled() {
return JiveGlobals.getBooleanProperty("xmpp.socket.plain.active", true);
}
public void enableClientSSLListener(boolean enabled) {
if (enabled == isClientSSLListenerEnabled()) {
// Ignore new setting
return;
}
if (enabled) {
JiveGlobals.setProperty("xmpp.socket.ssl.active", "true");
// Start the port listener for secured clients
startClientSSLListeners(localIPAddress);
}
else {
JiveGlobals.setProperty("xmpp.socket.ssl.active", "false");
// Stop the port listener for secured clients
stopClientSSLListeners();
}
}
public boolean isClientSSLListenerEnabled() {
return JiveGlobals.getBooleanProperty("xmpp.socket.ssl.active", true);
}
public void enableComponentListener(boolean enabled) {
if (enabled == isComponentListenerEnabled()) {
// Ignore new setting
return;
}
if (enabled) {
JiveGlobals.setProperty("xmpp.component.socket.active", "true");
// Start the port listener for external components
startComponentListener(localIPAddress);
}
else {
JiveGlobals.setProperty("xmpp.component.socket.active", "false");
// Stop the port listener for external components
stopComponentListener();
}
}
public boolean isComponentListenerEnabled() {
return JiveGlobals.getBooleanProperty("xmpp.component.socket.active", true);
}
public void enableServerListener(boolean enabled) {
if (enabled == isServerListenerEnabled()) {
// Ignore new setting
return;
}
if (enabled) {
JiveGlobals.setProperty("xmpp.server.socket.active", "true");
// Start the port listener for s2s communication
startServerListener(localIPAddress);
}
else {
JiveGlobals.setProperty("xmpp.server.socket.active", "false");
// Stop the port listener for s2s communication
stopServerListener();
}
}
public boolean isServerListenerEnabled() {
return JiveGlobals.getBooleanProperty("xmpp.server.socket.active", true);
}
public void setClientListenerPort(int port) {
if (port == getClientListenerPort()) {
// Ignore new setting
return;
}
JiveGlobals.setProperty("xmpp.socket.plain.port", String.valueOf(port));
// Stop the port listener for clients
stopClientListeners();
if (isClientListenerEnabled()) {
// Start the port listener for clients
startClientListeners(localIPAddress);
}
}
public int getClientListenerPort() {
return JiveGlobals.getIntProperty("xmpp.socket.plain.port",
SocketAcceptThread.DEFAULT_PORT);
}
public void setClientSSLListenerPort(int port) {
if (port == getClientSSLListenerPort()) {
// Ignore new setting
return;
}
JiveGlobals.setProperty("xmpp.socket.ssl.port", String.valueOf(port));
// Stop the port listener for secured clients
stopClientSSLListeners();
if (isClientSSLListenerEnabled()) {
// Start the port listener for secured clients
startClientSSLListeners(localIPAddress);
}
}
public int getClientSSLListenerPort() {
return JiveGlobals.getIntProperty("xmpp.socket.ssl.port",
SSLSocketAcceptThread.DEFAULT_PORT);
}
public void setComponentListenerPort(int port) {
if (port == getComponentListenerPort()) {
// Ignore new setting
return;
}
JiveGlobals.setProperty("xmpp.component.socket.port", String.valueOf(port));
// Stop the port listener for external components
stopComponentListener();
if (isComponentListenerEnabled()) {
// Start the port listener for external components
startComponentListener(localIPAddress);
}
}
public int getComponentListenerPort() {
return JiveGlobals.getIntProperty("xmpp.component.socket.port",
SocketAcceptThread.DEFAULT_COMPONENT_PORT);
}
public void setServerListenerPort(int port) {
if (port == getServerListenerPort()) {
// Ignore new setting
return;
}
JiveGlobals.setProperty("xmpp.server.socket.port", String.valueOf(port));
// Stop the port listener for s2s communication
stopServerListener();
if (isServerListenerEnabled()) {
// Start the port listener for s2s communication
startServerListener(localIPAddress);
}
}
public int getServerListenerPort() {
return JiveGlobals.getIntProperty("xmpp.server.socket.port",
SocketAcceptThread.DEFAULT_SERVER_PORT);
}
// ##################################################################### // #####################################################################
// Module management // Module management
...@@ -235,22 +428,10 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -235,22 +428,10 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
public void stop() { public void stop() {
super.stop(); super.stop();
if (socketThread != null) { stopClientListeners();
socketThread.shutdown(); stopClientSSLListeners();
socketThread = null; stopComponentListener();
} stopServerListener();
if (sslSocketThread != null) {
sslSocketThread.shutdown();
sslSocketThread = null;
}
if (componentSocketThread != null) {
componentSocketThread.shutdown();
componentSocketThread = null;
}
if (serverSocketThread != null) {
serverSocketThread.shutdown();
serverSocketThread = null;
}
SocketSendingTracker.getInstance().shutdown(); SocketSendingTracker.getInstance().shutdown();
serverName = null; serverName = null;
} }
......
...@@ -13,10 +13,12 @@ package org.jivesoftware.messenger.spi; ...@@ -13,10 +13,12 @@ package org.jivesoftware.messenger.spi;
import org.jivesoftware.util.Version; import org.jivesoftware.util.Version;
import org.jivesoftware.messenger.XMPPServerInfo; import org.jivesoftware.messenger.XMPPServerInfo;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.Collections;
/** /**
* Implements the server info for a basic server. Optimization opportunities * Implements the server info for a basic server. Optimization opportunities
...@@ -30,7 +32,7 @@ public class XMPPServerInfoImpl implements XMPPServerInfo { ...@@ -30,7 +32,7 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
private Date stopDate; private Date stopDate;
private String name; private String name;
private Version ver; private Version ver;
private Iterator ports; private ConnectionManager connectionManager;
/** /**
* Simple constructor * Simple constructor
...@@ -41,16 +43,16 @@ public class XMPPServerInfoImpl implements XMPPServerInfo { ...@@ -41,16 +43,16 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
* it hasn't been started). * it hasn't been started).
* @param stopDate the server's last stop time (can be null indicating it * @param stopDate the server's last stop time (can be null indicating it
* is running or hasn't been started). * is running or hasn't been started).
* @param portIter the portIter active on the server. * @param connectionManager the object that keeps track of the active ports.
*/ */
public XMPPServerInfoImpl(String serverName, Version version, Date startDate, Date stopDate, public XMPPServerInfoImpl(String serverName, Version version, Date startDate, Date stopDate,
Iterator portIter) ConnectionManager connectionManager)
{ {
this.name = serverName; this.name = serverName;
this.ver = version; this.ver = version;
this.startDate = startDate; this.startDate = startDate;
this.stopDate = stopDate; this.stopDate = stopDate;
this.ports = portIter; this.connectionManager = connectionManager;
} }
public Version getVersion() { public Version getVersion() {
...@@ -80,6 +82,11 @@ public class XMPPServerInfoImpl implements XMPPServerInfo { ...@@ -80,6 +82,11 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
} }
public Iterator getServerPorts() { public Iterator getServerPorts() {
return ports; if (connectionManager == null) {
return Collections.EMPTY_LIST.iterator();
}
else {
return connectionManager.getPorts();
}
} }
} }
\ No newline at end of file
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
boolean deleteSuccess = false; boolean deleteSuccess = false;
String serverName = XMPPServer.getInstance().getServerInfo().getName(); String serverName = XMPPServer.getInstance().getServerInfo().getName();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
// Update the session kick policy if requested // Update the session kick policy if requested
...@@ -74,11 +75,11 @@ ...@@ -74,11 +75,11 @@
// If no errors, continue: // If no errors, continue:
if (errors.isEmpty()) { if (errors.isEmpty()) {
if (!componentEnabled) { if (!componentEnabled) {
JiveGlobals.setProperty("xmpp.component.socket.active", "false"); connectionManager.enableComponentListener(false);
} }
else { else {
JiveGlobals.setProperty("xmpp.component.socket.active", "true"); connectionManager.enableComponentListener(true);
JiveGlobals.setProperty("xmpp.component.socket.port", String.valueOf(port)); connectionManager.setComponentListenerPort(port);
ExternalComponentManager.setDefaultSecret(defaultSecret); ExternalComponentManager.setDefaultSecret(defaultSecret);
} }
updateSucess = true; updateSucess = true;
...@@ -131,8 +132,8 @@ ...@@ -131,8 +132,8 @@
// Set page vars // Set page vars
if (errors.size() == 0) { if (errors.size() == 0) {
componentEnabled = JiveGlobals.getBooleanProperty("xmpp.component.socket.active", true); componentEnabled = connectionManager.isComponentListenerEnabled();
port = JiveGlobals.getIntProperty("xmpp.component.socket.port", SocketAcceptThread.DEFAULT_COMPONENT_PORT); port = connectionManager.getComponentListenerPort();
defaultSecret = ExternalComponentManager.getDefaultSecret(); defaultSecret = ExternalComponentManager.getDefaultSecret();
permissionFilter = ExternalComponentManager.getPermissionPolicy().toString(); permissionFilter = ExternalComponentManager.getPermissionPolicy().toString();
subdomain = ""; subdomain = "";
...@@ -140,7 +141,7 @@ ...@@ -140,7 +141,7 @@
} }
else { else {
if (port == 0) { if (port == 0) {
port = JiveGlobals.getIntProperty("xmpp.component.socket.port", SocketAcceptThread.DEFAULT_COMPONENT_PORT); port = connectionManager.getComponentListenerPort();
} }
if (defaultSecret == null) { if (defaultSecret == null) {
defaultSecret = ExternalComponentManager.getDefaultSecret(); defaultSecret = ExternalComponentManager.getDefaultSecret();
...@@ -291,22 +292,22 @@ ...@@ -291,22 +292,22 @@
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.blacklist %>" id="rb01" <input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.blacklist %>" id="rb03"
<%= (ExternalComponentManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>> <%= (ExternalComponentManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb01"> <label for="rb03">
<b><fmt:message key="component.settings.anyone" /></b> - <fmt:message key="component.settings.anyone_info" /> <b><fmt:message key="component.settings.anyone" /></b> - <fmt:message key="component.settings.anyone_info" />
</label> </label>
</td> </td>
</tr> </tr>
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.whitelist %>" id="rb02" <input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.whitelist %>" id="rb04"
<%= (ExternalComponentManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>> <%= (ExternalComponentManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb02"> <label for="rb04">
<b><fmt:message key="component.settings.whitelist" /></b> - <fmt:message key="component.settings.whitelist_info" /> <b><fmt:message key="component.settings.whitelist" /></b> - <fmt:message key="component.settings.whitelist_info" />
</label> </label>
</td> </td>
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
java.net.InetAddress, java.net.InetAddress,
org.jivesoftware.util.JiveGlobals, org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.net.SSLSocketAcceptThread, org.jivesoftware.messenger.net.SSLSocketAcceptThread,
org.jivesoftware.messenger.net.SocketAcceptThread" org.jivesoftware.messenger.net.SocketAcceptThread,
org.jivesoftware.messenger.ConnectionManager"
%> %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
...@@ -62,6 +63,7 @@ ...@@ -62,6 +63,7 @@
} }
XMPPServer server = admin.getXMPPServer(); XMPPServer server = admin.getXMPPServer();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
Map errors = new HashMap(); Map errors = new HashMap();
if (save) { if (save) {
if (serverName == null) { if (serverName == null) {
...@@ -96,25 +98,40 @@ ...@@ -96,25 +98,40 @@
} }
} }
if (errors.size() == 0) { if (errors.size() == 0) {
boolean needRestart = false;
if (!serverName.equals(server.getServerInfo().getName())) {
server.getServerInfo().setName(serverName); server.getServerInfo().setName(serverName);
JiveGlobals.setProperty("xmpp.socket.plain.port", String.valueOf(port)); needRestart = true;
JiveGlobals.setProperty("xmpp.socket.ssl.active", String.valueOf(sslEnabled)); }
JiveGlobals.setProperty("xmpp.socket.ssl.port", String.valueOf(sslPort)); connectionManager.setClientListenerPort(port);
JiveGlobals.setProperty("xmpp.component.socket.port", String.valueOf(componentPort)); connectionManager.enableClientSSLListener(sslEnabled);
JiveGlobals.setProperty("xmpp.server.socket.port", String.valueOf(serverPort)); connectionManager.setClientSSLListenerPort(sslPort);
connectionManager.setComponentListenerPort(componentPort);
connectionManager.setServerListenerPort(serverPort);
if (!String.valueOf(embeddedPort).equals(JiveGlobals.getXMLProperty("adminConsole.port"))) {
JiveGlobals.setXMLProperty("adminConsole.port", String.valueOf(embeddedPort)); JiveGlobals.setXMLProperty("adminConsole.port", String.valueOf(embeddedPort));
needRestart = true;
}
if (!String.valueOf(embeddedSecurePort).equals(JiveGlobals.getXMLProperty("adminConsole.securePort"))) {
JiveGlobals.setXMLProperty("adminConsole.securePort", String.valueOf(embeddedSecurePort)); JiveGlobals.setXMLProperty("adminConsole.securePort", String.valueOf(embeddedSecurePort));
needRestart = true;
}
if (needRestart) {
response.sendRedirect("server-props.jsp?success=true&restart=true");
}
else {
response.sendRedirect("server-props.jsp?success=true"); response.sendRedirect("server-props.jsp?success=true");
}
return; return;
} }
} }
else { else {
serverName = server.getServerInfo().getName(); serverName = server.getServerInfo().getName();
sslEnabled = "true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active")); sslEnabled = connectionManager.isClientSSLListenerEnabled();
try { port = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.plain.port", String.valueOf(SocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {} port = connectionManager.getClientListenerPort();
try { sslPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.ssl.port", String.valueOf(SSLSocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {} sslPort = connectionManager.getClientSSLListenerPort();
try { componentPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.component.socket.port", String.valueOf(SocketAcceptThread.DEFAULT_COMPONENT_PORT))); } catch (Exception ignored) {} componentPort = connectionManager.getComponentListenerPort();
try { serverPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.server.socket.port", String.valueOf(SocketAcceptThread.DEFAULT_SERVER_PORT))); } catch (Exception ignored) {} serverPort = connectionManager.getServerListenerPort();
try { embeddedPort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.port")); } catch (Exception ignored) {} try { embeddedPort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.port")); } catch (Exception ignored) {}
try { embeddedSecurePort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.securePort")); } catch (Exception ignored) {} try { embeddedSecurePort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.securePort")); } catch (Exception ignored) {}
} }
...@@ -148,7 +165,11 @@ ...@@ -148,7 +165,11 @@
<tbody> <tbody>
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td> <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label"> <td class="jive-icon-label">
<% if ("true".equals(request.getParameter("restart"))) { %>
<fmt:message key="server.props.update" /> <b><fmt:message key="global.restart" /></b> <fmt:message key="server.props.update2" /> <a href="index.jsp"><fmt:message key="global.server_status" /></a>). <fmt:message key="server.props.update" /> <b><fmt:message key="global.restart" /></b> <fmt:message key="server.props.update2" /> <a href="index.jsp"><fmt:message key="global.server_status" /></a>).
<% } else { %>
<fmt:message key="server.props.update.norestart" />.
<% } %>
</td></tr> </td></tr>
</tbody> </tbody>
</table> </table>
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
java.text.DateFormat, java.text.DateFormat,
org.jivesoftware.admin.AdminPageBean, org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.server.RemoteServerManager, org.jivesoftware.messenger.server.RemoteServerManager,
org.jivesoftware.messenger.server.RemoteServerConfiguration" org.jivesoftware.messenger.server.RemoteServerConfiguration,
org.jivesoftware.messenger.component.ExternalComponentManager"
errorPage="error.jsp" errorPage="error.jsp"
%> %>
...@@ -27,6 +28,9 @@ ...@@ -27,6 +28,9 @@
<% admin.init(request, response, session, application, out ); %> <% admin.init(request, response, session, application, out ); %>
<% // Get parameters <% // Get parameters
boolean update = request.getParameter("update") != null;
boolean s2sEnabled = ParamUtils.getBooleanParameter(request,"s2sEnabled");
int port = ParamUtils.getIntParameter(request,"port", 0);
boolean closeEnabled = ParamUtils.getBooleanParameter(request,"closeEnabled"); boolean closeEnabled = ParamUtils.getBooleanParameter(request,"closeEnabled");
String idletime = ParamUtils.getParameter(request,"idletime"); String idletime = ParamUtils.getParameter(request,"idletime");
boolean closeSettings = request.getParameter("closeSettings") != null; boolean closeSettings = request.getParameter("closeSettings") != null;
...@@ -45,8 +49,29 @@ ...@@ -45,8 +49,29 @@
// Get muc server // Get muc server
SessionManager sessionManager = admin.getSessionManager(); SessionManager sessionManager = admin.getSessionManager();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
Map errors = new HashMap(); Map errors = new HashMap();
if (update) {
// Validate params
if (s2sEnabled) {
if (port <= 0) {
errors.put("port","");
}
}
// If no errors, continue:
if (errors.isEmpty()) {
if (!s2sEnabled) {
connectionManager.enableServerListener(false);
}
else {
connectionManager.enableServerListener(true);
connectionManager.setServerListenerPort(port);
}
updateSucess = true;
}
}
// Handle an update of the kicking task settings // Handle an update of the kicking task settings
if (closeSettings) { if (closeSettings) {
if (!closeEnabled) { if (!closeEnabled) {
...@@ -131,11 +156,16 @@ ...@@ -131,11 +156,16 @@
// Set page vars // Set page vars
if (errors.size() == 0) { if (errors.size() == 0) {
s2sEnabled = connectionManager.isServerListenerEnabled();
port = connectionManager.getServerListenerPort();
permissionFilter = RemoteServerManager.getPermissionPolicy().toString(); permissionFilter = RemoteServerManager.getPermissionPolicy().toString();
domain = ""; domain = "";
remotePort = "0"; remotePort = "0";
} }
else { else {
if (port == 0) {
port = connectionManager.getServerListenerPort();
}
if (permissionFilter == null) { if (permissionFilter == null) {
permissionFilter = RemoteServerManager.getPermissionPolicy().toString(); permissionFilter = RemoteServerManager.getPermissionPolicy().toString();
} }
...@@ -217,6 +247,65 @@ ...@@ -217,6 +247,65 @@
<% } %> <% } %>
<form action="server2server-settings.jsp" method="post">
<fieldset>
<legend><fmt:message key="server2server.settings.enabled.legend" /></legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="s2sEnabled" value="false" id="rb01"
<%= (!s2sEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01">
<b><fmt:message key="server2server.settings.label_disable" /></b> - <fmt:message key="server2server.settings.label_disable_info" />
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="s2sEnabled" value="true" id="rb02"
<%= (s2sEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02">
<b><fmt:message key="server2server.settings.label_enable" /></b> - <fmt:message key="server2server.settings.label_enable_info" />
</label>
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap>
&nbsp;
</td>
<td width="99%">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr valign="top">
<td width="1%" nowrap class="c1">
<fmt:message key="server2server.settings.port" />
</td>
<td width="99%">
<input type="text" size="15" maxlength="50" name="port"
value="<%= port %>">
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<br>
<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
</form>
<br>
<form action="server2server-settings.jsp?closeSettings" method="post"> <form action="server2server-settings.jsp?closeSettings" method="post">
<fieldset> <fieldset>
...@@ -226,20 +315,20 @@ ...@@ -226,20 +315,20 @@
<tbody> <tbody>
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="closeEnabled" value="false" id="rb01" <input type="radio" name="closeEnabled" value="false" id="rb03"
<%= ((admin.getSessionManager().getServerSessionIdleTime() < 0) ? "checked" : "") %>> <%= ((admin.getSessionManager().getServerSessionIdleTime() < 0) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb01"><fmt:message key="server2server.settings.never_close" /></label> <label for="rb03"><fmt:message key="server2server.settings.never_close" /></label>
</td> </td>
</tr> </tr>
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="closeEnabled" value="true" id="rb02" <input type="radio" name="closeEnabled" value="true" id="rb04"
<%= ((admin.getSessionManager().getServerSessionIdleTime() > -1) ? "checked" : "") %>> <%= ((admin.getSessionManager().getServerSessionIdleTime() > -1) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb02"><fmt:message key="server2server.settings.close_session" /></label> <label for="rb04"><fmt:message key="server2server.settings.close_session" /></label>
<input type="text" name="idletime" size="5" maxlength="5" <input type="text" name="idletime" size="5" maxlength="5"
onclick="this.form.closeEnabled[1].checked=true;" onclick="this.form.closeEnabled[1].checked=true;"
value="<%= admin.getSessionManager().getServerSessionIdleTime() == -1 ? 30 : admin.getSessionManager().getServerSessionIdleTime() / 1000 / 60 %>"> value="<%= admin.getSessionManager().getServerSessionIdleTime() == -1 ? 30 : admin.getSessionManager().getServerSessionIdleTime() / 1000 / 60 %>">
...@@ -268,22 +357,22 @@ ...@@ -268,22 +357,22 @@
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.blacklist %>" id="rb01" <input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.blacklist %>" id="rb05"
<%= (RemoteServerManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>> <%= (RemoteServerManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb01"> <label for="rb05">
<b><fmt:message key="server2server.settings.anyone" /></b> - <fmt:message key="server2server.settings.anyone_info" /> <b><fmt:message key="server2server.settings.anyone" /></b> - <fmt:message key="server2server.settings.anyone_info" />
</label> </label>
</td> </td>
</tr> </tr>
<tr valign="middle"> <tr valign="middle">
<td width="1%" nowrap> <td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.whitelist %>" id="rb02" <input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.whitelist %>" id="rb06"
<%= (RemoteServerManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>> <%= (RemoteServerManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td> </td>
<td width="99%"> <td width="99%">
<label for="rb02"> <label for="rb06">
<b><fmt:message key="server2server.settings.whitelist" /></b> - <fmt:message key="server2server.settings.whitelist_info" /> <b><fmt:message key="server2server.settings.whitelist" /></b> - <fmt:message key="server2server.settings.whitelist_info" />
</label> </label>
</td> </td>
......
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