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
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Class for building up an authentication request |
42
|
|
|
* |
43
|
|
|
* @package u2flib_server |
44
|
|
|
*/ |
45
|
|
|
class SignRequest implements SignRequestInterface |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* Protocol version |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
public $version = U2F_interface::U2F_VERSION; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Authentication challenge |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
public $challenge; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Key handle of a registered authenticator |
61
|
|
|
* @var string |
62
|
|
|
*/ |
63
|
|
|
public $keyHandle; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Application id |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
public $appId; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* SignRequest constructor. |
73
|
|
|
* @param string $challenge |
74
|
|
|
* @param string $keyHandle |
75
|
|
|
* @param string $appId |
76
|
|
|
*/ |
77
|
|
|
public function __construct($challenge, $keyHandle, $appId) |
78
|
|
|
{ |
79
|
|
|
$this->challenge = $challenge; |
80
|
|
|
$this->keyHandle = $keyHandle; |
81
|
|
|
$this->appId = $appId; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getVersion() |
88
|
|
|
{ |
89
|
|
|
return $this->version; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $version |
94
|
|
|
* @return SignRequestInterface |
95
|
|
|
*/ |
96
|
|
|
public function setVersion($version) |
97
|
|
|
{ |
98
|
|
|
$this->version = $version; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getChallenge() |
106
|
|
|
{ |
107
|
|
|
return $this->challenge; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $challenge |
112
|
|
|
* @return SignRequestInterface |
113
|
|
|
*/ |
114
|
|
|
public function setChallenge($challenge) |
115
|
|
|
{ |
116
|
|
|
$this->challenge = $challenge; |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getKeyHandle() |
124
|
|
|
{ |
125
|
|
|
return $this->keyHandle; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $keyHandle |
130
|
|
|
* @return SignRequestInterface |
131
|
|
|
*/ |
132
|
|
|
public function setKeyHandle($keyHandle) |
133
|
|
|
{ |
134
|
|
|
$this->keyHandle = $keyHandle; |
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return string |
140
|
|
|
*/ |
141
|
|
|
public function getAppId() |
142
|
|
|
{ |
143
|
|
|
return $this->appId; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @param string $appId |
148
|
|
|
* @return SignRequestInterface |
149
|
|
|
*/ |
150
|
|
|
public function setAppId($appId) |
151
|
|
|
{ |
152
|
|
|
$this->appId = $appId; |
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
} |