[ 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\AttestationStatement; 15 16 use Assert\Assertion; 17 use JsonSerializable; 18 use Webauthn\TrustPath\TrustPath; 19 use Webauthn\TrustPath\TrustPathLoader; 20 21 class AttestationStatement implements JsonSerializable 22 { 23 public const TYPE_NONE = 'none'; 24 public const TYPE_BASIC = 'basic'; 25 public const TYPE_SELF = 'self'; 26 public const TYPE_ATTCA = 'attca'; 27 public const TYPE_ECDAA = 'ecdaa'; 28 29 /** 30 * @var string 31 */ 32 private $fmt; 33 34 /** 35 * @var array 36 */ 37 private $attStmt; 38 39 /** 40 * @var TrustPath 41 */ 42 private $trustPath; 43 44 /** 45 * @var string 46 */ 47 private $type; 48 49 public function __construct(string $fmt, array $attStmt, string $type, TrustPath $trustPath) 50 { 51 $this->fmt = $fmt; 52 $this->attStmt = $attStmt; 53 $this->type = $type; 54 $this->trustPath = $trustPath; 55 } 56 57 public static function createNone(string $fmt, array $attStmt, TrustPath $trustPath): self 58 { 59 return new self($fmt, $attStmt, self::TYPE_NONE, $trustPath); 60 } 61 62 public static function createBasic(string $fmt, array $attStmt, TrustPath $trustPath): self 63 { 64 return new self($fmt, $attStmt, self::TYPE_BASIC, $trustPath); 65 } 66 67 public static function createSelf(string $fmt, array $attStmt, TrustPath $trustPath): self 68 { 69 return new self($fmt, $attStmt, self::TYPE_SELF, $trustPath); 70 } 71 72 public static function createAttCA(string $fmt, array $attStmt, TrustPath $trustPath): self 73 { 74 return new self($fmt, $attStmt, self::TYPE_ATTCA, $trustPath); 75 } 76 77 public static function createEcdaa(string $fmt, array $attStmt, TrustPath $trustPath): self 78 { 79 return new self($fmt, $attStmt, self::TYPE_ECDAA, $trustPath); 80 } 81 82 public function getFmt(): string 83 { 84 return $this->fmt; 85 } 86 87 public function getAttStmt(): array 88 { 89 return $this->attStmt; 90 } 91 92 public function has(string $key): bool 93 { 94 return \array_key_exists($key, $this->attStmt); 95 } 96 97 /** 98 * @return mixed 99 */ 100 public function get(string $key) 101 { 102 Assertion::true($this->has($key), sprintf('The attestation statement has no key "%s".', $key)); 103 104 return $this->attStmt[$key]; 105 } 106 107 public function getTrustPath(): TrustPath 108 { 109 return $this->trustPath; 110 } 111 112 public function getType(): string 113 { 114 return $this->type; 115 } 116 117 public static function createFromArray(array $data): self 118 { 119 foreach (['fmt', 'attStmt', 'trustPath', 'type'] as $key) { 120 Assertion::keyExists($data, $key, sprintf('The key "%s" is missing', $key)); 121 } 122 123 return new self( 124 $data['fmt'], 125 $data['attStmt'], 126 $data['type'], 127 TrustPathLoader::loadTrustPath($data['trustPath']) 128 ); 129 } 130 131 public function jsonSerialize(): array 132 { 133 return [ 134 'fmt' => $this->fmt, 135 'attStmt' => $this->attStmt, 136 'trustPath' => $this->trustPath, 137 'type' => $this->type, 138 ]; 139 } 140 }
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 |