From 949a06cc94d071bf55f893825e2ba62908dd91c5 Mon Sep 17 00:00:00 2001 From: dcy Date: Fri, 6 Dec 2024 16:37:34 +0800 Subject: [PATCH] ssl supplyment:fix checkstyle --- .../dble/net/connection/AbstractConnection.java | 4 ++-- .../dble/net/connection/BackendConnection.java | 1 - .../dble/net/connection/SSLHandler.java | 15 +++++++-------- .../actiontech/dble/net/ssl/IOpenSSLWrapper.java | 6 +++--- .../mysqlauthenticate/MySQLBackAuthService.java | 3 ++- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java b/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java index 038da1880e..c9c6febf76 100644 --- a/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java +++ b/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java @@ -860,10 +860,10 @@ public void handleSSLData(ByteBuffer dataBuffer) throws IOException { return; } int offset = 0; - SSLProtoHandler proto = new SSLProtoHandler(this); + SSLProtoHandler sslProtoHandler = new SSLProtoHandler(this); boolean hasRemaining = true; while (hasRemaining) { - ProtoHandlerResult result = proto.handle(dataBuffer, offset, false, true); + ProtoHandlerResult result = sslProtoHandler.handle(dataBuffer, offset, false, true); switch (result.getCode()) { case SSL_PROTO_PACKET: case SSL_CLOSE_PACKET: diff --git a/src/main/java/com/actiontech/dble/net/connection/BackendConnection.java b/src/main/java/com/actiontech/dble/net/connection/BackendConnection.java index 6e8c18d292..6cdb52a258 100644 --- a/src/main/java/com/actiontech/dble/net/connection/BackendConnection.java +++ b/src/main/java/com/actiontech/dble/net/connection/BackendConnection.java @@ -10,7 +10,6 @@ import com.actiontech.dble.backend.pool.PooledConnectionListener; import com.actiontech.dble.backend.pool.ReadTimeStatusInstance; import com.actiontech.dble.buffer.BufferType; -import com.actiontech.dble.config.model.SystemConfig; import com.actiontech.dble.config.model.db.DbInstanceConfig; import com.actiontech.dble.net.IOProcessor; import com.actiontech.dble.net.SocketWR; diff --git a/src/main/java/com/actiontech/dble/net/connection/SSLHandler.java b/src/main/java/com/actiontech/dble/net/connection/SSLHandler.java index 72040d98ad..e8ebc1ad6f 100644 --- a/src/main/java/com/actiontech/dble/net/connection/SSLHandler.java +++ b/src/main/java/com/actiontech/dble/net/connection/SSLHandler.java @@ -73,7 +73,6 @@ public void sendhandShake() throws SSLException { default: throw new IllegalStateException("unknown handshake status: " + handshakeStatus); } - } catch (SSLException e) { LOGGER.warn("during the handshake, unwrap data exception: ", e); con.close("during the handshake, unwrap data fail"); @@ -90,14 +89,14 @@ private void unwrapNonAppData(byte[] data) { try { - final SSLEngineResult result = unwrap(engine, in); - final Status status = result.getStatus(); + final SSLEngineResult result = unwrap(engine, in); + final Status status = result.getStatus(); - final int produced = result.bytesProduced(); - final int consumed = result.bytesConsumed(); - if (status == Status.CLOSED) { - return; - } + final int produced = result.bytesProduced(); + final int consumed = result.bytesConsumed(); + if (status == Status.CLOSED) { + return; + } for (; ; ) { final SSLEngineResult.HandshakeStatus handshakeStatus = engine.getHandshakeStatus(); switch (handshakeStatus) { diff --git a/src/main/java/com/actiontech/dble/net/ssl/IOpenSSLWrapper.java b/src/main/java/com/actiontech/dble/net/ssl/IOpenSSLWrapper.java index 217a245ad5..552f6a975c 100644 --- a/src/main/java/com/actiontech/dble/net/ssl/IOpenSSLWrapper.java +++ b/src/main/java/com/actiontech/dble/net/ssl/IOpenSSLWrapper.java @@ -13,9 +13,9 @@ * Create Date: 2024-12-05 */ public interface IOpenSSLWrapper { - public SSLEngine createClientSSLEngine(); + SSLEngine createClientSSLEngine(); - public boolean initContext(); + boolean initContext(); - public SSLEngine createServerSSLEngine(boolean isAuthClient); + SSLEngine createServerSSLEngine(boolean isAuthClient); } diff --git a/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLBackAuthService.java b/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLBackAuthService.java index 67cb508a0f..52c8bb7bb7 100644 --- a/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLBackAuthService.java +++ b/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLBackAuthService.java @@ -165,7 +165,8 @@ private void handleHandshake(byte[] data) { String serverPlugin = new String(handshakePacket.getAuthPluginName()); try { pluginName = PluginName.valueOf(serverPlugin); - if (connection.isSupportSSL()) {//todo:move config in dbinstance scope + if (connection.isSupportSSL()) { + //todo:move config in dbinstance scope sendSSLRequestPacket(++data[3]); connection.sendSSLHandShake(OpenSSLWrapper.PROTOCOL); } else {