|
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
|
|
|
private $clientExtensionOutput; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var bool |
|
18
|
|
|
*/ |
|
19
|
|
|
private $hasAuthenticatorExtensionOutput = false; |
|
20
|
|
|
|
|
21
|
|
|
private $authenticatorExtensionOutput; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $identifier; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct(string $identifier) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->identifier = $identifier; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function getIdentifier(): string |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->identifier; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function hasClientExtensionOutput(): bool |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->hasClientExtensionOutput; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getClientExtensionOutput() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->clientExtensionOutput; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function hasAuthenticatorExtensionOutput(): bool |
|
49
|
|
|
{ |
|
50
|
|
|
if (!$this->hasClientExtensionOutput) { |
|
51
|
|
|
throw new NotAvailableException(sprintf('No client extension output is available for extension "%s".', $this->identifier)); |
|
52
|
|
|
} |
|
53
|
|
|
return $this->hasAuthenticatorExtensionOutput; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getAuthenticatorExtensionOutput() |
|
57
|
|
|
{ |
|
58
|
|
|
if (!$this->hasAuthenticatorExtensionOutput) { |
|
59
|
|
|
throw new NotAvailableException(sprintf('No authenticator extension output is available for extension "%s".', $this->identifier)); |
|
60
|
|
|
} |
|
61
|
|
|
return $this->authenticatorExtensionOutput; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param mixed $clientExtensionOutput |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setClientExtensionOutput($clientExtensionOutput): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->hasClientExtensionOutput = true; |
|
70
|
|
|
$this->clientExtensionOutput = $clientExtensionOutput; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param mixed $authenticatorExtensionOutput |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setAuthenticatorExtensionOutput($authenticatorExtensionOutput): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->hasAuthenticatorExtensionOutput = true; |
|
79
|
|
|
$this->authenticatorExtensionOutput = $authenticatorExtensionOutput; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|