PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.6.0
Defender Security – Malware Scanner, Login Security & Firewall v5.6.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / web-auth / metadata-service / src / VerificationMethodDescriptor.php

VerificationMethodDescriptor.php in Defender Security – Malware Scanner, Login Security & Firewall 5.6.0, at vendor/web-auth/metadata-service/src/VerificationMethodDescriptor.php

169 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /*
6 * The MIT License (MIT)
7 *
8 * Copyright (c) 2014-2021 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\MetadataService;
15
16 use Assert\Assertion;
17 use JsonSerializable;
18 use function Safe\sprintf;
19
20 class VerificationMethodDescriptor implements JsonSerializable
21 {
22 public const USER_VERIFY_PRESENCE = 0x00000001;
23 public const USER_VERIFY_FINGERPRINT = 0x00000002;
24 public const USER_VERIFY_PASSCODE = 0x00000004;
25 public const USER_VERIFY_VOICEPRINT = 0x00000008;
26 public const USER_VERIFY_FACEPRINT = 0x00000010;
27 public const USER_VERIFY_LOCATION = 0x00000020;
28 public const USER_VERIFY_EYEPRINT = 0x00000040;
29 public const USER_VERIFY_PATTERN = 0x00000080;
30 public const USER_VERIFY_HANDPRINT = 0x00000100;
31 public const USER_VERIFY_NONE = 0x00000200;
32 public const USER_VERIFY_ALL = 0x00000400;
33
34 /**
35 * @var int
36 */
37 private $userVerification;
38
39 /**
40 * @var CodeAccuracyDescriptor|null
41 */
42 private $caDesc;
43
44 /**
45 * @var BiometricAccuracyDescriptor|null
46 */
47 private $baDesc;
48
49 /**
50 * @var PatternAccuracyDescriptor|null
51 */
52 private $paDesc;
53
54 public function __construct(int $userVerification, ?CodeAccuracyDescriptor $caDesc = null, ?BiometricAccuracyDescriptor $baDesc = null, ?PatternAccuracyDescriptor $paDesc = null)
55 {
56 Assertion::greaterOrEqualThan($userVerification, 0, Utils::logicException('The parameter "userVerification" is invalid'));
57 $this->userVerification = $userVerification;
58 $this->caDesc = $caDesc;
59 $this->baDesc = $baDesc;
60 $this->paDesc = $paDesc;
61 }
62
63 public function getUserVerification(): int
64 {
65 return $this->userVerification;
66 }
67
68 public function userPresence(): bool
69 {
70 return 0 !== ($this->userVerification & self::USER_VERIFY_PRESENCE);
71 }
72
73 public function fingerprint(): bool
74 {
75 return 0 !== ($this->userVerification & self::USER_VERIFY_FINGERPRINT);
76 }
77
78 public function passcode(): bool
79 {
80 return 0 !== ($this->userVerification & self::USER_VERIFY_PASSCODE);
81 }
82
83 public function voicePrint(): bool
84 {
85 return 0 !== ($this->userVerification & self::USER_VERIFY_VOICEPRINT);
86 }
87
88 public function facePrint(): bool
89 {
90 return 0 !== ($this->userVerification & self::USER_VERIFY_FACEPRINT);
91 }
92
93 public function location(): bool
94 {
95 return 0 !== ($this->userVerification & self::USER_VERIFY_LOCATION);
96 }
97
98 public function eyePrint(): bool
99 {
100 return 0 !== ($this->userVerification & self::USER_VERIFY_EYEPRINT);
101 }
102
103 public function pattern(): bool
104 {
105 return 0 !== ($this->userVerification & self::USER_VERIFY_PATTERN);
106 }
107
108 public function handprint(): bool
109 {
110 return 0 !== ($this->userVerification & self::USER_VERIFY_HANDPRINT);
111 }
112
113 public function none(): bool
114 {
115 return 0 !== ($this->userVerification & self::USER_VERIFY_NONE);
116 }
117
118 public function all(): bool
119 {
120 return 0 !== ($this->userVerification & self::USER_VERIFY_ALL);
121 }
122
123 public function getCaDesc(): ?CodeAccuracyDescriptor
124 {
125 return $this->caDesc;
126 }
127
128 public function getBaDesc(): ?BiometricAccuracyDescriptor
129 {
130 return $this->baDesc;
131 }
132
133 public function getPaDesc(): ?PatternAccuracyDescriptor
134 {
135 return $this->paDesc;
136 }
137
138 public static function createFromArray(array $data): self
139 {
140 $data = Utils::filterNullValues($data);
141 Assertion::keyExists($data, 'userVerification', Utils::logicException('The parameter "userVerification" is missing'));
142 Assertion::integer($data['userVerification'], Utils::logicException('The parameter "userVerification" is invalid'));
143 foreach (['caDesc', 'baDesc', 'paDesc'] as $key) {
144 if (isset($data[$key])) {
145 Assertion::isArray($data[$key], Utils::logicException(sprintf('Invalid parameter "%s"', $key)));
146 }
147 }
148
149 return new self(
150 $data['userVerification'],
151 isset($data['caDesc']) ? CodeAccuracyDescriptor::createFromArray($data['caDesc']) : null,
152 isset($data['baDesc']) ? BiometricAccuracyDescriptor::createFromArray($data['baDesc']) : null,
153 isset($data['paDesc']) ? PatternAccuracyDescriptor::createFromArray($data['paDesc']) : null
154 );
155 }
156
157 public function jsonSerialize(): array
158 {
159 $data = [
160 'userVerification' => $this->userVerification,
161 'caDesc' => null === $this->caDesc ? null : $this->caDesc->jsonSerialize(),
162 'baDesc' => null === $this->baDesc ? null : $this->baDesc->jsonSerialize(),
163 'paDesc' => null === $this->paDesc ? null : $this->paDesc->jsonSerialize(),
164 ];
165
166 return Utils::filterNullValues($data);
167 }
168 }
169