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