HandshakeResponse extends Packet { public static HandshakeResponse loadFromPacket(byte[] packet) { HandshakeResponse obj = new HandshakeResponse(); Proto proto = new Proto(packet, 3); obj.sequenceId = proto.get_fixed_int(1); obj.capabilityFlags = proto.get_fixed_int(2); proto.offset -= 2; if (obj.hasCapabilityFlag(Flags.CLIENT_PROTOCOL_41)) { obj.capabilityFlags = proto.get_fixed_int(4); obj.maxPacketSize = proto.get_fixed_int(4); obj.characterSet = proto.get_fixed_int(1); proto.get_filler(23); obj.username = proto.get_null_str(); if (obj.hasCapabilityFlag(Flags.CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA)) { obj.authResponseLen = proto.get_lenenc_int(); obj.authResponse = proto.get_fixed_str(obj.authResponseLen, true); } else { if (obj.hasCapabilityFlag(Flags.CLIENT_SECURE_CONNECTION)) { obj.authResponseLen = proto.get_fixed_int(1); obj.authResponse = proto.get_fixed_str(obj.authResponseLen, true); } else { obj.authResponse = proto.get_null_str(); } } if (obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_WITH_DB)) obj.schema = proto.get_null_str(); if (obj.hasCapabilityFlag(Flags.CLIENT_PLUGIN_AUTH)) obj.pluginName = proto.get_null_str(); if (obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_ATTRS)) { obj.clientAttributesLen = proto.get_lenenc_int(); obj.clientAttributes = proto.get_eop_str(); } } else { obj.capabilityFlags = proto.get_fixed_int(2); obj.maxPacketSize = proto.get_fixed_int(3); obj.username = proto.get_null_str(); if (obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_WITH_DB)) { obj.authResponse = proto.get_null_str(); obj.schema = proto.get_null_str(); } else obj.authResponse = proto.get_eop_str(); } return obj; }  void setCapabilityFlag(long flag); void removeCapabilityFlag(long flag); void toggleCapabilityFlag(long flag); boolean hasCapabilityFlag(long flag); ArrayList<byte[]> getPayload(); static HandshakeResponse loadFromPacket(byte[] packet); public long capabilityFlags; public long maxPacketSize; public long characterSet; public String username; public long authResponseLen; public String authResponse; public String schema; public String pluginName; public long clientAttributesLen; public String clientAttributes; }
@Test public void test_1() { byte[] packet = new byte[] { (byte)0x2f, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x0d, (byte)0xa6, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x72, (byte)0x6f, (byte)0x6f, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x62, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x68, (byte)0x00 }; assertArrayEquals(packet, HandshakeResponse.loadFromPacket(packet).toPacket()); }
@Test public void test_5_5_8() { byte[] packet = new byte[] { (byte)0x54, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x8d, (byte)0xa6, (byte)0x0f, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x70, (byte)0x61, (byte)0x6d, (byte)0x00, (byte)0x14, (byte)0xab, (byte)0x09, (byte)0xee, (byte)0xf6, (byte)0xbc, (byte)0xb1, (byte)0x32, (byte)0x3e, (byte)0x61, (byte)0x14, (byte)0x38, (byte)0x65, (byte)0xc0, (byte)0x99, (byte)0x1d, (byte)0x95, (byte)0x7d, (byte)0x75, (byte)0xd4, (byte)0x47, (byte)0x74, (byte)0x65, (byte)0x73, (byte)0x74, (byte)0x00, (byte)0x6d, (byte)0x79, (byte)0x73, (byte)0x71, (byte)0x6c, (byte)0x5f, (byte)0x6e, (byte)0x61, (byte)0x74, (byte)0x69, (byte)0x76, (byte)0x65, (byte)0x5f, (byte)0x70, (byte)0x61, (byte)0x73, (byte)0x73, (byte)0x77, (byte)0x6f, (byte)0x72, (byte)0x64, (byte)0x00, }; assertArrayEquals(packet, HandshakeResponse.loadFromPacket(packet).toPacket()); }
@Test public void test_5_6_6() { byte[] packet = new byte[] { (byte)0xb2, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x85, (byte)0xa2, (byte)0x1e, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x40, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x72, (byte)0x6f, (byte)0x6f, (byte)0x74, (byte)0x00, (byte)0x14, (byte)0x22, (byte)0x50, (byte)0x79, (byte)0xa2, (byte)0x12, (byte)0xd4, (byte)0xe8, (byte)0x82, (byte)0xe5, (byte)0xb3, (byte)0xf4, (byte)0x1a, (byte)0x97, (byte)0x75, (byte)0x6b, (byte)0xc8, (byte)0xbe, (byte)0xdb, (byte)0x9f, (byte)0x80, (byte)0x6d, (byte)0x79, (byte)0x73, (byte)0x71, (byte)0x6c, (byte)0x5f, (byte)0x6e, (byte)0x61, (byte)0x74, (byte)0x69, (byte)0x76, (byte)0x65, (byte)0x5f, (byte)0x70, (byte)0x61, (byte)0x73, (byte)0x73, (byte)0x77, (byte)0x6f, (byte)0x72, (byte)0x64, (byte)0x00, (byte)0x61, (byte)0x03, (byte)0x5f, (byte)0x6f, (byte)0x73, (byte)0x09, (byte)0x64, (byte)0x65, (byte)0x62, (byte)0x69, (byte)0x61, (byte)0x6e, (byte)0x36, (byte)0x2e, (byte)0x30, (byte)0x0c, (byte)0x5f, (byte)0x63, (byte)0x6c, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x74, (byte)0x5f, (byte)0x6e, (byte)0x61, (byte)0x6d, (byte)0x65, (byte)0x08, (byte)0x6c, (byte)0x69, (byte)0x62, (byte)0x6d, (byte)0x79, (byte)0x73, (byte)0x71, (byte)0x6c, (byte)0x04, (byte)0x5f, (byte)0x70, (byte)0x69, (byte)0x64, (byte)0x05, (byte)0x32, (byte)0x32, (byte)0x33, (byte)0x34, (byte)0x34, (byte)0x0f, (byte)0x5f, (byte)0x63, (byte)0x6c, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x74, (byte)0x5f, (byte)0x76, (byte)0x65, (byte)0x72, (byte)0x73, (byte)0x69, (byte)0x6f, (byte)0x6e, (byte)0x08, (byte)0x35, (byte)0x2e, (byte)0x36, (byte)0x2e, (byte)0x36, (byte)0x2d, (byte)0x6d, (byte)0x39, (byte)0x09, (byte)0x5f, (byte)0x70, (byte)0x6c, (byte)0x61, (byte)0x74, (byte)0x66, (byte)0x6f, (byte)0x72, (byte)0x6d, (byte)0x06, (byte)0x78, (byte)0x38, (byte)0x36, (byte)0x5f, (byte)0x36, (byte)0x34, (byte)0x03, (byte)0x66, (byte)0x6f, (byte)0x6f, (byte)0x03, (byte)0x62, (byte)0x61, (byte)0x72 }; assertArrayEquals(packet, HandshakeResponse.loadFromPacket(packet).toPacket()); }
@Test public void test_3_2_0() { byte[] packet = new byte[] { (byte)0x11, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x85, (byte)0x24, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x6f, (byte)0x6c, (byte)0x64, (byte)0x00, (byte)0x47, (byte)0x44, (byte)0x53, (byte)0x43, (byte)0x51, (byte)0x59, (byte)0x52, (byte)0x5f }; assertArrayEquals(packet, HandshakeResponse.loadFromPacket(packet).toPacket()); }