Passed
Pull Request — 3.0 (#1115)
by
unknown
04:22
created

LdapParams::setServer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
8
 *
9
 * This file is part of sysPass.
10
 *
11
 * sysPass is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * sysPass is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 *  along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
namespace SP\Providers\Auth\Ldap;
26
27
/**
28
 * Class LdapParams
29
 *
30
 * @package SP\Providers\Auth\Ldap
31
 */
32
final class LdapParams
33
{
34
    const REGEX_SERVER = '(?<server>(?:(?<proto>ldap|ldaps):\/\/)?[\w\.\-]+)(?::(?<port>\d+))?';
35
36
    /**
37
     * @var string
38
     */
39
    protected $server;
40
    /**
41
     * @var int
42
     */
43
    protected $port = 389;
44
    /**
45
     * @var string
46
     */
47
    protected $searchBase;
48
    /**
49
     * @var string
50
     */
51
    protected $bindDn;
52
    /**
53
     * @var string
54
     */
55
    protected $bindPass;
56
    /**
57
     * @var string
58
     */
59
    protected $group;
60
    /**
61
     * @var bool
62
     */
63
    protected $ads = false;
64
    /**
65
     * @var bool
66
     */
67
    protected $azure = false;
68
    /**
69
     * @var bool
70
     */
71
    protected $tlsEnabled = false;
72
73
    /**
74
     * Devolver el puerto del servidor si está establecido
75
     *
76
     * @param $server
77
     *
78
     * @return array|false
79
     */
80
    public static function getServerAndPort($server)
81
    {
82
        return preg_match('#' . self::REGEX_SERVER . '#i', $server, $matches) ? $matches : false;
83
    }
84
85
    /**
86
     * @return int
87
     */
88
    public function getPort()
89
    {
90
        return $this->port;
91
    }
92
93
    /**
94
     * @param int $port
95
     *
96
     * @return LdapParams
97
     */
98
    public function setPort($port)
99
    {
100
        $this->port = $port;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getSearchBase()
109
    {
110
        return $this->searchBase;
111
    }
112
113
    /**
114
     * @param string $searchBase
115
     *
116
     * @return LdapParams
117
     */
118
    public function setSearchBase($searchBase)
119
    {
120
        $this->searchBase = $searchBase;
121
        return $this;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getBindDn()
128
    {
129
        return $this->bindDn;
130
    }
131
132
    /**
133
     * @param string $bindDn
134
     *
135
     * @return LdapParams
136
     */
137
    public function setBindDn($bindDn)
138
    {
139
        $this->bindDn = $bindDn;
140
        return $this;
141
    }
142
143
    /**
144
     * @return string
145
     */
146
    public function getBindPass()
147
    {
148
        return $this->bindPass;
149
    }
150
151
    /**
152
     * @param string $bindPass
153
     *
154
     * @return LdapParams
155
     */
156
    public function setBindPass($bindPass)
157
    {
158
        $this->bindPass = $bindPass;
159
        return $this;
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    public function getGroup()
166
    {
167
        return $this->group;
168
    }
169
170
    /**
171
     * @param string $group
172
     *
173
     * @return LdapParams
174
     */
175
    public function setGroup($group)
176
    {
177
        $this->group = $group;
178
        return $this;
179
    }
180
181
    /**
182
     * @return string
183
     */
184
    public function getServer()
185
    {
186
        return $this->server;
187
    }
188
189
    /**
190
     * @param string $server
191
     *
192
     * @return LdapParams
193
     */
194
    public function setServer($server)
195
    {
196
        $this->server = $server;
197
198
        return $this;
199
    }
200
201
    /**
202
     * @return bool
203
     */
204
    public function isAds()
205
    {
206
        return $this->ads;
207
    }
208
209
    /**
210
     * @param bool $ads
211
     *
212
     * @return LdapParams
213
     */
214
    public function setAds($ads)
215
    {
216
        $this->ads = (bool)$ads;
217
218
        return $this;
219
    }
220
221
    /**
222
     * @return bool
223
     */
224
    public function isAzure()
225
    {
226
        return $this->azure;
227
    }
228
229
    /**
230
     * @param bool $azure
231
     *
232
     * @return LdapParams
233
     */
234
    public function setAzure($azure)
235
    {
236
        $this->azure= (bool)$azure;
237
238
        return $this;
239
    }
240
241
    /**
242
     * @return bool
243
     */
244
    public function isTlsEnabled(): bool
245
    {
246
        return $this->tlsEnabled;
247
    }
248
249
    /**
250
     * @param bool $tlsEnabled
251
     *
252
     * @return LdapParams
253
     */
254
    public function setTlsEnabled(bool $tlsEnabled)
255
    {
256
        $this->tlsEnabled = $tlsEnabled;
257
258
        return $this;
259
    }
260
261
}
262