1 | <?php |
||
17 | class Configuration |
||
18 | { |
||
19 | const AUTH_BY_PASSWORD = 0; |
||
20 | const AUTH_BY_CONFIG = 1; |
||
21 | const AUTH_BY_IDENTITY_FILE = 2; |
||
22 | const AUTH_BY_PEM_FILE = 3; |
||
23 | const AUTH_BY_AGENT = 4; |
||
24 | const AUTH_BY_IDENTITY_FILE_AND_PASSWORD = 5; |
||
25 | |||
26 | /** |
||
27 | * Type of authentication. |
||
28 | * By default try to connect via password authentication |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | private $authenticationMethod = self::AUTH_BY_PASSWORD; |
||
33 | |||
34 | /** |
||
35 | * Server name |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $name; |
||
40 | |||
41 | /** |
||
42 | * Server host. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $host; |
||
47 | |||
48 | /** |
||
49 | * Server port. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | private $port; |
||
54 | |||
55 | /** |
||
56 | * User of remote server. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $user; |
||
61 | |||
62 | /** |
||
63 | * Used for authentication with password. |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | private $password; |
||
68 | |||
69 | /** |
||
70 | * Used for authentication with config file. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $configFile; |
||
75 | |||
76 | /** |
||
77 | * Used for authentication with public key. |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | private $publicKey; |
||
82 | |||
83 | /** |
||
84 | * Used for authentication with public key. |
||
85 | * |
||
86 | * @var string |
||
87 | */ |
||
88 | private $privateKey; |
||
89 | |||
90 | /** |
||
91 | * Used for authentication with public key. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | private $passPhrase; |
||
96 | |||
97 | /** |
||
98 | * Pem file. |
||
99 | * |
||
100 | * @var string |
||
101 | */ |
||
102 | private $pemFile; |
||
103 | |||
104 | /** |
||
105 | * Pty configuration |
||
106 | * |
||
107 | * @var mixed |
||
108 | */ |
||
109 | private $pty = null; |
||
110 | |||
111 | |||
112 | /** |
||
113 | * Construct |
||
114 | * |
||
115 | * @param string $name |
||
116 | * @param string $host |
||
117 | * @param int $port |
||
118 | */ |
||
119 | 23 | public function __construct($name, $host, $port = 22) |
|
125 | |||
126 | /** |
||
127 | * Get authentication method |
||
128 | * |
||
129 | * @return int |
||
130 | */ |
||
131 | 1 | public function getAuthenticationMethod() |
|
135 | |||
136 | /** |
||
137 | * Set authentication method |
||
138 | * |
||
139 | * @param int $authenticationMethod |
||
140 | * |
||
141 | * @return Configuration |
||
142 | */ |
||
143 | 2 | public function setAuthenticationMethod($authenticationMethod) |
|
149 | |||
150 | /** |
||
151 | * Get configuration file |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | public function getConfigFile() |
|
159 | |||
160 | /** |
||
161 | * Set configuration file |
||
162 | * |
||
163 | * @param string $configFile |
||
164 | * |
||
165 | * @return Configuration |
||
166 | */ |
||
167 | 1 | public function setConfigFile($configFile) |
|
173 | |||
174 | /** |
||
175 | * Get host for connection |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | 23 | public function getHost() |
|
183 | |||
184 | /** |
||
185 | * Set host for connection |
||
186 | * |
||
187 | * @param string $host |
||
188 | * |
||
189 | * @return Configuration |
||
190 | */ |
||
191 | 23 | public function setHost($host) |
|
197 | |||
198 | /** |
||
199 | * Get password for connection |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | 2 | public function getPassword() |
|
207 | |||
208 | /** |
||
209 | * Set password for connection |
||
210 | * |
||
211 | * @param string $password |
||
212 | * |
||
213 | * @return Configuration |
||
214 | */ |
||
215 | 3 | public function setPassword($password) |
|
221 | |||
222 | /** |
||
223 | * Get port |
||
224 | * |
||
225 | * @return int |
||
226 | */ |
||
227 | 21 | public function getPort() |
|
231 | |||
232 | /** |
||
233 | * Set port for connection |
||
234 | * |
||
235 | * @param int $port |
||
236 | * |
||
237 | * @return Configuration |
||
238 | */ |
||
239 | 23 | public function setPort($port) |
|
245 | |||
246 | /** |
||
247 | * Get public key |
||
248 | * |
||
249 | * @return string |
||
250 | */ |
||
251 | 1 | public function getPublicKey() |
|
255 | |||
256 | /** |
||
257 | * Set public key |
||
258 | * |
||
259 | * @param string $path |
||
260 | * |
||
261 | * @return Configuration |
||
262 | */ |
||
263 | 2 | public function setPublicKey($path) |
|
269 | |||
270 | /** |
||
271 | * Get pass phrase |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | 2 | public function getPassPhrase() |
|
279 | |||
280 | /** |
||
281 | * Set pass phrase |
||
282 | * |
||
283 | * @param string $passPhrase |
||
284 | * |
||
285 | * @return Configuration |
||
286 | */ |
||
287 | 3 | public function setPassPhrase($passPhrase) |
|
293 | |||
294 | /** |
||
295 | * Get private key |
||
296 | * |
||
297 | * @return string |
||
298 | */ |
||
299 | 1 | public function getPrivateKey() |
|
303 | |||
304 | /** |
||
305 | * Set private key |
||
306 | * |
||
307 | * @param string $path |
||
308 | * |
||
309 | * @return Configuration |
||
310 | */ |
||
311 | 2 | public function setPrivateKey($path) |
|
317 | |||
318 | /** |
||
319 | * Get user |
||
320 | * |
||
321 | * @return string |
||
322 | */ |
||
323 | 3 | public function getUser() |
|
327 | |||
328 | /** |
||
329 | * Set user |
||
330 | * |
||
331 | * @param string $user |
||
332 | * |
||
333 | * @return Configuration |
||
334 | */ |
||
335 | 4 | public function setUser($user) |
|
341 | |||
342 | /** |
||
343 | * Get name |
||
344 | * |
||
345 | * @return string |
||
346 | */ |
||
347 | 21 | public function getName() |
|
351 | |||
352 | /** |
||
353 | * Set name |
||
354 | * |
||
355 | * @param string $name |
||
356 | * |
||
357 | * @return Configuration |
||
358 | */ |
||
359 | 23 | public function setName($name) |
|
365 | |||
366 | /** |
||
367 | * Get pem file |
||
368 | * |
||
369 | * @return string |
||
370 | */ |
||
371 | 1 | public function getPemFile() |
|
375 | |||
376 | /** |
||
377 | * To auth with pem file use pemFile() method instead of this. |
||
378 | * |
||
379 | * @param string $pemFile |
||
380 | * |
||
381 | * @return Configuration |
||
382 | */ |
||
383 | 1 | public function setPemFile($pemFile) |
|
389 | |||
390 | /** |
||
391 | * Parse "~" symbol from path. |
||
392 | * |
||
393 | * @param string $path |
||
394 | * |
||
395 | * @return string |
||
396 | */ |
||
397 | 2 | private function parseHome($path) |
|
407 | |||
408 | /** |
||
409 | * Get real password |
||
410 | * |
||
411 | * @param mixed $password |
||
412 | * |
||
413 | * @return string |
||
414 | */ |
||
415 | 3 | private function getRealPassword($password) |
|
423 | |||
424 | /** |
||
425 | * Set pty |
||
426 | * |
||
427 | * @param $pty |
||
428 | */ |
||
429 | public function setPty($pty) |
||
433 | |||
434 | /** |
||
435 | * Get pty option |
||
436 | * |
||
437 | * @return mixed |
||
438 | */ |
||
439 | public function getPty() |
||
443 | |||
444 | /** |
||
445 | * Set pty for ssh2 connection. For retro compatibility |
||
446 | * |
||
447 | * @param $ssh2Pty |
||
448 | * @deprecated |
||
449 | */ |
||
450 | public function setSsh2Pty($ssh2Pty) |
||
454 | |||
455 | /** |
||
456 | * Get pty option for ssh2 connection. For retro compatibility |
||
457 | * |
||
458 | * @deprecated |
||
459 | * @return mixed |
||
460 | */ |
||
461 | public function getSsh2Pty() |
||
465 | } |
||
466 |