GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bf6976...0e8096 )
by Charlotte
03:40
created

AuthSecureConnection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getHandshakeAuth() 0 9 2
A receiveMoreData() 0 2 1
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\AuthPlugins;
11
12
/**
13
 * Defines the interface for auth plugins.
14
 * @internal
15
 */
16
class AuthSecureConnection implements AuthPluginInterface {
17
    /**
18
     * @var \Plasma\Drivers\MySQL\ProtocolParser
19
     */
20
    protected $parser;
21
    
22
    /**
23
     * @var \Plasma\Drivers\MySQL\Messages\HandshakeMessage
24
     */
25
    protected $handshake;
26
    
27
    /**
28
     * Constructor. Receives the protocol parser and the handshake message.
29
     * @param \Plasma\Drivers\MySQL\ProtocolParser             $parser
30
     * @param \Plasma\Drivers\MySQL\Messages\HandshakeMessage  $handshake
31
     */
32 15
    function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser, \Plasma\Drivers\MySQL\Messages\HandshakeMessage $handshake) {
33 15
        $this->parser = $parser;
34 15
        $this->handshake = $handshake;
35 15
    }
36
37
    /**
38
     * Computes the auth response, including the length, for the handshake response.
39
     * @param string  $password
40
     * @return string
41
     */
42 14
    function getHandshakeAuth(string $password): string {
43 14
        if($password !== '') {
44 2
            $hash = \sha1($password, true);
45 2
            $str = $hash ^ \sha1($this->handshake->scramble.\sha1($hash, true), true);
46
            
47 2
            return \Plasma\BinaryBuffer::writeStringLength($str);
48
        }
49
        
50 12
        return "\x00";
51
    }
52
    
53
    /**
54
     * We received more auth data, so we send it into the auth plugin.
55
     * @param \Plasma\Drivers\MySQL\Messages\AuthMoreDataMessage  $message
56
     * @return \Plasma\Drivers\MySQL\Commands\CommandInterface
57
     * @throws \Plasma\Exception
58
     */
59 1
    function receiveMoreData(\Plasma\Drivers\MySQL\Messages\AuthMoreDataMessage $message): \Plasma\Drivers\MySQL\Commands\CommandInterface {
60 1
        throw new \Plasma\Exception('Auth plugin does not support auth more data');
61
    }
62
}
63