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

Created replacement for Client Connection admin page

parent b6ba74f8
...@@ -22,6 +22,7 @@ import java.util.*; ...@@ -22,6 +22,7 @@ import java.util.*;
public class ConnectionConfiguration public class ConnectionConfiguration
{ {
private final Logger Log; private final Logger Log;
private final boolean enabled;
private final ConnectionType type; private final ConnectionType type;
private final int maxThreadPoolSize; private final int maxThreadPoolSize;
private final int maxBufferSize; private final int maxBufferSize;
...@@ -329,6 +330,7 @@ public class ConnectionConfiguration ...@@ -329,6 +330,7 @@ public class ConnectionConfiguration
/** /**
* @param type * @param type
* @param enabled
* @param maxThreadPoolSize The maximum number of threads that are to be used to processing network activity. Must be equal to or larger than one. * @param maxThreadPoolSize The maximum number of threads that are to be used to processing network activity. Must be equal to or larger than one.
* @param maxBufferSize The maximum amount of bytes of the read buffer that I/O processor allocates per each read, or a non-positive value to configure no maximum. * @param maxBufferSize The maximum amount of bytes of the read buffer that I/O processor allocates per each read, or a non-positive value to configure no maximum.
* @param clientAuth specification if peers should be authenticated ('mutual authentication') (cannot be null). * @param clientAuth specification if peers should be authenticated ('mutual authentication') (cannot be null).
...@@ -337,7 +339,7 @@ public class ConnectionConfiguration ...@@ -337,7 +339,7 @@ public class ConnectionConfiguration
* @param tlsPolicy The TLS policy that is applied to connections (cannot be null). * @param tlsPolicy The TLS policy that is applied to connections (cannot be null).
*/ */
// TODO input validation // TODO input validation
public ConnectionConfiguration( ConnectionType type, int maxThreadPoolSize, int maxBufferSize, Connection.ClientAuth clientAuth, InetAddress bindAddress, int port, Connection.TLSPolicy tlsPolicy, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration, boolean acceptSelfSignedCertificates, boolean verifyCertificateValidity, Set<String> encryptionProtocolsEnabled, Set<String> encryptionProtocolsDisabled, Set<String> cipherSuitesEnabled, Set<String> cipherSuitesDisabled ) public ConnectionConfiguration( ConnectionType type, boolean enabled, int maxThreadPoolSize, int maxBufferSize, Connection.ClientAuth clientAuth, InetAddress bindAddress, int port, Connection.TLSPolicy tlsPolicy, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration, boolean acceptSelfSignedCertificates, boolean verifyCertificateValidity, Set<String> encryptionProtocolsEnabled, Set<String> encryptionProtocolsDisabled, Set<String> cipherSuitesEnabled, Set<String> cipherSuitesDisabled )
{ {
if ( maxThreadPoolSize <= 0 ) { if ( maxThreadPoolSize <= 0 ) {
throw new IllegalArgumentException( "Argument 'maxThreadPoolSize' must be equal to or greater than one." ); throw new IllegalArgumentException( "Argument 'maxThreadPoolSize' must be equal to or greater than one." );
...@@ -346,6 +348,7 @@ public class ConnectionConfiguration ...@@ -346,6 +348,7 @@ public class ConnectionConfiguration
throw new IllegalArgumentException( "Argument 'clientAuth' cannot be null." ); throw new IllegalArgumentException( "Argument 'clientAuth' cannot be null." );
} }
this.enabled = enabled;
this.tlsPolicy = tlsPolicy; this.tlsPolicy = tlsPolicy;
this.type = type; this.type = type;
this.maxThreadPoolSize = maxThreadPoolSize; this.maxThreadPoolSize = maxThreadPoolSize;
...@@ -521,4 +524,9 @@ public class ConnectionConfiguration ...@@ -521,4 +524,9 @@ public class ConnectionConfiguration
{ {
return trustStore; return trustStore;
} }
public boolean isEnabled()
{
return enabled;
}
} }
...@@ -2,12 +2,9 @@ package org.jivesoftware.openfire.spi; ...@@ -2,12 +2,9 @@ package org.jivesoftware.openfire.spi;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor; import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionManager;
import org.jivesoftware.openfire.ServerPort; import org.jivesoftware.openfire.ServerPort;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.keystore.CertificateStore;
import org.jivesoftware.openfire.keystore.CertificateStoreConfiguration; import org.jivesoftware.openfire.keystore.CertificateStoreConfiguration;
import org.jivesoftware.openfire.keystore.CertificateStoreManager;
import org.jivesoftware.openfire.net.SocketConnection; import org.jivesoftware.openfire.net.SocketConnection;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -156,14 +153,7 @@ public class ConnectionListener ...@@ -156,14 +153,7 @@ public class ConnectionListener
} }
JiveGlobals.setProperty( isEnabledPropertyName, Boolean.toString( enable ) ); JiveGlobals.setProperty( isEnabledPropertyName, Boolean.toString( enable ) );
if ( isRunning ) restart();
{
start();
}
else
{
stop();
}
} }
/** /**
...@@ -249,31 +239,13 @@ public class ConnectionListener ...@@ -249,31 +239,13 @@ public class ConnectionListener
maxBufferSize = -1; // No upper bound. maxBufferSize = -1; // No upper bound.
} }
Connection.ClientAuth clientAuth;
if ( clientAuthPolicyPropertyName == null )
{
clientAuth = Connection.ClientAuth.disabled;
}
else
{
try
{
final String value = JiveGlobals.getProperty( clientAuthPolicyPropertyName, Connection.ClientAuth.disabled.name() );
clientAuth = Connection.ClientAuth.valueOf( value );
}
catch ( IllegalArgumentException e )
{
Log.warn( "Invalid client auth value. A default will be used.", e );
clientAuth = Connection.ClientAuth.wanted;
}
}
// Take the current state of this instance, and create a new configuration. // Take the current state of this instance, and create a new configuration.
return new ConnectionConfiguration( return new ConnectionConfiguration(
getType(), getType(),
isEnabled(),
maxThreadPoolSize, maxThreadPoolSize,
maxBufferSize, maxBufferSize,
clientAuth, getClientAuth(),
getBindAddress(), getBindAddress(),
getPort(), getPort(),
getTLSPolicy(), getTLSPolicy(),
...@@ -423,6 +395,42 @@ public class ConnectionListener ...@@ -423,6 +395,42 @@ public class ConnectionListener
restart(); restart();
} }
public Connection.ClientAuth getClientAuth()
{
Connection.ClientAuth clientAuth;
if ( clientAuthPolicyPropertyName == null )
{
clientAuth = Connection.ClientAuth.disabled;
}
else
{
final String value = JiveGlobals.getProperty( clientAuthPolicyPropertyName, Connection.ClientAuth.disabled.name() );
try
{
clientAuth = Connection.ClientAuth.valueOf( value );
}
catch ( IllegalArgumentException e )
{
Log.error( "Error parsing property value of '{}' into a valid ClientAUth. Offending value: '{}'.", value, clientAuthPolicyPropertyName, e );
clientAuth = Connection.ClientAuth.disabled;
}
}
return clientAuth;
}
public void setClientAuth( Connection.ClientAuth clientAuth )
{
final Connection.ClientAuth oldValue = getClientAuth();
if ( oldValue.equals( clientAuth ) )
{
Log.debug( "Ignoring client auth configuration change request (to '{}'): listener already in this state.", clientAuth );
return;
}
Log.debug( "Changing client auth configuration from '{}' to '{}'.", oldValue, clientAuth );
JiveGlobals.setProperty( tlsPolicyPropertyName, clientAuth.toString() );
restart();
}
/** /**
* Returns the applicable TLS policy, but only when it is hardcoded (and inconfigurable). * Returns the applicable TLS policy, but only when it is hardcoded (and inconfigurable).
* @return a policy or null. * @return a policy or null.
......
This diff is collapsed.
This diff is collapsed.
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