1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plasma Driver MySQL component |
4
|
|
|
* Copyright 2018-2019 PlasmaPHP, All Rights Reserved |
5
|
|
|
* |
6
|
|
|
* Website: https://github.com/PlasmaPHP |
7
|
|
|
* License: https://github.com/PlasmaPHP/driver-mysql/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Plasma\Drivers\MySQL\Messages; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Represents an Auth More Data Message. |
14
|
|
|
*/ |
15
|
|
|
class AuthMoreDataMessage implements \Plasma\Drivers\MySQL\Messages\MessageInterface { |
16
|
|
|
/** |
17
|
|
|
* @var string|null |
18
|
|
|
*/ |
19
|
|
|
public $authPluginData; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var \Plasma\Drivers\MySQL\ProtocolParser |
23
|
|
|
* @internal |
24
|
|
|
*/ |
25
|
|
|
protected $parser; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Constructor. |
29
|
|
|
* @param \Plasma\Drivers\MySQL\ProtocolParser $parser |
30
|
|
|
* @internal |
31
|
|
|
*/ |
32
|
5 |
|
function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser) { |
33
|
5 |
|
$this->parser = $parser; |
34
|
5 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get the identifier for the packet. |
38
|
|
|
* @return string |
39
|
|
|
* @internal |
40
|
|
|
*/ |
41
|
1 |
|
static function getID(): string { |
42
|
1 |
|
return "\x01"; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Parses the message, once the complete string has been received. |
47
|
|
|
* Returns false if not enough data has been received, or the remaining buffer. |
48
|
|
|
* @param \Plasma\BinaryBuffer $buffer |
49
|
|
|
* @return bool |
50
|
|
|
* @throws \Plasma\Drivers\MySQL\Messages\ParseException |
51
|
|
|
* @internal |
52
|
|
|
*/ |
53
|
1 |
|
function parseMessage(\Plasma\BinaryBuffer $buffer): bool { |
54
|
1 |
|
$this->authPluginData = $buffer->getContents(); |
55
|
1 |
|
$buffer->clear(); |
56
|
|
|
|
57
|
1 |
|
return true; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get the parser which created this message. |
62
|
|
|
* @return \Plasma\Drivers\MySQL\ProtocolParser |
63
|
|
|
* @internal |
64
|
|
|
*/ |
65
|
1 |
|
function getParser(): \Plasma\Drivers\MySQL\ProtocolParser { |
66
|
1 |
|
return $this->parser; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Sets the parser state, if necessary. If not, return `-1`. |
71
|
|
|
* @return int |
72
|
|
|
* @internal |
73
|
|
|
*/ |
74
|
1 |
|
function setParserState(): int { |
75
|
1 |
|
return \Plasma\Drivers\MySQL\ProtocolParser::STATE_AUTH; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|