Class: MysqlPR::Protocol::AuthenticationPacket

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql-pr/protocol.rb

Overview

Authentication packet

Class Method Summary collapse

Class Method Details

.serialize(client_flags, max_packet_size, charset_number, username, scrambled_password, databasename, auth_plugin_name = nil) ⇒ Object



922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
# File 'lib/mysql-pr/protocol.rb', line 922

def self.serialize(client_flags, max_packet_size, charset_number, username, scrambled_password, databasename,
                   auth_plugin_name = nil)
  packet = [
    client_flags,
    max_packet_size,
    charset_number,
    "" # reserved 23 bytes
  ].pack("VVCa23")

  packet << "#{username}\x00"
  packet << Packet.lcs(scrambled_password)
  packet << "#{databasename}\x00" if databasename && (client_flags & MysqlPR::CLIENT_CONNECT_WITH_DB) != 0
  packet << "#{auth_plugin_name}\x00" if auth_plugin_name && (client_flags & MysqlPR::CLIENT_PLUGIN_AUTH) != 0

  packet
end