| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn\MetadataService\Service; |
| 6 |
|
| 7 |
use function count; |
| 8 |
use function is_string; |
| 9 |
use Webauthn\Exception\MetadataStatementLoadingException; |
| 10 |
use Webauthn\MetadataService\Statement\BiometricStatusReport; |
| 11 |
use Webauthn\MetadataService\Statement\MetadataStatement; |
| 12 |
use Webauthn\MetadataService\Statement\StatusReport; |
| 13 |
|
| 14 |
class MetadataBLOBPayloadEntry |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public function __construct( |
| 22 |
public readonly string $timeOfLastStatusChange, |
| 23 |
public array $statusReports, |
| 24 |
public readonly ?string $aaid = null, |
| 25 |
public readonly ?string $aaguid = null, |
| 26 |
public array $attestationCertificateKeyIdentifiers = [], |
| 27 |
public readonly ?MetadataStatement $metadataStatement = null, |
| 28 |
public readonly ?string $rogueListURL = null, |
| 29 |
public readonly ?string $rogueListHash = null, |
| 30 |
public array $biometricStatusReports = [] |
| 31 |
) { |
| 32 |
if ($aaid !== null && $aaguid !== null) { |
| 33 |
throw MetadataStatementLoadingException::create('Authenticators cannot support both AAID and AAGUID'); |
| 34 |
} |
| 35 |
if ($aaid === null && $aaguid === null && count($attestationCertificateKeyIdentifiers) === 0) { |
| 36 |
throw MetadataStatementLoadingException::create( |
| 37 |
'If neither AAID nor AAGUID are set, the attestation certificate identifier list shall not be empty' |
| 38 |
); |
| 39 |
} |
| 40 |
foreach ($attestationCertificateKeyIdentifiers as $attestationCertificateKeyIdentifier) { |
| 41 |
is_string($attestationCertificateKeyIdentifier) || throw MetadataStatementLoadingException::create( |
| 42 |
'Invalid attestation certificate identifier. Shall be a list of strings' |
| 43 |
); |
| 44 |
preg_match( |
| 45 |
'/^[0-9a-f]+$/', |
| 46 |
$attestationCertificateKeyIdentifier |
| 47 |
) === 1 || throw MetadataStatementLoadingException::create( |
| 48 |
'Invalid attestation certificate identifier. Shall be a list of strings' |
| 49 |
); |
| 50 |
} |
| 51 |
} |
| 52 |
} |