提交 8d310830 编写于 作者: T terrymanu

refactor MySQLResponseHandler

上级 d054acce
...@@ -29,7 +29,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter; ...@@ -29,7 +29,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
*/ */
public abstract class ResponseHandler extends ChannelInboundHandlerAdapter { public abstract class ResponseHandler extends ChannelInboundHandlerAdapter {
private AuthType authType; private AuthType authType = AuthType.UN_AUTH;
@Override @Override
public void channelRead(final ChannelHandlerContext context, final Object message) { public void channelRead(final ChannelHandlerContext context, final Object message) {
......
...@@ -80,7 +80,8 @@ public final class MySQLResponseHandler extends ResponseHandler { ...@@ -80,7 +80,8 @@ public final class MySQLResponseHandler extends ResponseHandler {
protected void auth(final ChannelHandlerContext context, final ByteBuf byteBuf) { protected void auth(final ChannelHandlerContext context, final ByteBuf byteBuf) {
try (MySQLPacketPayload payload = new MySQLPacketPayload(byteBuf)) { try (MySQLPacketPayload payload = new MySQLPacketPayload(byteBuf)) {
HandshakePacket handshakePacket = new HandshakePacket(payload); HandshakePacket handshakePacket = new HandshakePacket(payload);
byte[] authResponse = securePasswordAuthentication(dataSourceParameter.getPassword().getBytes(), handshakePacket.getAuthPluginData().getAuthPluginData()); byte[] authResponse = securePasswordAuthentication(
(null == dataSourceParameter.getPassword() ? "" : dataSourceParameter.getPassword()).getBytes(), handshakePacket.getAuthPluginData().getAuthPluginData());
HandshakeResponse41Packet handshakeResponse41Packet = new HandshakeResponse41Packet( HandshakeResponse41Packet handshakeResponse41Packet = new HandshakeResponse41Packet(
handshakePacket.getSequenceId() + 1, CapabilityFlag.calculateHandshakeCapabilityFlagsLower(), 16777215, ServerInfo.CHARSET, handshakePacket.getSequenceId() + 1, CapabilityFlag.calculateHandshakeCapabilityFlagsLower(), 16777215, ServerInfo.CHARSET,
dataSourceParameter.getUsername(), authResponse, dataSourceMetaData.getSchemeName()); dataSourceParameter.getUsername(), authResponse, dataSourceMetaData.getSchemeName());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册