This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Checkdomain\Comodo; |
||
3 | |||
4 | use Checkdomain\Comodo\Model\Exception\AccountException; |
||
5 | use Checkdomain\Comodo\Model\Exception\ArgumentException; |
||
6 | use Checkdomain\Comodo\Model\Exception\CSRException; |
||
7 | use Checkdomain\Comodo\Model\Exception\RequestException; |
||
8 | use Checkdomain\Comodo\Model\Exception\UnknownApiException; |
||
9 | use Checkdomain\Comodo\Model\Exception\UnknownException; |
||
10 | |||
11 | use Checkdomain\Comodo\Model\Result\AutoApplyResult; |
||
12 | use Checkdomain\Comodo\Model\Result\AutoReplaceResult; |
||
13 | use Checkdomain\Comodo\Model\Result\CollectSslResult; |
||
14 | use Checkdomain\Comodo\Model\Result\GetDCVEMailAddressListResult; |
||
15 | use Checkdomain\Comodo\Model\Result\GetMDCDomainDetailsResult; |
||
16 | use Checkdomain\Comodo\Model\Result\UpdateUserEvClickThroughResult; |
||
17 | use Checkdomain\Comodo\Model\Result\SslCheckerResult; |
||
18 | use Checkdomain\Comodo\Model\Result\WebHostReportResult; |
||
19 | |||
20 | /** |
||
21 | * Class Util |
||
22 | * Provides functions to communicate with the Comodo API,requires an Account object, given to the Communication-adapter |
||
23 | */ |
||
24 | class Util |
||
25 | { |
||
26 | const AUTO_REFUND_REASON_VALIDATION = 1; |
||
27 | const AUTO_REFUND_REASON_INACTIVE = 2; |
||
28 | const AUTO_REFUND_REASON_TYPE = 3; |
||
29 | const AUTO_REFUND_REASON_BRAND = 4; |
||
30 | const AUTO_REFUND_REASON_REJECTED = 5; |
||
31 | const AUTO_REFUND_REASON_MALWARE = 6; |
||
32 | const AUTO_REFUND_REASON_PHISHING = 7; |
||
33 | const AUTO_REFUND_REASON_SAFE_BROWSING = 8; |
||
34 | const AUTO_REFUND_REASON_AUTHORITY = 9; |
||
35 | const AUTO_REFUND_REASON_PRICE = 10; |
||
36 | const AUTO_REFUND_REASON_OTHER = 11; |
||
37 | |||
38 | const COMODO_AUTO_REFUND_URL = 'https://secure.trust-provider.com/products/!AutoRefund'; |
||
39 | const COMODO_AUTO_APPLY_URL = 'https://secure.trust-provider.com/products/!AutoApplySSL'; |
||
40 | const COMODO_AUTO_REVOKE_URL = 'https://secure.trust-provider.com/products/!AutoRevokeSSL'; |
||
41 | const COMODO_DCV_MAIL_URL = 'https://secure.trust-provider.com/products/!GetDCVEmailAddressList'; |
||
42 | const COMODO_DCV_RESEND_URL = 'https://secure.trust-provider.com/products/!ResendDCVEmail'; |
||
43 | const COMODO_AUTO_UPDATE_DCV_URL = 'https://secure.trust-provider.com/products/!AutoUpdateDCV'; |
||
44 | const COMODO_PROVIDE_EV_DETAILS_URL = 'https://secure.trust-provider.com/products/!ProvideEVDetails'; |
||
45 | const COMODO_MDC_DOMAIN_DETAILS_URL = 'https://secure.trust-provider.com/products/!GetMDCDomainDetails'; |
||
46 | const COMODO_AUTO_REPLACE_URL = 'https://secure.trust-provider.com/products/!AutoReplaceSSL'; |
||
47 | const COMODO_COLLECT_SSL_URL = 'https://secure.trust-provider.com/products/download/CollectSSL'; |
||
48 | const COMODO_UPDATE_USER_EV_CLICK_THROUGH = 'https://secure.trust-provider.com/products/!UpdateUserEvClickThrough'; |
||
49 | const COMODO_WEB_HOST_REPORT = 'https://secure.trust-provider.com/products/!WebHostReport'; |
||
50 | const COMODO_SSLCHECKER = 'https://secure.trust-provider.com/sslchecker'; |
||
51 | const COMODO_DCV_CODE_URL = 'https://secure.trust-provider.com/products/EnterDCVCode2'; |
||
52 | |||
53 | /** |
||
54 | * @var CommunicationAdapter |
||
55 | */ |
||
56 | protected $communicationAdapter; |
||
57 | |||
58 | /** |
||
59 | * @var ImapAdapter |
||
60 | */ |
||
61 | protected $imapAdapter; |
||
62 | |||
63 | /** |
||
64 | * @var ImapHelper |
||
65 | */ |
||
66 | protected $imapHelper; |
||
67 | |||
68 | /** |
||
69 | * Constructs the Util with a communicationAdapter |
||
70 | * |
||
71 | * @param CommunicationAdapter|null $communicationAdapter |
||
72 | * @param ImapAdapter|null $imapAdapter |
||
73 | * @param ImapHelper|null $imapHelper |
||
74 | */ |
||
75 | public function __construct(CommunicationAdapter $communicationAdapter, ImapAdapter $imapAdapter, ImapHelper $imapHelper) |
||
76 | { |
||
77 | $this->communicationAdapter = $communicationAdapter; |
||
78 | $this->imapAdapter = $imapAdapter; |
||
79 | $this->imapHelper = $imapHelper; |
||
80 | } |
||
81 | |||
82 | |||
83 | /** |
||
84 | * @return CommunicationAdapter |
||
85 | */ |
||
86 | public function getCommunicationAdapter() |
||
87 | { |
||
88 | return $this->communicationAdapter; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param CommunicationAdapter $communicationAdapter |
||
93 | * |
||
94 | * @return Util |
||
95 | */ |
||
96 | public function setCommunicationAdapter(CommunicationAdapter $communicationAdapter) |
||
97 | { |
||
98 | $this->communicationAdapter = $communicationAdapter; |
||
99 | |||
100 | return $this; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @return ImapHelper |
||
105 | */ |
||
106 | public function getImapHelper() |
||
107 | { |
||
108 | return $this->imapHelper; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @param ImapHelper $imapHelper |
||
113 | * |
||
114 | * @return Util |
||
115 | */ |
||
116 | public function setImapHelper(ImapHelper $imapHelper) |
||
117 | { |
||
118 | $this->imapHelper = $imapHelper; |
||
119 | |||
120 | return $this; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @return ImapAdapter |
||
125 | */ |
||
126 | public function getImapAdapter() |
||
127 | { |
||
128 | return $this->imapAdapter; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param ImapAdapter $imapAdapter |
||
133 | * |
||
134 | * @return Util |
||
135 | */ |
||
136 | public function setImapAdapter(ImapAdapter $imapAdapter) |
||
137 | { |
||
138 | $this->imapAdapter = $imapAdapter; |
||
139 | |||
140 | return $this; |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Refunds a ordered certificate |
||
145 | * |
||
146 | * @param array $params |
||
147 | * |
||
148 | * @return bool |
||
149 | * |
||
150 | * @throws AccountException |
||
151 | * @throws ArgumentException |
||
152 | * @throws CSRException |
||
153 | * @throws RequestException |
||
154 | * @throws UnknownApiException |
||
155 | * @throws UnknownException |
||
156 | */ |
||
157 | public function autoRefund(array $params) |
||
158 | { |
||
159 | if (false === isset($params['refundReasonCode'])) { |
||
160 | $params['refundReasonCode'] = self::AUTO_REFUND_REASON_OTHER; |
||
161 | } |
||
162 | |||
163 | $response = $this |
||
164 | ->communicationAdapter |
||
165 | ->sendToApi( |
||
166 | self::COMODO_AUTO_REFUND_URL, |
||
167 | $params, |
||
168 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
169 | ); |
||
170 | |||
171 | if ($response['errorCode'] == 0) { |
||
172 | return true; |
||
173 | } else { |
||
174 | throw $this->createException($response); |
||
175 | } |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Function apply for a certificate |
||
180 | * |
||
181 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
182 | * |
||
183 | * @param array $params |
||
184 | * |
||
185 | * @return AutoApplyResult |
||
186 | * @throws Model\Exception\AccountException |
||
187 | * @throws Model\Exception\ArgumentException |
||
188 | * @throws Model\Exception\CSRException |
||
189 | * @throws Model\Exception\RequestException |
||
190 | * @throws Model\Exception\UnknownApiException |
||
191 | * @throws Model\Exception\UnknownException |
||
192 | */ |
||
193 | public function autoApplySSL(array $params) |
||
194 | { |
||
195 | // Two choices, we want url-encoded |
||
196 | $params['responseFormat'] = CommunicationAdapter::RESPONSE_URL_ENCODED; |
||
197 | $params['showCertificateID'] = 'Y'; |
||
198 | |||
199 | // Send request |
||
200 | $arr = $this |
||
201 | ->communicationAdapter |
||
202 | ->sendToApi(self::COMODO_AUTO_APPLY_URL, $params, CommunicationAdapter::RESPONSE_URL_ENCODED); |
||
203 | |||
204 | // Successful |
||
205 | if ($arr['errorCode'] == 1 || $arr['errorCode'] == 0) { |
||
206 | $result = new AutoApplyResult(); |
||
207 | |||
208 | if ($arr['errorCode'] == 0) { |
||
209 | $paid = true; |
||
210 | } else { |
||
211 | $paid = false; |
||
212 | } |
||
213 | |||
214 | $result |
||
215 | ->setPaid($paid) |
||
216 | ->setCertificateID($arr['certificateID']) |
||
217 | ->setExpectedDeliveryTime($arr['expectedDeliveryTime']) |
||
218 | ->setOrderNumber($arr['orderNumber']) |
||
219 | ->setTotalCost($arr['totalCost']) |
||
220 | ->setRequestQuery($arr['requestQuery']); |
||
221 | |||
222 | if (isset($arr['uniqueValue'])) { |
||
223 | $result->setUniqueValue($arr['uniqueValue']); |
||
224 | } |
||
225 | |||
226 | return $result; |
||
227 | } else { |
||
228 | throw $this->createException($arr); |
||
229 | } |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * @param array $params |
||
234 | * |
||
235 | * @return UpdateUserEvClickThroughResult |
||
236 | * @throws AccountException |
||
237 | * @throws ArgumentException |
||
238 | * @throws CSRException |
||
239 | * @throws RequestException |
||
240 | * @throws UnknownApiException |
||
241 | * @throws UnknownException |
||
242 | */ |
||
243 | public function updateUserEvClickThrough(array $params) |
||
244 | { |
||
245 | // Send request |
||
246 | $arr = $this |
||
247 | ->communicationAdapter |
||
248 | ->sendToApi( |
||
249 | self::COMODO_UPDATE_USER_EV_CLICK_THROUGH, |
||
250 | $params, |
||
251 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
252 | ); |
||
253 | |||
254 | // Successful |
||
255 | if ($arr['errorCode'] == 0) { |
||
256 | $result = new UpdateUserEvClickThroughResult(); |
||
257 | |||
258 | $result |
||
259 | ->setStatus($arr['status']); |
||
260 | |||
261 | return $result; |
||
262 | } else { |
||
263 | throw $this->createException($arr); |
||
264 | } |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Function update for a certificate |
||
269 | * |
||
270 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
271 | * |
||
272 | * @param array $params |
||
273 | * |
||
274 | * @return AutoReplaceResult |
||
275 | * @throws Model\Exception\AccountException |
||
276 | * @throws Model\Exception\ArgumentException |
||
277 | * @throws Model\Exception\CSRException |
||
278 | * @throws Model\Exception\RequestException |
||
279 | * @throws Model\Exception\UnknownApiException |
||
280 | * @throws Model\Exception\UnknownException |
||
281 | */ |
||
282 | public function autoReplaceSSL(array $params) |
||
283 | { |
||
284 | // Two choices, we want url-encoded |
||
285 | $params['responseFormat'] = CommunicationAdapter::RESPONSE_URL_ENCODED; |
||
286 | |||
287 | // Send request |
||
288 | $arr = $this |
||
289 | ->communicationAdapter |
||
290 | ->sendToApi( |
||
291 | self::COMODO_AUTO_REPLACE_URL, |
||
292 | $params, |
||
293 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
294 | ); |
||
295 | |||
296 | // Successful |
||
297 | if ($arr['errorCode'] == 0) { |
||
298 | $result = new AutoReplaceResult(); |
||
299 | |||
300 | $result |
||
301 | ->setCertificateID($arr['certificateID']) |
||
302 | ->setExpectedDeliveryTime($arr['expectedDeliveryTime']); |
||
303 | |||
304 | if (isset($arr['uniqueValue'])) { |
||
305 | $result->setUniqueValue($arr['uniqueValue']); |
||
306 | } |
||
307 | |||
308 | return $result; |
||
309 | } else { |
||
310 | throw $this->createException($arr); |
||
311 | } |
||
312 | } |
||
313 | |||
314 | /** |
||
315 | * Function to revoke order |
||
316 | * |
||
317 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
318 | * |
||
319 | * @param array $params |
||
320 | * |
||
321 | * @return bool |
||
322 | * @throws Model\Exception\AccountException |
||
323 | * @throws Model\Exception\ArgumentException |
||
324 | * @throws Model\Exception\RequestException |
||
325 | * @throws Model\Exception\UnknownApiException |
||
326 | * @throws Model\Exception\UnknownException |
||
327 | */ |
||
328 | public function autoRevokeSSL(array $params) |
||
329 | { |
||
330 | // Two choices, we want url-encoded |
||
331 | $params['responseFormat'] = CommunicationAdapter::RESPONSE_URL_ENCODED; |
||
332 | |||
333 | return $this->sendBooleanRequest( |
||
334 | self::COMODO_AUTO_REVOKE_URL, |
||
335 | $params, |
||
336 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
337 | ); |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * Function to auto update dcv |
||
342 | * |
||
343 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
344 | * |
||
345 | * @param array $params |
||
346 | * |
||
347 | * @return bool |
||
348 | * @throws Model\Exception\AccountException |
||
349 | * @throws Model\Exception\ArgumentException |
||
350 | * @throws Model\Exception\RequestException |
||
351 | * @throws Model\Exception\UnknownApiException |
||
352 | * @throws Model\Exception\UnknownException |
||
353 | */ |
||
354 | public function autoUpdateDCV(array $params) |
||
355 | { |
||
356 | return $this->sendBooleanRequest( |
||
357 | self::COMODO_AUTO_UPDATE_DCV_URL, |
||
358 | $params, |
||
359 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
360 | ); |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * Function to get details of a certificate |
||
365 | * |
||
366 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
367 | * |
||
368 | * @param array $params |
||
369 | * |
||
370 | * @return CollectSslResult |
||
371 | * @throws Model\Exception\AccountException |
||
372 | * @throws Model\Exception\ArgumentException |
||
373 | * @throws Model\Exception\CSRException |
||
374 | * @throws Model\Exception\RequestException |
||
375 | * @throws Model\Exception\UnknownApiException |
||
376 | * @throws Model\Exception\UnknownException |
||
377 | */ |
||
378 | public function collectSsl(array $params) |
||
379 | { |
||
380 | // Not decode the following indexes |
||
381 | $notDecode = array('caCertificate', 'certificate', 'netscapeCertificateSequence', 'zipFile'); |
||
382 | |||
383 | // Force threating as array |
||
384 | $forceArray = array('caCertificate'); |
||
385 | |||
386 | // Two choices, we want url-encoded |
||
387 | $params['responseFormat'] = CommunicationAdapter::RESPONSE_URL_ENCODED; |
||
388 | |||
389 | // Send request |
||
390 | $arr = $this |
||
391 | ->communicationAdapter |
||
392 | ->sendToApi( |
||
393 | self::COMODO_COLLECT_SSL_URL, |
||
394 | $params, |
||
395 | CommunicationAdapter::RESPONSE_URL_ENCODED, |
||
396 | $notDecode, |
||
397 | $forceArray |
||
398 | ); |
||
399 | |||
400 | // Successful |
||
401 | if ($arr['errorCode'] >= 0) { |
||
402 | $result = new CollectSslResult(); |
||
403 | |||
404 | $this->fill($result, $arr, array('notBefore', 'notAfter')); |
||
0 ignored issues
–
show
|
|||
405 | |||
406 | /* |
||
407 | * Comodo does not provide these data, when not a EV certificate (Bug?). So we fill this manually to "not required". |
||
408 | * |
||
409 | * https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/CollectSSL%20v1.17.pdf |
||
410 | */ |
||
411 | if (!isset($arr['evClickThroughStatus'])) { |
||
412 | $result->setEvClickThroughStatus(-1); |
||
413 | } |
||
414 | |||
415 | if (!isset($arr['brandValStatus'])) { |
||
416 | $result->setBrandValStatus(-1); |
||
417 | } |
||
418 | |||
419 | return $result; |
||
420 | } else { |
||
421 | throw $this->createException($arr); |
||
422 | } |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * Function to resend the DCV Email |
||
427 | * |
||
428 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
429 | * |
||
430 | * @param array $params |
||
431 | * |
||
432 | * @return bool |
||
433 | * @throws Model\Exception\AccountException |
||
434 | * @throws Model\Exception\ArgumentException |
||
435 | * @throws Model\Exception\RequestException |
||
436 | * @throws Model\Exception\UnknownApiException |
||
437 | * @throws Model\Exception\UnknownException |
||
438 | */ |
||
439 | public function resendDCVEMail(array $params) |
||
440 | { |
||
441 | return $this |
||
442 | ->sendBooleanRequest( |
||
443 | self::COMODO_DCV_RESEND_URL, |
||
444 | $params, |
||
445 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
446 | ); |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * @param array $params |
||
451 | * |
||
452 | * @deprecated Comodo support told this function doesn't have any effect anymore |
||
453 | * |
||
454 | * @return bool |
||
455 | * @throws Model\Exception\AccountException |
||
456 | * @throws Model\Exception\ArgumentException |
||
457 | * @throws Model\Exception\CSRException |
||
458 | * @throws Model\Exception\RequestException |
||
459 | * @throws Model\Exception\UnknownApiException |
||
460 | * @throws Model\Exception\UnknownException |
||
461 | */ |
||
462 | public function provideEVDetails(array $params) |
||
463 | { |
||
464 | return $this->sendBooleanRequest( |
||
465 | self::COMODO_PROVIDE_EV_DETAILS_URL, |
||
466 | $params, |
||
467 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
468 | ); |
||
469 | } |
||
470 | |||
471 | /** |
||
472 | * Function to get the DCV e-mail address-list |
||
473 | * |
||
474 | * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/ |
||
475 | * |
||
476 | * @param array $params |
||
477 | * |
||
478 | * @return GetDCVEMailAddressListResult |
||
479 | * @throws AccountException |
||
480 | * @throws ArgumentException |
||
481 | * @throws CSRException |
||
482 | * @throws RequestException |
||
483 | * @throws UnknownApiException |
||
484 | * @throws UnknownException |
||
485 | */ |
||
486 | public function getDCVEMailAddressList(array $params) |
||
487 | { |
||
488 | // Force threating as array |
||
489 | $forceArray = array('whois_email', 'level2_email', 'level3_email'); |
||
490 | |||
491 | // Response is always new line encoded |
||
492 | $responseArray = $this |
||
493 | ->communicationAdapter |
||
494 | ->sendToApi( |
||
495 | self::COMODO_DCV_MAIL_URL, |
||
496 | $params, |
||
497 | CommunicationAdapter::RESPONSE_NEW_LINE, |
||
498 | null, |
||
499 | $forceArray |
||
500 | ); |
||
501 | |||
502 | if ($responseArray['errorCode'] == 0) { |
||
503 | $result = new GetDCVEMailAddressListResult(); |
||
504 | |||
505 | if (isset($responseArray['whois_email'][0]) && $responseArray['whois_email'][0] == 'none') { |
||
506 | unset($responseArray['whois_email'][0]); |
||
507 | } |
||
508 | |||
509 | $result |
||
510 | ->setDomainName($responseArray['domain_name']) |
||
511 | ->setWhoisEmail($responseArray['whois_email']) |
||
512 | ->setLevel2Emails($responseArray['level2_email']) |
||
513 | ->setRequestQuery($responseArray['requestQuery']); |
||
514 | |||
515 | if (isset($responseArray['level3_email'])) { |
||
516 | $result->setLevel3Emails($responseArray['level3_email']); |
||
517 | } |
||
518 | |||
519 | return $result; |
||
520 | } else { |
||
521 | throw $this->createException($responseArray); |
||
522 | } |
||
523 | } |
||
524 | |||
525 | /** |
||
526 | * Function to get details of a order-number (this API support just one domain) |
||
527 | * |
||
528 | * https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/GetMDCDomainDetails%20v1.00.pdf |
||
529 | * |
||
530 | * @param array $params |
||
531 | * |
||
532 | * @return GetMDCDomainDetailsResult |
||
533 | * |
||
534 | * @throws Model\Exception\AccountException |
||
535 | * @throws Model\Exception\ArgumentException |
||
536 | * @throws Model\Exception\CSRException |
||
537 | * @throws Model\Exception\RequestException |
||
538 | * @throws Model\Exception\UnknownApiException |
||
539 | * @throws Model\Exception\UnknownException |
||
540 | */ |
||
541 | View Code Duplication | public function getMDCDomainDetails(array $params) |
|
542 | { |
||
543 | // Response is always new line encoded |
||
544 | $responseArray = $this |
||
545 | ->communicationAdapter |
||
546 | ->sendToApi( |
||
547 | self::COMODO_MDC_DOMAIN_DETAILS_URL, |
||
548 | $params, |
||
549 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
550 | ); |
||
551 | |||
552 | if ($responseArray['errorCode'] == 0) { |
||
553 | $result = new GetMDCDomainDetailsResult(); |
||
554 | |||
555 | $result |
||
556 | ->setDomainName($responseArray['1_domainName']) |
||
557 | ->setDcvMethod($responseArray['1_dcvMethod']) |
||
558 | ->setDcvStatus($responseArray['1_dcvStatus']); |
||
559 | |||
560 | return $result; |
||
561 | } else { |
||
562 | throw $this->createException($responseArray); |
||
563 | } |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * Function to do a sslcheck |
||
568 | * |
||
569 | * https://secure.comodo.net/api/pdf/latest/SSLChecker.pdf |
||
570 | * |
||
571 | * @param array $params |
||
572 | * |
||
573 | * @return GetMDCDomainDetailsResult |
||
574 | * |
||
575 | * @throws Model\Exception\AccountException |
||
576 | * @throws Model\Exception\ArgumentException |
||
577 | * @throws Model\Exception\CSRException |
||
578 | * @throws Model\Exception\RequestException |
||
579 | * @throws Model\Exception\UnknownApiException |
||
580 | * @throws Model\Exception\UnknownException |
||
581 | */ |
||
582 | public function sslChecker(array $params) |
||
583 | { |
||
584 | // Response is always new line encoded |
||
585 | $responseArray = $this |
||
586 | ->communicationAdapter |
||
587 | ->sendToApi( |
||
588 | self::COMODO_SSLCHECKER, |
||
589 | $params, |
||
590 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
591 | ); |
||
592 | |||
593 | if ($responseArray['error_code'] == 0) { |
||
594 | $result = new SslCheckerResult(); |
||
595 | |||
596 | $result |
||
597 | ->setServerUrl($responseArray['server_url']) |
||
598 | ->setServerDomainIsIDN($responseArray['server_domain_isIDN']) |
||
599 | ->setServerDomainUtf8($responseArray['server_domain_utf8']) |
||
600 | ->setServerDomainAce($responseArray['server_domain_ace']) |
||
601 | ->setServerIp($responseArray['server_ip']) |
||
602 | ->setServerPort($responseArray['server_port']) |
||
603 | ->setServerSoftware($responseArray['server_software']) |
||
604 | ->setCertNotBeforeFromUnixTimestamp($responseArray['cert_notBefore']) |
||
605 | ->setCertNotAfterFromUnixTimestamp($responseArray['cert_notAfter']) |
||
606 | ->setCertValidityNotBefore($responseArray['cert_validity_notBefore']) |
||
607 | ->setCertValidityNotAfter($responseArray['cert_validity_notAfter']) |
||
608 | ->setCertKeyAlgorithm($responseArray['cert_key_algorithm']) |
||
609 | ->setCertKeySize($responseArray['cert_key_size']) |
||
610 | ->setCertSubjectCN($responseArray['cert_subject_DN']) |
||
611 | ->setCertSubjectCN($responseArray['cert_subject_CN']) |
||
612 | ->setCertSubjectOU($responseArray['cert_subject_OU']) |
||
613 | ->setCertSubjectOrganization($responseArray['cert_subject_O']) |
||
614 | ->setCertSubjectStreetAddress1($responseArray['cert_subject_streetAddress_1']) |
||
615 | ->setCertSubjectStreetAddress2($responseArray['cert_subject_streetAddress_2']) |
||
616 | ->setCertSubjectStreetAddress3($responseArray['cert_subject_streetAddress_3']) |
||
617 | ->setCertSubjectLocality($responseArray['cert_subject_L']) |
||
618 | ->setCertSubjectState($responseArray['cert_subject_S']) |
||
619 | ->setCertSubjectPostalCode($responseArray['cert_subject_postalCode']) |
||
620 | ->setCertSubjectCountry($responseArray['cert_subject_C']) |
||
621 | ->setCertIsMultiDomain($responseArray['cert_isMultiDomain']) |
||
622 | ->setCertIsWildcard($responseArray['cert_isWildcard']) |
||
623 | ->setCertIssuerDN($responseArray['cert_issuer_DN']) |
||
624 | ->setCertIssuerCN($responseArray['cert_issuer_CN']) |
||
625 | ->setCertIssuerOrganization($responseArray['cert_issuer_O']) |
||
626 | ->setCertIssuerOrganization($responseArray['cert_issuer_C']) |
||
627 | ->setCertIssuerBrand($responseArray['cert_issuer_brand']) |
||
628 | ->setCertPolicyOID($responseArray['cert_policyOID']) |
||
629 | ->setCertValidation($responseArray['cert_validation']); |
||
630 | |||
631 | return $result; |
||
632 | } else { |
||
633 | throw $this->createException($responseArray); |
||
634 | } |
||
635 | } |
||
636 | |||
637 | /** |
||
638 | * Function to call WebHostReport api |
||
639 | * |
||
640 | * https://secure.comodo.net/products/!WebHostReport |
||
641 | * |
||
642 | * Details for params usage: |
||
643 | * https://secure.comodo.net/api/pdf/latest/WebHostReport.pdf |
||
644 | * |
||
645 | * @param array $params |
||
646 | * |
||
647 | * @return WebHostReportResult |
||
648 | * |
||
649 | * @throws Model\Exception\AccountException |
||
650 | * @throws Model\Exception\ArgumentException |
||
651 | * @throws Model\Exception\CSRException |
||
652 | * @throws Model\Exception\RequestException |
||
653 | * @throws Model\Exception\UnknownApiException |
||
654 | * @throws Model\Exception\UnknownException |
||
655 | */ |
||
656 | View Code Duplication | public function webHostReport(array $params) { |
|
657 | |||
658 | if (empty($params['lastResultNo'])) { |
||
659 | $params['lastResultNo'] = 10; |
||
660 | } |
||
661 | |||
662 | // Response is always new line encoded |
||
663 | $responseArray = $this |
||
664 | ->communicationAdapter |
||
665 | ->sendToApi( |
||
666 | self::COMODO_WEB_HOST_REPORT, |
||
667 | $params, |
||
668 | CommunicationAdapter::RESPONSE_URL_ENCODED |
||
669 | ); |
||
670 | if ($responseArray['error_code'] == 0) { |
||
671 | $result = new WebHostReportResult(); |
||
672 | $result->importEntries($responseArray); |
||
0 ignored issues
–
show
It seems like
$responseArray defined by $this->communicationAdap...::RESPONSE_URL_ENCODED) on line 663 can also be of type boolean ; however, Checkdomain\Comodo\Model...Result::importEntries() does only seem to accept array , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
673 | return $result; |
||
674 | } else { |
||
675 | throw $this->createException($responseArray); |
||
676 | } |
||
677 | } |
||
678 | |||
679 | /** |
||
680 | * Function to enter the DCV code, coming from DCV E-Mail |
||
681 | * |
||
682 | * @param array $params |
||
683 | * |
||
684 | * @return bool |
||
685 | * @throws Model\Exception\UnknownException |
||
686 | * @throws Model\Exception\ArgumentException |
||
687 | */ |
||
688 | public function enterDCVCode(array $params) |
||
689 | { |
||
690 | // Check parameters |
||
691 | if (!isset($params['dcvCode'])) { |
||
692 | throw new ArgumentException(-3, 'Please provide an order-number', 'dcvCode', ''); |
||
693 | } |
||
694 | |||
695 | if (!isset($params['orderNumber'])) { |
||
696 | throw new ArgumentException(-3, 'Please provide an order-number', 'orderNumber', ''); |
||
697 | } |
||
698 | |||
699 | // this is not a official request, so we need to use the website |
||
700 | $responseString = $this |
||
701 | ->communicationAdapter |
||
702 | ->sendToWebsite(self::COMODO_DCV_CODE_URL, $params); |
||
703 | |||
704 | // Decode answer from website |
||
705 | if (stristr($responseString, 'You have entered the correct Domain Control Validation code') !== false) { |
||
706 | return true; |
||
707 | } elseif (stristr($responseString, 'the certificate has already been issued') !== false) { |
||
708 | throw new ArgumentException(-104, 'The certificate has already been issued', 'certificate', $responseString); |
||
709 | } elseif (stristr($responseString, 'Invalid Validation Code!') !== false) { |
||
710 | throw new ArgumentException(-103, 'Invalid Validation Code', 'validation-code', $responseString); |
||
711 | } else { |
||
712 | throw new UnknownException(99, 'UnknownException', $responseString); |
||
713 | } |
||
714 | } |
||
715 | |||
716 | /** |
||
717 | * @param string $domainName |
||
718 | * @param null $orderNumbers |
||
719 | * @param \Closure $callbackFunction |
||
720 | * |
||
721 | * @return array |
||
722 | */ |
||
723 | public function getMails($domainName, $orderNumbers = null, \Closure $callbackFunction = null) |
||
724 | { |
||
725 | $orList = ' OR '; |
||
726 | $whereList = ' BODY "'.$domainName.'"'; |
||
727 | $whereList .= ' SUBJECT "'.$domainName.'"'; |
||
728 | |||
729 | if (is_array($orderNumbers)) { |
||
730 | foreach ($orderNumbers as $orderNumber) { |
||
731 | $orList .= ' OR OR '; |
||
732 | $whereList .= ' BODY "'.$orderNumber.'"'; |
||
733 | $whereList .= ' SUBJECT "'.$orderNumber.'"'; |
||
734 | } |
||
735 | } |
||
736 | |||
737 | $search = $orList.' '.$whereList; |
||
738 | |||
739 | return $this |
||
740 | ->imapHelper |
||
741 | ->fetchMails($this->imapAdapter, $search, false, false, $callbackFunction); |
||
742 | } |
||
743 | |||
744 | /** |
||
745 | * @param bool $markProcessed |
||
746 | * @param \Closure $callbackFunction |
||
747 | * |
||
748 | * @return array |
||
749 | */ |
||
750 | public function getUnprocessedMails($markProcessed = true, \Closure $callbackFunction = null) |
||
751 | { |
||
752 | $search = ' NOT KEYWORD "'.ImapHelper::PROCESSED_FLAG.'"'; |
||
753 | |||
754 | return $this |
||
755 | ->imapHelper |
||
756 | ->fetchMails( |
||
757 | $this->imapAdapter, |
||
758 | $search, |
||
759 | $markProcessed, |
||
760 | true, |
||
761 | $callbackFunction |
||
762 | ); |
||
763 | } |
||
764 | |||
765 | /** |
||
766 | * Function to create an exception for API errorcodes |
||
767 | * |
||
768 | * @param array|mixed $responseArray |
||
769 | * |
||
770 | * @return AccountException|ArgumentException|CSRException|RequestException|UnknownApiException|UnknownException |
||
771 | * |
||
772 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
||
773 | */ |
||
774 | protected function createException($responseArray) |
||
775 | { |
||
776 | if (is_array($responseArray) === false) { |
||
777 | return new UnknownException( |
||
778 | 0, |
||
779 | 'Internal error', |
||
780 | $responseArray['responseString'] |
||
781 | ); |
||
782 | } |
||
783 | |||
784 | switch ($responseArray['errorCode']) { |
||
785 | case -1: // Not using https: |
||
786 | case -17: // Wrong HTTP-method |
||
787 | return new RequestException( |
||
788 | $responseArray['errorCode'], |
||
789 | $responseArray['errorMessage'], |
||
790 | $responseArray['responseString'] |
||
791 | ); |
||
792 | |||
793 | case -2: // unrecognized argument |
||
794 | case -3: // missing argument |
||
795 | case -4: // invalid argument |
||
796 | case -7: // invalid ISO Country |
||
797 | case -18: // Name = Fully-Qualified Domain Name |
||
798 | case -35: // Name = = IP |
||
799 | case -19: // Name = = Accessible IP |
||
800 | return new ArgumentException( |
||
801 | $responseArray['errorCode'], |
||
802 | $responseArray['errorMessage'], |
||
803 | ((isset($responseArray['errorItem'])) ? $responseArray['errorItem'] : null), |
||
804 | $responseArray['responseString'] |
||
805 | ); |
||
806 | |||
807 | case -16: // Permission denied |
||
808 | case -15: // insufficient credits |
||
809 | return new AccountException( |
||
810 | $responseArray['errorCode'], |
||
811 | $responseArray['errorMessage'], |
||
812 | $responseArray['responseString'] |
||
813 | ); |
||
814 | |||
815 | case -5: // contains wildcard |
||
816 | case -6: // no wildcard, but must have |
||
817 | case -8: // missing field |
||
818 | case -9: // base64 decode exception |
||
819 | case -10: // decode exception |
||
820 | case -11: // unsupported algorithm |
||
821 | case -12: // invalid signature |
||
822 | case -13: // unsupported key size |
||
823 | case -20: // Already rejected / Order relevated |
||
824 | case -21: // Already revoked |
||
825 | case -26: // current being issued |
||
826 | case -40: // key compromised |
||
827 | return new CSRException( |
||
828 | $responseArray['errorCode'], |
||
829 | $responseArray['errorMessage'], |
||
830 | $responseArray['responseString'] |
||
831 | ); |
||
832 | |||
833 | case -14: |
||
834 | return new UnknownApiException( |
||
835 | $responseArray['errorCode'], |
||
836 | $responseArray['errorMessage'], |
||
837 | $responseArray['responseString'] |
||
838 | ); |
||
839 | |||
840 | default: |
||
841 | return new UnknownException( |
||
842 | $responseArray['errorCode'], |
||
843 | $responseArray['errorMessage'], |
||
844 | $responseArray['responseString'] |
||
845 | ); |
||
846 | } |
||
847 | } |
||
848 | |||
849 | /** |
||
850 | * @param CollectSslResult $object |
||
851 | * @param array $arr |
||
852 | * @param array $timestampFields |
||
853 | * |
||
854 | * @return $this |
||
855 | */ |
||
856 | protected function fill(CollectSslResult $object, array $arr, array $timestampFields = array()) |
||
857 | { |
||
858 | foreach ($arr as $key => $value) { |
||
859 | if (in_array($key, $timestampFields)) { |
||
860 | $value = new \DateTime('@'.$value); |
||
861 | } |
||
862 | |||
863 | $function = 'set'.ucfirst($key); |
||
864 | |||
865 | // For example setErrorCode does not exists, so check before |
||
866 | if (method_exists($object, $function)) { |
||
867 | call_user_func(array($object, $function), $value); |
||
868 | } |
||
869 | } |
||
870 | |||
871 | return $this; |
||
872 | } |
||
873 | |||
874 | /** |
||
875 | * @param string $url |
||
876 | * @param array $params |
||
877 | * @param int $type |
||
878 | * |
||
879 | * @return bool |
||
880 | * @throws AccountException |
||
881 | * @throws ArgumentException |
||
882 | * @throws CSRException |
||
883 | * @throws RequestException |
||
884 | * @throws UnknownApiException |
||
885 | * @throws UnknownException |
||
886 | */ |
||
887 | protected function sendBooleanRequest($url, array $params, $type) |
||
888 | { |
||
889 | // Response is always url encoded |
||
890 | $responseArray = $this |
||
891 | ->communicationAdapter |
||
892 | ->sendToApi( |
||
893 | $url, |
||
894 | $params, |
||
895 | $type |
||
896 | ); |
||
897 | |||
898 | if ($responseArray['errorCode'] == 0) { |
||
899 | return true; |
||
900 | } else { |
||
901 | throw $this->createException($responseArray); |
||
902 | } |
||
903 | } |
||
904 | } |
||
905 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.