Commit 690d43e1 authored by Guus der Kinderen's avatar Guus der Kinderen

Reduce complexity by removing a wrapper method.

parent a1c7f9cb
......@@ -87,6 +87,7 @@ import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.jivesoftware.openfire.net.MXParser;
import org.jivesoftware.openfire.session.ComponentSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.user.UserNotFoundException;
......@@ -781,13 +782,14 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
private void updateClearspaceClientSettings() {
String xmppBoshSslPort = "0";
String xmppBoshPort = "0";
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
String xmppPort = String.valueOf( connectionManager.getConfiguration( ConnectionType.SOCKET_C2S, false ).getPort() );
final ConnectionManagerImpl connectionManager = ( (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager() );
final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.SOCKET_C2S, false ).generateConnectionConfiguration();
String xmppPort = String.valueOf( configuration.getPort() );
if (JiveGlobals.getBooleanProperty(HttpBindManager.HTTP_BIND_ENABLED, HttpBindManager.HTTP_BIND_ENABLED_DEFAULT)) {
int boshSslPort = HttpBindManager.getInstance().getHttpBindSecurePort();
int boshPort = HttpBindManager.getInstance().getHttpBindUnsecurePort();
try {
if (HttpBindManager.getInstance().isHttpsBindActive() && connectionManager.getConfiguration( ConnectionType.SOCKET_C2S, false ).getTlsPolicy() != org.jivesoftware.openfire.Connection.TLSPolicy.disabled) {
if (HttpBindManager.getInstance().isHttpsBindActive() && configuration.getTlsPolicy() != org.jivesoftware.openfire.Connection.TLSPolicy.disabled) {
xmppBoshSslPort = String.valueOf(boshSslPort);
}
}
......
......@@ -156,7 +156,7 @@ public class AdminConsolePlugin implements Plugin {
}
final ConnectionManagerImpl connectionManager = ( (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager() );
final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.WEBADMIN, true );
final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.WEBADMIN, true ).generateConnectionConfiguration();
final SslContextFactory sslContextFactory = new EncryptionArtifactFactory( configuration ).getSslContextFactory();
final ServerConnector httpsConnector;
......
......@@ -258,7 +258,7 @@ public final class HttpBindManager {
}
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.BOSH_C2S, true );
final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.BOSH_C2S, true ).generateConnectionConfiguration();
final SslContextFactory sslContextFactory = new EncryptionArtifactFactory(configuration).getSslContextFactory();
final HttpConfiguration httpsConfig = new HttpConfiguration();
......
......@@ -122,7 +122,7 @@ public class ClientSessionConnection extends VirtualConnection {
// Here, a client-to-server configuration is mocked. It is likely not used, as actual connection handling takes
// place at the connection manager.
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
return connectionManager.getConfiguration( ConnectionType.SOCKET_C2S, false );
return connectionManager.getListener( ConnectionType.SOCKET_C2S, true ).generateConnectionConfiguration();
}
public byte[] getAddress() throws UnknownHostException {
......
......@@ -237,7 +237,7 @@ public class SocketConnection implements Connection {
// removed (it is marked as deprecated - at the time of writing, it is only used for S2S). The ugly hack: assume
// S2S:
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
return connectionManager.getConfiguration( ConnectionType.SOCKET_S2S, false );
return connectionManager.getListener( ConnectionType.SOCKET_S2S, false ).generateConnectionConfiguration();
}
public boolean validate() {
......
......@@ -266,7 +266,7 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
private void sendClientOptions() {
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.SOCKET_C2S, false );
final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.SOCKET_C2S, false ).generateConnectionConfiguration();
IQ options = new IQ(IQ.Type.set);
Element child = options.setChildElement("configuration",
......
......@@ -453,22 +453,6 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
return result;
}
/**
* Returns connection configuration that under the current settings is applicable.
*
* The #startInSslMode parameter is used to distinguish between listeners that expect to receive SSL encrypted data
* immediately, as opposed to connections that initially accept plain text data (the latter are typically subject to
* StartTLS for in-band encryption configuration). When for a particular connection type only one of these options
* is implemented, the parameter value is ignored.
*
* @param type The connection type for which a listener is to be configured.
* @param startInSslMode true when the listener to be configured is in legacy SSL mode, otherwise false.
* @return The applicable connection configuration (never null).
*/
public ConnectionConfiguration getConfiguration( ConnectionType type, boolean startInSslMode ) {
return getListener( type, startInSslMode ).generateConnectionConfiguration();
}
/**
* Return if the configuration allows this listener to be enabled (but does not verify that the listener is
* indeed active)
......
......@@ -20,8 +20,8 @@
final ConnectionType connectionType = ConnectionType.SOCKET_C2S;
final ConnectionManagerImpl manager = (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager();
final ConnectionConfiguration plaintextConfiguration = manager.getConfiguration( connectionType, false );
final ConnectionConfiguration legacymodeConfiguration = manager.getConfiguration( connectionType, true );
final ConnectionConfiguration plaintextConfiguration = manager.getListener( connectionType, false ).generateConnectionConfiguration();
final ConnectionConfiguration legacymodeConfiguration = manager.getListener( connectionType, true ).generateConnectionConfiguration();
final boolean update = request.getParameter( "update" ) != null;
final Map<String, String> errors = new HashMap<>();
......
......@@ -21,8 +21,8 @@
final ConnectionType connectionType = ConnectionType.SOCKET_S2S;
final ConnectionManagerImpl manager = (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager();
// final ConnectionConfiguration plaintextConfiguration = manager.getConfiguration( connectionType, false );
final ConnectionConfiguration legacymodeConfiguration = manager.getConfiguration( connectionType, true );
// final ConnectionConfiguration plaintextConfiguration = manager.getListener( connectionType, false ).generateConnectionConfiguration();
final ConnectionConfiguration legacymodeConfiguration = manager.getListener( connectionType, true ).generateConnectionConfiguration();
final boolean update = request.getParameter( "update" ) != null;
final boolean closeSettings = request.getParameter( "closeSettings" ) != null;
......
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