Commit c4773fd9 authored by Guus der Kinderen's avatar Guus der Kinderen

Configuration representation should not include factory methods.

parent 3c1a4efd
...@@ -47,11 +47,11 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; ...@@ -47,11 +47,11 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.jivesoftware.openfire.JMXManager; import org.jivesoftware.openfire.JMXManager;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.keystore.CertificateStoreManager;
import org.jivesoftware.openfire.keystore.IdentityStore; import org.jivesoftware.openfire.keystore.IdentityStore;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl; import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType; import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.spi.EncryptionArtifactFactory;
import org.jivesoftware.util.CertificateEventListener; import org.jivesoftware.util.CertificateEventListener;
import org.jivesoftware.util.CertificateManager; import org.jivesoftware.util.CertificateManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
...@@ -157,7 +157,7 @@ public class AdminConsolePlugin implements Plugin { ...@@ -157,7 +157,7 @@ public class AdminConsolePlugin implements Plugin {
final ConnectionManagerImpl connectionManager = ( (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager() ); final ConnectionManagerImpl connectionManager = ( (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager() );
final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.WEBADMIN, true ); final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.WEBADMIN, true );
final SslContextFactory sslContextFactory = configuration.getSslContextFactory(); final SslContextFactory sslContextFactory = new EncryptionArtifactFactory( configuration ).getSslContextFactory();
final ServerConnector httpsConnector; final ServerConnector httpsConnector;
if ( "npn".equals( JiveGlobals.getXMLProperty( "spdy.protocol", "" ) ) ) if ( "npn".equals( JiveGlobals.getXMLProperty( "spdy.protocol", "" ) ) )
......
...@@ -64,6 +64,7 @@ import org.jivesoftware.openfire.session.ConnectionSettings; ...@@ -64,6 +64,7 @@ import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl; import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType; import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.spi.EncryptionArtifactFactory;
import org.jivesoftware.util.CertificateEventListener; import org.jivesoftware.util.CertificateEventListener;
import org.jivesoftware.util.CertificateManager; import org.jivesoftware.util.CertificateManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
...@@ -258,7 +259,7 @@ public final class HttpBindManager { ...@@ -258,7 +259,7 @@ public final class HttpBindManager {
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager()); final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.BOSH_C2S, true ); final ConnectionConfiguration configuration = connectionManager.getConfiguration( ConnectionType.BOSH_C2S, true );
final SslContextFactory sslContextFactory = configuration.getSslContextFactory(); final SslContextFactory sslContextFactory = new EncryptionArtifactFactory(configuration).getSslContextFactory();
final HttpConfiguration httpsConfig = new HttpConfiguration(); final HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.setSecureScheme("https"); httpsConfig.setSecureScheme("https");
......
...@@ -33,6 +33,7 @@ import javax.net.ssl.SSLEngineResult.Status; ...@@ -33,6 +33,7 @@ import javax.net.ssl.SSLEngineResult.Status;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionType; import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.spi.EncryptionArtifactFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -75,14 +76,15 @@ public class TLSWrapper { ...@@ -75,14 +76,15 @@ public class TLSWrapper {
try try
{ {
final EncryptionArtifactFactory factory = new EncryptionArtifactFactory( configuration );
final SSLEngine sslEngine; final SSLEngine sslEngine;
if ( clientMode ) if ( clientMode )
{ {
sslEngine = configuration.createClientModeSSLEngine(); sslEngine = factory.createClientModeSSLEngine();
} }
else else
{ {
sslEngine = configuration.createServerModeSSLEngine(); sslEngine = factory .createServerModeSSLEngine();
} }
final SSLSession sslSession = sslEngine.getSession(); final SSLSession sslSession = sslEngine.getSession();
......
...@@ -54,6 +54,7 @@ import org.jivesoftware.openfire.session.LocalSession; ...@@ -54,6 +54,7 @@ import org.jivesoftware.openfire.session.LocalSession;
import org.jivesoftware.openfire.session.Session; import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionType; import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.spi.EncryptionArtifactFactory;
import org.jivesoftware.util.XMLWriter; import org.jivesoftware.util.XMLWriter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -373,14 +374,15 @@ public class NIOConnection implements Connection { ...@@ -373,14 +374,15 @@ public class NIOConnection implements Connection {
public void startTLS(boolean clientMode) throws Exception { public void startTLS(boolean clientMode) throws Exception {
final EncryptionArtifactFactory factory = new EncryptionArtifactFactory( configuration );
final SslFilter filter; final SslFilter filter;
if ( clientMode ) if ( clientMode )
{ {
filter = configuration.createClientModeSslFilter(); filter = factory.createClientModeSslFilter();
} }
else else
{ {
filter = configuration.createServerModeSslFilter(); filter = factory.createServerModeSslFilter();
} }
ioSession.getFilterChain().addBefore(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, filter); ioSession.getFilterChain().addBefore(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, filter);
......
...@@ -48,6 +48,8 @@ class ConnectionAcceptor ...@@ -48,6 +48,8 @@ class ConnectionAcceptor
// Configuration // Configuration
private final ConnectionConfiguration configuration; private final ConnectionConfiguration configuration;
private final EncryptionArtifactFactory encryptionArtifactFactory;
private NioSocketAcceptor socketAcceptor; private NioSocketAcceptor socketAcceptor;
/** /**
...@@ -61,6 +63,7 @@ class ConnectionAcceptor ...@@ -61,6 +63,7 @@ class ConnectionAcceptor
} }
this.configuration = configuration; this.configuration = configuration;
this.encryptionArtifactFactory = new EncryptionArtifactFactory( configuration );
this.name = configuration.getType().toString().toLowerCase() + ( configuration.getTlsPolicy() == Connection.TLSPolicy.legacyMode ? "_ssl" : "" ); this.name = configuration.getType().toString().toLowerCase() + ( configuration.getTlsPolicy() == Connection.TLSPolicy.legacyMode ? "_ssl" : "" );
Log = LoggerFactory.getLogger( ConnectionAcceptor.class.getName() + "[" + name + "]" ); Log = LoggerFactory.getLogger( ConnectionAcceptor.class.getName() + "[" + name + "]" );
...@@ -132,7 +135,7 @@ class ConnectionAcceptor ...@@ -132,7 +135,7 @@ class ConnectionAcceptor
// Ports can be configured to start connections in SSL (as opposed to upgrade a non-encrypted socket to an encrypted one, typically using StartTLS) // Ports can be configured to start connections in SSL (as opposed to upgrade a non-encrypted socket to an encrypted one, typically using StartTLS)
if ( configuration.getTlsPolicy() == Connection.TLSPolicy.legacyMode ) if ( configuration.getTlsPolicy() == Connection.TLSPolicy.legacyMode )
{ {
final SslFilter sslFilter = configuration.createServerModeSslFilter(); final SslFilter sslFilter = encryptionArtifactFactory.createServerModeSslFilter();
filterChain.addAfter( ConnectionManagerImpl.EXECUTOR_FILTER_NAME, ConnectionManagerImpl.TLS_FILTER_NAME, sslFilter ); filterChain.addAfter( ConnectionManagerImpl.EXECUTOR_FILTER_NAME, ConnectionManagerImpl.TLS_FILTER_NAME, sslFilter );
} }
......
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