Skip to content

Commit

Permalink
OF-2559 WIP startTLS does not need to return
Browse files Browse the repository at this point in the history
  • Loading branch information
viv committed Aug 1, 2023
1 parent edec92b commit 8d8dd7f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.jivesoftware.openfire;

import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
import org.dom4j.Namespace;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.session.LocalSession;
Expand All @@ -39,7 +37,7 @@
*
* @author Iain Shigeoka
*/
public interface Connection<T> extends Closeable {
public interface Connection extends Closeable {
/**
* When a connection is used to transmit an XML data, the root element of that data can define XML namespaces other
* than the ones that are default (eg: 'jabber:client', 'jabber:server', etc). For an XML parser to be able to parse
Expand Down Expand Up @@ -351,10 +349,9 @@ default boolean isEncrypted() {
*
* @param clientMode boolean indicating if this entity is a client or a server in the TLS negotiation.
* @param directTLS boolean indicating if the negotiation is directTLS (true) or startTLS (false).
* @return a future that resolves once TLS handshake has completed
* @throws Exception if an error occurred while encrypting the connection.
*/
Future<T> startTLS(boolean clientMode, boolean directTLS) throws Exception;
void startTLS(boolean clientMode, boolean directTLS) throws Exception;

/**
* Adds the compression filter to the connection but only filter incoming traffic. Do not filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.ZOutputStream;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.session.IncomingServerSession;
Expand Down Expand Up @@ -59,7 +57,7 @@
* @author Iain Shigeoka
* @deprecated Old, pre NIO / MINA code. Should not be used as NIO offers better performance. Currently only in use for s2s.
*/
public class SocketConnection implements Connection<Void> {
public class SocketConnection implements Connection {

private static final Logger Log = LoggerFactory.getLogger(SocketConnection.class);

Expand Down Expand Up @@ -152,7 +150,7 @@ public TLSStreamHandler getTLSStreamHandler() {
return tlsStreamHandler;
}

public Future<Void> startTLS(boolean clientMode, boolean directTLS) throws IOException {
public void startTLS(boolean clientMode, boolean directTLS) throws IOException {
if (!isEncrypted) {
isEncrypted = true;

Expand All @@ -177,7 +175,6 @@ public Future<Void> startTLS(boolean clientMode, boolean directTLS) throws IOExc
writer = new BufferedWriter(new OutputStreamWriter(tlsStreamHandler.getOutputStream(), StandardCharsets.UTF_8));
xmlSerializer = new XMLSocketWriter(writer, this);
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.jivesoftware.openfire.net;

import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionCloseListener;
import org.jivesoftware.openfire.PacketDeliverer;
Expand All @@ -44,7 +42,7 @@
*
* @author Gaston Dombiak
*/
public abstract class VirtualConnection implements Connection<Void> {
public abstract class VirtualConnection implements Connection {

private static final Logger Log = LoggerFactory.getLogger(VirtualConnection.class);

Expand Down Expand Up @@ -111,9 +109,8 @@ public PacketDeliverer getPacketDeliverer() {
return null;
}

public Future<Void> startTLS(boolean clientMode, boolean directTLS) throws Exception {
public void startTLS(boolean clientMode, boolean directTLS) throws Exception {
//Ignore
return null;
}

public void addCompression() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.traffic.ChannelTrafficShapingHandler;
import io.netty.util.concurrent.Future;
import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionCloseListener;
import org.jivesoftware.openfire.PacketDeliverer;
Expand Down Expand Up @@ -63,7 +62,7 @@
* @author Matthew Vivian
* @author Alex Gidman
*/
public class NettyConnection implements Connection<Channel> {
public class NettyConnection implements Connection {

private static final Logger Log = LoggerFactory.getLogger(NettyConnection.class);
public static final String SSL_HANDLER_NAME = "ssl";
Expand Down Expand Up @@ -388,7 +387,7 @@ private void updateWrittenBytesCounter(ChannelHandlerContext ctx) {
}
}

public Future<Channel> startTLS(boolean clientMode, boolean directTLS) throws Exception {
public void startTLS(boolean clientMode, boolean directTLS) throws Exception {

final EncryptionArtifactFactory factory = new EncryptionArtifactFactory( configuration );

Expand All @@ -406,8 +405,6 @@ public Future<Channel> startTLS(boolean clientMode, boolean directTLS) throws Ex
// Indicate the client that the server is ready to negotiate TLS
deliverRawText( "<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>" );
}

return sslHandler.handshakeFuture();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
package org.jivesoftware.openfire.session;

import org.jivesoftware.Fixtures;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.keystore.*;
import org.jivesoftware.openfire.net.*;
import org.jivesoftware.openfire.net.DNSUtil;
import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionListener;
import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.util.JiveGlobals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down

0 comments on commit 8d8dd7f

Please sign in to comment.