These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * @copyright (c) 2015, Paul Sohier |
||
5 | * @copyright (c) 2014 Yubico AB |
||
6 | * @license BSD-2-Clause |
||
7 | * |
||
8 | * |
||
9 | * Orignal Copyright: |
||
10 | * Copyright (c) 2014 Yubico AB |
||
11 | * All rights reserved. |
||
12 | * |
||
13 | * Redistribution and use in source and binary forms, with or without |
||
14 | * modification, are permitted provided that the following conditions are |
||
15 | * met: |
||
16 | * |
||
17 | * * Redistributions of source code must retain the above copyright |
||
18 | * notice, this list of conditions and the following disclaimer. |
||
19 | * |
||
20 | * * Redistributions in binary form must reproduce the above |
||
21 | * copyright notice, this list of conditions and the following |
||
22 | * disclaimer in the documentation and/or other materials provided |
||
23 | * with the distribution. |
||
24 | * |
||
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
26 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
27 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
28 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
29 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
31 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
36 | */ |
||
37 | |||
38 | namespace paul999\u2f; |
||
39 | use JsonSerializable; |
||
40 | |||
41 | /** |
||
42 | * Class returned for successful registrations |
||
43 | * |
||
44 | * @package u2flib_server |
||
45 | */ |
||
46 | class Registration implements RegistrationInterface, JsonSerializable |
||
47 | { |
||
48 | /** |
||
49 | * The key handle of the registered authenticator |
||
50 | * @var string |
||
51 | */ |
||
52 | private $keyHandle; |
||
53 | |||
54 | /** |
||
55 | * The public key of the registered authenticator |
||
56 | * @var string |
||
57 | */ |
||
58 | private $publicKey; |
||
59 | |||
60 | /** |
||
61 | * The attestation certificate of the registered authenticator |
||
62 | * @var string |
||
63 | */ |
||
64 | private $certificate; |
||
65 | |||
66 | /** |
||
67 | * The counter associated with this registration |
||
68 | * @var int |
||
69 | */ |
||
70 | private $counter = -1; |
||
71 | |||
72 | /** |
||
73 | * Registration constructor. |
||
74 | * @param string $keyHandle |
||
75 | * @param string $publicKey |
||
76 | * @param string $certificate |
||
77 | * @param int $counter |
||
78 | */ |
||
79 | public function __construct($keyHandle = null, $publicKey = null, $certificate = null, $counter = -1) |
||
80 | { |
||
81 | $this->setKeyHandle($keyHandle); |
||
82 | $this->setPublicKey($publicKey); |
||
83 | $this->setCertificate($certificate); |
||
84 | $this->setCounter($counter); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getKeyHandle() |
||
91 | { |
||
92 | return $this->keyHandle; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param string $keyHandle |
||
97 | * @return RegistrationInterface |
||
98 | */ |
||
99 | public function setKeyHandle($keyHandle) |
||
100 | { |
||
101 | $this->keyHandle = $keyHandle; |
||
102 | return $this; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getPublicKey() |
||
109 | { |
||
110 | return $this->publicKey; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @param string $publicKey |
||
115 | * @return RegistrationInterface |
||
116 | */ |
||
117 | public function setPublicKey($publicKey) |
||
118 | { |
||
119 | $this->publicKey = $publicKey; |
||
120 | return $this; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getCertificate() |
||
127 | { |
||
128 | return $this->certificate; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param string $certificate |
||
133 | * @return RegistrationInterface |
||
134 | */ |
||
135 | public function setCertificate($certificate) |
||
136 | { |
||
137 | $this->certificate = $certificate; |
||
138 | return $this; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @return int |
||
143 | */ |
||
144 | public function getCounter() |
||
145 | { |
||
146 | return $this->counter; |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @param int $counter |
||
151 | * @return RegistrationInterface |
||
152 | */ |
||
153 | public function setCounter($counter) |
||
154 | { |
||
155 | $this->counter = $counter; |
||
156 | return $this; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Specify data which should be serialized to JSON |
||
161 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
162 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
163 | * which is a value of any type other than a resource. |
||
164 | * @since 5.4.0 |
||
165 | */ |
||
166 | function jsonSerialize() |
||
0 ignored issues
–
show
|
|||
167 | { |
||
168 | return [ |
||
169 | 'keyHandle' => $this->getKeyHandle(), |
||
170 | 'publicKey' => $this->getPublicKey(), |
||
171 | 'certificate' => $this->getCertificate(), |
||
172 | 'counter' => $this->getCounter(), |
||
173 | ]; |
||
174 | } |
||
175 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.