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