|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Sasl library. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2002-2003 Richard Heyes, |
|
9
|
|
|
* 2014-2025 Fabian Grutschus |
|
10
|
|
|
* All rights reserved. |
|
11
|
|
|
* |
|
12
|
|
|
* Redistribution and use in source and binary forms, with or without |
|
13
|
|
|
* modification, are permitted provided that the following conditions |
|
14
|
|
|
* are met: |
|
15
|
|
|
* |
|
16
|
|
|
* o Redistributions of source code must retain the above copyright |
|
17
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
18
|
|
|
* o Redistributions in binary form must reproduce the above copyright |
|
19
|
|
|
* notice, this list of conditions and the following disclaimer in the |
|
20
|
|
|
* documentation and/or other materials provided with the distribution.| |
|
21
|
|
|
* o The names of the authors may not be used to endorse or promote |
|
22
|
|
|
* products derived from this software without specific prior written |
|
23
|
|
|
* permission. |
|
24
|
|
|
* |
|
25
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
26
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
27
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
28
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
29
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
30
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
31
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
32
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
33
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
34
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
35
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
36
|
|
|
* |
|
37
|
|
|
* @author Fabian Grutschus <[email protected]> |
|
38
|
|
|
*/ |
|
39
|
|
|
|
|
40
|
|
|
namespace Fabiang\SASL; |
|
41
|
|
|
|
|
42
|
|
|
use Fabiang\SASL\Options\DowngradeProtectionOptions; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Options object for Sasl. |
|
46
|
|
|
* |
|
47
|
|
|
* @author Fabian Grutschus <[email protected]> |
|
48
|
|
|
*/ |
|
49
|
|
|
class Options |
|
50
|
|
|
{ |
|
51
|
|
|
/** |
|
52
|
|
|
* Constructor. |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $authcid authentication identity (e.g. username) |
|
55
|
|
|
* @param string $secret authentication secret (e.g. password) |
|
56
|
|
|
* @param string $authzid authorization identity (username to proxy as) |
|
57
|
|
|
* @param string $service service name |
|
58
|
|
|
* @param string $hostname service hostname |
|
59
|
|
|
* @param DowngradeProtectionOptions $downgradeProtection Options for SCRAM-SHA*'s downgrade protection |
|
60
|
|
|
*/ |
|
61
|
|
|
public function __construct( |
|
62
|
|
|
protected ?string $authcid = null, |
|
63
|
|
|
#[\SensitiveParameter] |
|
64
|
|
|
protected ?string $secret = null, |
|
65
|
|
|
protected ?string $authzid = null, |
|
66
|
|
|
protected ?string $service = null, |
|
67
|
|
|
protected ?string $hostname = null, |
|
68
|
|
|
protected ?DowngradeProtectionOptions $downgradeProtection = null |
|
69
|
|
|
) { |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getAuthcid(): ?string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->authcid; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function getSecret(): ?string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->secret; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getAuthzid(): ?string |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->authzid; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getService(): ?string |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->service; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getHostname(): ?string |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->hostname; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getDowngradeProtection(): ?DowngradeProtectionOptions |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->downgradeProtection; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function toArray(): array |
|
103
|
|
|
{ |
|
104
|
|
|
return [ |
|
105
|
|
|
'authcid' => $this->getAuthcid(), |
|
106
|
|
|
'secret' => $this->getSecret(), |
|
107
|
|
|
'authzid' => $this->getAuthzid(), |
|
108
|
|
|
'service' => $this->getService(), |
|
109
|
|
|
'hostname' => $this->getHostname(), |
|
110
|
|
|
]; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|