use of io.mycat.config.MySQLServerCapabilityFlags in project Mycat2 by MyCATApache.
the class HandshakePacket method readPayload.
public void readPayload(MySQLPayloadReadView buffer) {
protocolVersion = buffer.readByte();
if (protocolVersion != 0x0a) {
throw new MycatException("unsupport HandshakeV9");
}
serverVersion = buffer.readNULString();
connectionId = buffer.readFixInt(4);
authPluginDataPartOne = buffer.readFixString(8);
buffer.skipInReading(1);
capabilities = new MySQLServerCapabilityFlags((int) buffer.readFixInt(2) & 0x0000ffff);
if (!buffer.readFinished()) {
hasPartTwo = true;
characterSet = buffer.readByte();
statusFlags = (int) buffer.readFixInt(2);
long l = buffer.readFixInt(2) << 16;
capabilities.value |= l;
if (capabilities.isPluginAuth()) {
byte b = buffer.readByte();
authPluginDataLen = Byte.toUnsignedInt(b);
} else {
buffer.skipInReading(1);
}
// reserved = buffers.readFixString(10);
buffer.skipInReading(10);
if (capabilities.isCanDo41Anthentication()) {
// todo check length in range [13.authPluginDataLen)
// authPluginDataPartTwo = buffers.readFixString(13);
authPluginDataPartTwo = buffer.readNULString();
}
if (capabilities.isPluginAuth()) {
authPluginName = buffer.readNULString();
}
}
}
use of io.mycat.config.MySQLServerCapabilityFlags 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