1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MadWizard\WebAuthn\Extension; |
4
|
|
|
|
5
|
|
|
use MadWizard\WebAuthn\Exception\NotAvailableException; |
6
|
|
|
|
7
|
|
|
final class ExtensionResponse implements ExtensionResponseInterface |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var bool |
11
|
|
|
*/ |
12
|
|
|
private $hasClientExtensionOutput = false; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var mixed |
16
|
|
|
*/ |
17
|
|
|
private $clientExtensionOutput; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var bool |
21
|
|
|
*/ |
22
|
|
|
private $hasAuthenticatorExtensionOutput = false; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var mixed |
26
|
|
|
*/ |
27
|
|
|
private $authenticatorExtensionOutput; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $identifier; |
33
|
|
|
|
34
|
3 |
|
public function __construct(string $identifier) |
35
|
|
|
{ |
36
|
3 |
|
$this->identifier = $identifier; |
37
|
3 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function getIdentifier(): string |
40
|
|
|
{ |
41
|
1 |
|
return $this->identifier; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function hasClientExtensionOutput(): bool |
45
|
|
|
{ |
46
|
|
|
return $this->hasClientExtensionOutput; |
47
|
|
|
} |
48
|
|
|
|
49
|
2 |
|
public function getClientExtensionOutput() |
50
|
|
|
{ |
51
|
2 |
|
return $this->clientExtensionOutput; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function hasAuthenticatorExtensionOutput(): bool |
55
|
|
|
{ |
56
|
|
|
if (!$this->hasClientExtensionOutput) { |
57
|
|
|
throw new NotAvailableException(sprintf('No client extension output is available for extension "%s".', $this->identifier)); |
58
|
|
|
} |
59
|
|
|
return $this->hasAuthenticatorExtensionOutput; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getAuthenticatorExtensionOutput() |
63
|
|
|
{ |
64
|
|
|
if (!$this->hasAuthenticatorExtensionOutput) { |
65
|
|
|
throw new NotAvailableException(sprintf('No authenticator extension output is available for extension "%s".', $this->identifier)); |
66
|
|
|
} |
67
|
|
|
return $this->authenticatorExtensionOutput; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param mixed $clientExtensionOutput |
72
|
|
|
*/ |
73
|
2 |
|
public function setClientExtensionOutput($clientExtensionOutput): void |
74
|
|
|
{ |
75
|
2 |
|
$this->hasClientExtensionOutput = true; |
76
|
2 |
|
$this->clientExtensionOutput = $clientExtensionOutput; |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param mixed $authenticatorExtensionOutput |
81
|
|
|
*/ |
82
|
|
|
public function setAuthenticatorExtensionOutput($authenticatorExtensionOutput): void |
83
|
|
|
{ |
84
|
|
|
$this->hasAuthenticatorExtensionOutput = true; |
85
|
|
|
$this->authenticatorExtensionOutput = $authenticatorExtensionOutput; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|