|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LE_ACME2\Response\Authorization; |
|
4
|
|
|
|
|
5
|
|
|
use LE_ACME2\Response\Authorization\Struct; |
|
6
|
|
|
|
|
7
|
|
|
class Get extends AbstractAuthorization { |
|
8
|
|
|
|
|
9
|
|
|
public function getIdentifier() : Struct\Identifier { |
|
10
|
|
|
|
|
11
|
|
|
return new Struct\Identifier( |
|
12
|
|
|
$this->_raw->body['identifier']['type'], |
|
13
|
|
|
$this->_raw->body['identifier']['value'] |
|
14
|
|
|
); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function getStatus() : string { |
|
18
|
|
|
return $this->_raw->body['status']; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function getExpires() : string { |
|
22
|
|
|
return $this->_raw->body['expires']; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
1 |
|
public function getChallenges() : array { |
|
26
|
1 |
|
return $this->_raw->body['challenges']; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param string $type |
|
31
|
|
|
* @return Struct\Challenge|null |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getChallenge(string $type) : ?Struct\Challenge { |
|
34
|
|
|
|
|
35
|
|
|
foreach($this->getChallenges() as $challenge) { |
|
36
|
|
|
|
|
37
|
|
|
if($type == $challenge['type']) { |
|
38
|
|
|
|
|
39
|
|
|
$error = null; |
|
40
|
|
|
if(isset($challenge[ 'error' ]) && $challenge[ 'error' ] != "") { |
|
41
|
|
|
$error = new Struct\ChallengeError( |
|
42
|
|
|
$challenge[ 'error' ][ 'type' ], |
|
43
|
|
|
$challenge[ 'error' ][ 'detail' ], |
|
44
|
|
|
$challenge[ 'error' ][ 'status' ], |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return new Struct\Challenge( |
|
49
|
|
|
$challenge[ 'type' ], |
|
50
|
|
|
$challenge[ 'status' ], |
|
51
|
|
|
$challenge[ 'url' ], |
|
52
|
|
|
$challenge[ 'token' ], |
|
53
|
|
|
$error, |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// There is not a challenge for a specific type, when the subject is already authorized by another |
|
59
|
|
|
// authorize type, f.e. when switching from http-01 to dns-01 |
|
60
|
|
|
|
|
61
|
|
|
return null; |
|
62
|
|
|
} |
|
63
|
|
|
} |