processResponse method
After receiving the handshake packet, if all is well, an _AuthHandler
is created and returned to handle authentication.
Currently, if the client protocol version is not 4.1, an exception is thrown.
Implementation
HandlerResponse processResponse(ReadBuffer response) {
checkResponse(response);
readResponseBuffer(response);
if ((serverCapabilities & CLIENT_PROTOCOL_41) == 0) {
throw MySqlClientError("Unsupported protocol (must be 4.1 or newer");
}
if ((serverCapabilities & CLIENT_SECURE_CONNECTION) == 0) {
throw MySqlClientError("Old Password Authentication is not supported");
}
List<int> pwdHash = [];
if ((serverCapabilities & CLIENT_PLUGIN_AUTH) != 0) {
if (pluginName == AuthPluginNames.mysqlNativePassword) {
pwdHash = makeMysqlNativePassword(scrambleBuffer, _password);
} else if (pluginName == AuthPluginNames.cachingSha2Password) {
pwdHash = makeCachingSha2Password(scrambleBuffer, _password);
} else {
throw MySqlClientError("Authentication plugin not supported: $pluginName");
}
}
int clientFlags =
CLIENT_PROTOCOL_41 | CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_SECURE_CONNECTION;
if (useCompression! && (serverCapabilities & CLIENT_COMPRESS) != 0) {
clientFlags |= CLIENT_COMPRESS;
} else {
useCompression = false;
}
if (useSSL! && (serverCapabilities & CLIENT_SSL) != 0) {
clientFlags |= CLIENT_SSL | CLIENT_SECURE_CONNECTION;
} else {
useSSL = false;
}
if (useSSL!) {
return HandlerResponse(
nextHandler: SSLHandler(
clientFlags,
_maxPacketSize,
_characterSet,
AuthHandler(
_user,
pwdHash,
_db,
clientFlags,
_maxPacketSize,
_characterSet,
)));
}
return HandlerResponse(nextHandler: AuthHandler(_user, pwdHash, _db, clientFlags, _maxPacketSize, _characterSet));
}