use of io.mycat.beans.mysql.packet.HandshakePacket in project Mycat2 by MyCATApache.
the class MySQLClientAuthHandler method createHandshakePayload.
public static byte[] createHandshakePayload(long sessionId, int serverCapabilities, byte[][] seedParts) {
HandshakePacket hs = new HandshakePacket();
hs.setProtocolVersion(MySQLVersion.PROTOCOL_VERSION);
hs.setServerVersion(new String(MySQLVersion.SERVER_VERSION));
hs.setConnectionId(sessionId);
hs.setAuthPluginDataPartOne(new String(seedParts[0]));
hs.setCapabilities(new MySQLServerCapabilityFlags(serverCapabilities));
hs.setHasPartTwo(true);
hs.setCharacterSet(8);
hs.setStatusFlags(2);
// 有插件的话,总长度必是21, seed
hs.setAuthPluginDataLen(21);
hs.setAuthPluginDataPartTwo(new String(seedParts[1]));
hs.setAuthPluginName(MysqlNativePasswordPluginUtil.PROTOCOL_PLUGIN_NAME);
MySQLPayloadWriter mySQLPayloadWriter = new MySQLPayloadWriter();
hs.writePayload(mySQLPayloadWriter);
return mySQLPayloadWriter.toByteArray();
}
Aggregations