@@ -13,88 +13,88 @@ |
||
13 | 13 | */ |
14 | 14 | class LEAuthorization |
15 | 15 | { |
16 | - private $connector; |
|
16 | + private $connector; |
|
17 | 17 | |
18 | - public $authorizationURL; |
|
19 | - public $identifier; |
|
20 | - public $status; |
|
21 | - public $expires; |
|
22 | - public $challenges; |
|
18 | + public $authorizationURL; |
|
19 | + public $identifier; |
|
20 | + public $status; |
|
21 | + public $expires; |
|
22 | + public $challenges; |
|
23 | 23 | |
24 | - /** @var LoggerInterface */ |
|
25 | - private $log; |
|
24 | + /** @var LoggerInterface */ |
|
25 | + private $log; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance. |
|
29 | - * |
|
30 | - * @param LEConnector $connector The LetsEncrypt Connector instance to use for HTTP requests. |
|
31 | - * @param LoggerInterface $log PSR-3 logger |
|
32 | - * @param string $authorizationURL The URL of the authorization, given by a LetsEncrypt order request. |
|
33 | - */ |
|
34 | - public function __construct($connector, LoggerInterface $log, $authorizationURL) |
|
35 | - { |
|
36 | - $this->connector = $connector; |
|
37 | - $this->log = $log; |
|
38 | - $this->authorizationURL = $authorizationURL; |
|
27 | + /** |
|
28 | + * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance. |
|
29 | + * |
|
30 | + * @param LEConnector $connector The LetsEncrypt Connector instance to use for HTTP requests. |
|
31 | + * @param LoggerInterface $log PSR-3 logger |
|
32 | + * @param string $authorizationURL The URL of the authorization, given by a LetsEncrypt order request. |
|
33 | + */ |
|
34 | + public function __construct($connector, LoggerInterface $log, $authorizationURL) |
|
35 | + { |
|
36 | + $this->connector = $connector; |
|
37 | + $this->log = $log; |
|
38 | + $this->authorizationURL = $authorizationURL; |
|
39 | 39 | |
40 | - $sign = $this->connector->signRequestKid( |
|
41 | - null, |
|
42 | - $this->connector->accountURL, |
|
43 | - $this->authorizationURL |
|
44 | - ); |
|
40 | + $sign = $this->connector->signRequestKid( |
|
41 | + null, |
|
42 | + $this->connector->accountURL, |
|
43 | + $this->authorizationURL |
|
44 | + ); |
|
45 | 45 | |
46 | - $post = $this->connector->post($this->authorizationURL, $sign); |
|
47 | - if ($post['status'] === 200) { |
|
48 | - $this->identifier = $post['body']['identifier']; |
|
49 | - $this->status = $post['body']['status']; |
|
50 | - $this->expires = $post['body']['expires']; |
|
51 | - $this->challenges = $post['body']['challenges']; |
|
52 | - } else { |
|
53 | - //@codeCoverageIgnoreStart |
|
54 | - $this->log->error("LEAuthorization::__construct cannot find authorization $authorizationURL"); |
|
55 | - //@codeCoverageIgnoreEnd |
|
56 | - } |
|
57 | - } |
|
46 | + $post = $this->connector->post($this->authorizationURL, $sign); |
|
47 | + if ($post['status'] === 200) { |
|
48 | + $this->identifier = $post['body']['identifier']; |
|
49 | + $this->status = $post['body']['status']; |
|
50 | + $this->expires = $post['body']['expires']; |
|
51 | + $this->challenges = $post['body']['challenges']; |
|
52 | + } else { |
|
53 | + //@codeCoverageIgnoreStart |
|
54 | + $this->log->error("LEAuthorization::__construct cannot find authorization $authorizationURL"); |
|
55 | + //@codeCoverageIgnoreEnd |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Updates the data associated with the current LetsEncrypt Authorization instance. |
|
61 | - */ |
|
59 | + /** |
|
60 | + * Updates the data associated with the current LetsEncrypt Authorization instance. |
|
61 | + */ |
|
62 | 62 | |
63 | - public function updateData() |
|
64 | - { |
|
65 | - $get = $this->connector->get($this->authorizationURL); |
|
66 | - if ($get['status'] === 200) { |
|
67 | - $this->identifier = $get['body']['identifier']; |
|
68 | - $this->status = $get['body']['status']; |
|
69 | - $this->expires = $get['body']['expires']; |
|
70 | - $this->challenges = $get['body']['challenges']; |
|
71 | - } else { |
|
72 | - //@codeCoverageIgnoreStart |
|
73 | - $this->log->error("LEAuthorization::updateData cannot find authorization " . $this->authorizationURL); |
|
74 | - //@codeCoverageIgnoreEnd |
|
75 | - } |
|
76 | - } |
|
63 | + public function updateData() |
|
64 | + { |
|
65 | + $get = $this->connector->get($this->authorizationURL); |
|
66 | + if ($get['status'] === 200) { |
|
67 | + $this->identifier = $get['body']['identifier']; |
|
68 | + $this->status = $get['body']['status']; |
|
69 | + $this->expires = $get['body']['expires']; |
|
70 | + $this->challenges = $get['body']['challenges']; |
|
71 | + } else { |
|
72 | + //@codeCoverageIgnoreStart |
|
73 | + $this->log->error("LEAuthorization::updateData cannot find authorization " . $this->authorizationURL); |
|
74 | + //@codeCoverageIgnoreEnd |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. |
|
80 | - * Throws a Runtime Exception if the given $type is not found in this LetsEncrypt Authorization instance. |
|
81 | - * |
|
82 | - * @param string $type The type of verification. |
|
83 | - * Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS. |
|
84 | - * |
|
85 | - * @return array Returns an array with the challenge of the requested $type. |
|
86 | - */ |
|
87 | - public function getChallenge($type) |
|
88 | - { |
|
89 | - foreach ($this->challenges as $challenge) { |
|
90 | - if ($challenge['type'] == $type) { |
|
91 | - return $challenge; |
|
92 | - } |
|
93 | - } |
|
94 | - //@codeCoverageIgnoreStart |
|
95 | - throw new RuntimeException( |
|
96 | - 'No challenge found for type \'' . $type . '\' and identifier \'' . $this->identifier['value'] . '\'.' |
|
97 | - ); |
|
98 | - //@codeCoverageIgnoreEnd |
|
99 | - } |
|
78 | + /** |
|
79 | + * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. |
|
80 | + * Throws a Runtime Exception if the given $type is not found in this LetsEncrypt Authorization instance. |
|
81 | + * |
|
82 | + * @param string $type The type of verification. |
|
83 | + * Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS. |
|
84 | + * |
|
85 | + * @return array Returns an array with the challenge of the requested $type. |
|
86 | + */ |
|
87 | + public function getChallenge($type) |
|
88 | + { |
|
89 | + foreach ($this->challenges as $challenge) { |
|
90 | + if ($challenge['type'] == $type) { |
|
91 | + return $challenge; |
|
92 | + } |
|
93 | + } |
|
94 | + //@codeCoverageIgnoreStart |
|
95 | + throw new RuntimeException( |
|
96 | + 'No challenge found for type \'' . $type . '\' and identifier \'' . $this->identifier['value'] . '\'.' |
|
97 | + ); |
|
98 | + //@codeCoverageIgnoreEnd |
|
99 | + } |
|
100 | 100 | } |