[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 /* 6 * The MIT License (MIT) 7 * 8 * Copyright (c) 2014-2019 Spomky-Labs 9 * 10 * This software may be modified and distributed under the terms 11 * of the MIT license. See the LICENSE file for details. 12 */ 13 14 namespace Webauthn; 15 16 use Assert\Assertion; 17 use JsonSerializable; 18 19 class AuthenticatorSelectionCriteria implements JsonSerializable 20 { 21 public const AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE = null; 22 public const AUTHENTICATOR_ATTACHMENT_PLATFORM = 'platform'; 23 public const AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM = 'cross-platform'; 24 25 public const USER_VERIFICATION_REQUIREMENT_REQUIRED = 'required'; 26 public const USER_VERIFICATION_REQUIREMENT_PREFERRED = 'preferred'; 27 public const USER_VERIFICATION_REQUIREMENT_DISCOURAGED = 'discouraged'; 28 29 /** 30 * @var string|null 31 */ 32 private $authenticatorAttachment; 33 34 /** 35 * @var bool 36 */ 37 private $requireResidentKey; 38 39 /** 40 * @var string 41 */ 42 private $userVerification; 43 44 public function __construct(?string $authenticatorAttachment = null, bool $requireResidentKey = false, string $userVerification = self::USER_VERIFICATION_REQUIREMENT_PREFERRED) 45 { 46 $this->authenticatorAttachment = $authenticatorAttachment; 47 $this->requireResidentKey = $requireResidentKey; 48 $this->userVerification = $userVerification; 49 } 50 51 public function getAuthenticatorAttachment(): ?string 52 { 53 return $this->authenticatorAttachment; 54 } 55 56 public function isRequireResidentKey(): bool 57 { 58 return $this->requireResidentKey; 59 } 60 61 public function getUserVerification(): string 62 { 63 return $this->userVerification; 64 } 65 66 public static function createFromString(string $data): self 67 { 68 $data = json_decode($data, true); 69 Assertion::eq(JSON_ERROR_NONE, json_last_error(), 'Invalid data'); 70 Assertion::isArray($data, 'Invalid data'); 71 72 return self::createFromArray($data); 73 } 74 75 public static function createFromArray(array $json): self 76 { 77 return new self( 78 $json['authenticatorAttachment'] ?? null, 79 $json['requireResidentKey'] ?? false, 80 $json['userVerification'] ?? self::USER_VERIFICATION_REQUIREMENT_PREFERRED 81 ); 82 } 83 84 public function jsonSerialize(): array 85 { 86 $json = [ 87 'requireResidentKey' => $this->requireResidentKey, 88 'userVerification' => $this->userVerification, 89 ]; 90 if (null !== $this->authenticatorAttachment) { 91 $json['authenticatorAttachment'] = $this->authenticatorAttachment; 92 } 93 94 return $json; 95 } 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |