|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the core-library package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Library\Core\Security; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Library\Core\Model\Attribute\IntegerPortTrait; |
|
15
|
|
|
use WBW\Library\Core\Model\Attribute\StringHostnameTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Authenticator. |
|
19
|
|
|
* |
|
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
21
|
|
|
* @package WBW\Library\Core\Security |
|
22
|
|
|
*/ |
|
23
|
|
|
class Authenticator { |
|
24
|
|
|
|
|
25
|
|
|
use IntegerPortTrait; |
|
26
|
|
|
use StringHostnameTrait; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Password authentication. |
|
30
|
|
|
* |
|
31
|
|
|
* @var PasswordAuthentication |
|
32
|
|
|
*/ |
|
33
|
|
|
private $passwordAuthentication; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Scheme. |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $scheme; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Constructor. |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $host The host. |
|
46
|
|
|
* @param PasswordAuthentication $passwordAuthentication |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct($host, PasswordAuthentication $passwordAuthentication) { |
|
49
|
|
|
$this->host = $host; |
|
|
|
|
|
|
50
|
|
|
$this->passwordAuthentication = $passwordAuthentication; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get the password authentication. |
|
55
|
|
|
* |
|
56
|
|
|
* @return PasswordAuthentication Returns this password authentication. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getPasswordAuthentication() { |
|
59
|
|
|
return $this->passwordAuthentication; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Get the scheme. |
|
64
|
|
|
* |
|
65
|
|
|
* @return string Returns the scheme. |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getScheme() { |
|
68
|
|
|
return $this->scheme; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Set the password authenticator. |
|
73
|
|
|
* |
|
74
|
|
|
* @param PasswordAuthentication $passwordAuthentication The password authentication. |
|
75
|
|
|
* @return Authenticator Returns this authenticator. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setPasswordAuthentication(PasswordAuthentication $passwordAuthentication) { |
|
78
|
|
|
$this->passwordAuthentication = $passwordAuthentication; |
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Set the scheme. |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $scheme The scheme. |
|
86
|
|
|
* @return Authenticator Returns this authenticator. |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setScheme($scheme) { |
|
89
|
|
|
$this->scheme = $scheme; |
|
90
|
|
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: