1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2014 Roave, LLC. |
4
|
|
|
* All rights reserved. |
5
|
|
|
* |
6
|
|
|
* Redistribution and use in source and binary forms, with or without |
7
|
|
|
* modification, are permitted provided that the following conditions |
8
|
|
|
* are met: |
9
|
|
|
* |
10
|
|
|
* * Redistributions of source code must retain the above copyright |
11
|
|
|
* notice, this list of conditions and the following disclaimer. |
12
|
|
|
* |
13
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
14
|
|
|
* notice, this list of conditions and the following disclaimer in |
15
|
|
|
* the documentation and/or other materials provided with the |
16
|
|
|
* distribution. |
17
|
|
|
* |
18
|
|
|
* * Neither the names of the copyright holders nor the names of the |
19
|
|
|
* contributors may be used to endorse or promote products derived |
20
|
|
|
* from this software without specific prior written permission. |
21
|
|
|
* |
22
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
23
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
24
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
25
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
26
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
27
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
28
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
29
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
30
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
32
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
33
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
34
|
|
|
* |
35
|
|
|
* @author Antoine Hedgecock |
36
|
|
|
* |
37
|
|
|
* @copyright 2014 Roave, LLC |
38
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
39
|
|
|
*/ |
40
|
|
|
|
41
|
|
|
namespace Roave\NonceUtility\Entity; |
42
|
|
|
|
43
|
|
|
use DateTime; |
44
|
|
|
use Roave\NonceUtility\Stdlib\NonceOwnerInterface; |
45
|
|
|
|
46
|
|
|
class NonceEntity |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
protected $nonce; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
protected $namespace; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string|null |
60
|
|
|
*/ |
61
|
|
|
protected $httpUserAgent; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string|null |
65
|
|
|
*/ |
66
|
|
|
protected $ipAddress; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var DateTime|null |
70
|
|
|
*/ |
71
|
|
|
protected $consumedAt = null; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var DateTime|null |
75
|
|
|
*/ |
76
|
|
|
protected $expiresAt = null; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var DateTime|null |
80
|
|
|
*/ |
81
|
|
|
protected $createdAt = null; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var NonceOwnerInterface |
85
|
|
|
*/ |
86
|
|
|
protected $owner = null; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return null|string |
90
|
|
|
*/ |
91
|
1 |
|
public function getHttpUserAgent() |
92
|
|
|
{ |
93
|
1 |
|
return $this->httpUserAgent; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param null|string $httpUserAgent |
98
|
|
|
*/ |
99
|
1 |
|
public function setHttpUserAgent($httpUserAgent) |
100
|
|
|
{ |
101
|
1 |
|
$this->httpUserAgent = (string) $httpUserAgent; |
102
|
1 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return null|string |
106
|
|
|
*/ |
107
|
1 |
|
public function getIpAddress() |
108
|
|
|
{ |
109
|
1 |
|
return $this->ipAddress; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param null|string $ipAddress |
114
|
|
|
*/ |
115
|
1 |
|
public function setIpAddress($ipAddress) |
116
|
|
|
{ |
117
|
1 |
|
$this->ipAddress = (string) $ipAddress; |
118
|
1 |
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
1 |
|
public function getNamespace() |
124
|
|
|
{ |
125
|
1 |
|
return $this->namespace; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $namespace |
130
|
|
|
*/ |
131
|
1 |
|
public function setNamespace($namespace) |
132
|
|
|
{ |
133
|
1 |
|
$this->namespace = (string) $namespace; |
134
|
1 |
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return DateTime|null |
138
|
|
|
*/ |
139
|
1 |
|
public function getConsumedAt() |
140
|
|
|
{ |
141
|
1 |
|
return $this->consumedAt; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param DateTime|null $consumedAt |
146
|
|
|
*/ |
147
|
1 |
|
public function setConsumedAt(DateTime $consumedAt = null) |
148
|
|
|
{ |
149
|
1 |
|
$this->consumedAt = $consumedAt; |
150
|
1 |
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return DateTime|null |
154
|
|
|
*/ |
155
|
1 |
|
public function getCreatedAt() |
156
|
|
|
{ |
157
|
1 |
|
return $this->createdAt; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @param DateTime|null $createdAt |
162
|
|
|
*/ |
163
|
1 |
|
public function setCreatedAt(DateTime $createdAt = null) |
164
|
|
|
{ |
165
|
1 |
|
$this->createdAt = $createdAt; |
166
|
1 |
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return DateTime|null |
170
|
|
|
*/ |
171
|
1 |
|
public function getExpiresAt() |
172
|
|
|
{ |
173
|
1 |
|
return $this->expiresAt; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param DateTime|null $expiresAt |
178
|
|
|
*/ |
179
|
1 |
|
public function setExpiresAt(DateTime $expiresAt = null) |
180
|
|
|
{ |
181
|
1 |
|
$this->expiresAt = $expiresAt; |
182
|
1 |
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return NonceOwnerInterface |
186
|
|
|
*/ |
187
|
1 |
|
public function getOwner() |
188
|
|
|
{ |
189
|
1 |
|
return $this->owner; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param NonceOwnerInterface $owner |
194
|
|
|
*/ |
195
|
1 |
|
public function setOwner(NonceOwnerInterface $owner) |
196
|
|
|
{ |
197
|
1 |
|
$this->owner = $owner; |
198
|
1 |
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return string |
202
|
|
|
*/ |
203
|
1 |
|
public function getNonce() |
204
|
|
|
{ |
205
|
1 |
|
return $this->nonce; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param string $nonce |
210
|
|
|
*/ |
211
|
1 |
|
public function setNonce($nonce) |
212
|
|
|
{ |
213
|
1 |
|
$this->nonce = (string) $nonce; |
214
|
1 |
|
} |
215
|
|
|
} |
216
|
|
|
|