@@ 218-259 (lines=42) @@ | ||
215 | ); |
|
216 | } |
|
217 | ||
218 | public function provePossessionOfYubikey( |
|
219 | SecondFactorId $secondFactorId, |
|
220 | YubikeyPublicId $yubikeyPublicId, |
|
221 | $emailVerificationRequired, |
|
222 | EmailVerificationWindow $emailVerificationWindow |
|
223 | ) { |
|
224 | $this->assertNotForgotten(); |
|
225 | $this->assertUserMayAddSecondFactor(); |
|
226 | ||
227 | if ($emailVerificationRequired) { |
|
228 | $emailVerificationNonce = TokenGenerator::generateNonce(); |
|
229 | ||
230 | $this->apply( |
|
231 | new YubikeyPossessionProvenEvent( |
|
232 | $this->id, |
|
233 | $this->institution, |
|
234 | $secondFactorId, |
|
235 | $yubikeyPublicId, |
|
236 | $emailVerificationRequired, |
|
237 | $emailVerificationWindow, |
|
238 | $emailVerificationNonce, |
|
239 | $this->commonName, |
|
240 | $this->email, |
|
241 | $this->preferredLocale |
|
242 | ) |
|
243 | ); |
|
244 | } else { |
|
245 | $this->apply( |
|
246 | new YubikeyPossessionProvenAndVerifiedEvent( |
|
247 | $this->id, |
|
248 | $this->institution, |
|
249 | $secondFactorId, |
|
250 | $yubikeyPublicId, |
|
251 | $this->commonName, |
|
252 | $this->email, |
|
253 | $this->preferredLocale, |
|
254 | DateTime::now(), |
|
255 | OtpGenerator::generate(8) |
|
256 | ) |
|
257 | ); |
|
258 | } |
|
259 | } |
|
260 | ||
261 | public function provePossessionOfPhone( |
|
262 | SecondFactorId $secondFactorId, |
|
@@ 261-302 (lines=42) @@ | ||
258 | } |
|
259 | } |
|
260 | ||
261 | public function provePossessionOfPhone( |
|
262 | SecondFactorId $secondFactorId, |
|
263 | PhoneNumber $phoneNumber, |
|
264 | $emailVerificationRequired, |
|
265 | EmailVerificationWindow $emailVerificationWindow |
|
266 | ) { |
|
267 | $this->assertNotForgotten(); |
|
268 | $this->assertUserMayAddSecondFactor(); |
|
269 | ||
270 | if ($emailVerificationRequired) { |
|
271 | $emailVerificationNonce = TokenGenerator::generateNonce(); |
|
272 | ||
273 | $this->apply( |
|
274 | new PhonePossessionProvenEvent( |
|
275 | $this->id, |
|
276 | $this->institution, |
|
277 | $secondFactorId, |
|
278 | $phoneNumber, |
|
279 | $emailVerificationRequired, |
|
280 | $emailVerificationWindow, |
|
281 | $emailVerificationNonce, |
|
282 | $this->commonName, |
|
283 | $this->email, |
|
284 | $this->preferredLocale |
|
285 | ) |
|
286 | ); |
|
287 | } else { |
|
288 | $this->apply( |
|
289 | new PhonePossessionProvenAndVerifiedEvent( |
|
290 | $this->id, |
|
291 | $this->institution, |
|
292 | $secondFactorId, |
|
293 | $phoneNumber, |
|
294 | $this->commonName, |
|
295 | $this->email, |
|
296 | $this->preferredLocale, |
|
297 | DateTime::now(), |
|
298 | OtpGenerator::generate(8) |
|
299 | ) |
|
300 | ); |
|
301 | } |
|
302 | } |
|
303 | ||
304 | public function provePossessionOfGssf( |
|
305 | SecondFactorId $secondFactorId, |
|
@@ 304-348 (lines=45) @@ | ||
301 | } |
|
302 | } |
|
303 | ||
304 | public function provePossessionOfGssf( |
|
305 | SecondFactorId $secondFactorId, |
|
306 | StepupProvider $provider, |
|
307 | GssfId $gssfId, |
|
308 | $emailVerificationRequired, |
|
309 | EmailVerificationWindow $emailVerificationWindow |
|
310 | ) { |
|
311 | $this->assertNotForgotten(); |
|
312 | $this->assertUserMayAddSecondFactor(); |
|
313 | ||
314 | if ($emailVerificationRequired) { |
|
315 | $emailVerificationNonce = TokenGenerator::generateNonce(); |
|
316 | ||
317 | $this->apply( |
|
318 | new GssfPossessionProvenEvent( |
|
319 | $this->id, |
|
320 | $this->institution, |
|
321 | $secondFactorId, |
|
322 | $provider, |
|
323 | $gssfId, |
|
324 | $emailVerificationRequired, |
|
325 | $emailVerificationWindow, |
|
326 | $emailVerificationNonce, |
|
327 | $this->commonName, |
|
328 | $this->email, |
|
329 | $this->preferredLocale |
|
330 | ) |
|
331 | ); |
|
332 | } else { |
|
333 | $this->apply( |
|
334 | new GssfPossessionProvenAndVerifiedEvent( |
|
335 | $this->id, |
|
336 | $this->institution, |
|
337 | $secondFactorId, |
|
338 | $provider, |
|
339 | $gssfId, |
|
340 | $this->commonName, |
|
341 | $this->email, |
|
342 | $this->preferredLocale, |
|
343 | DateTime::now(), |
|
344 | OtpGenerator::generate(8) |
|
345 | ) |
|
346 | ); |
|
347 | } |
|
348 | } |
|
349 | ||
350 | public function provePossessionOfU2fDevice( |
|
351 | SecondFactorId $secondFactorId, |
|
@@ 350-391 (lines=42) @@ | ||
347 | } |
|
348 | } |
|
349 | ||
350 | public function provePossessionOfU2fDevice( |
|
351 | SecondFactorId $secondFactorId, |
|
352 | U2fKeyHandle $keyHandle, |
|
353 | $emailVerificationRequired, |
|
354 | EmailVerificationWindow $emailVerificationWindow |
|
355 | ) { |
|
356 | $this->assertNotForgotten(); |
|
357 | $this->assertUserMayAddSecondFactor(); |
|
358 | ||
359 | if ($emailVerificationRequired) { |
|
360 | $emailVerificationNonce = TokenGenerator::generateNonce(); |
|
361 | ||
362 | $this->apply( |
|
363 | new U2fDevicePossessionProvenEvent( |
|
364 | $this->id, |
|
365 | $this->institution, |
|
366 | $secondFactorId, |
|
367 | $keyHandle, |
|
368 | $emailVerificationRequired, |
|
369 | $emailVerificationWindow, |
|
370 | $emailVerificationNonce, |
|
371 | $this->commonName, |
|
372 | $this->email, |
|
373 | $this->preferredLocale |
|
374 | ) |
|
375 | ); |
|
376 | } else { |
|
377 | $this->apply( |
|
378 | new U2fDevicePossessionProvenAndVerifiedEvent( |
|
379 | $this->id, |
|
380 | $this->institution, |
|
381 | $secondFactorId, |
|
382 | $keyHandle, |
|
383 | $this->commonName, |
|
384 | $this->email, |
|
385 | $this->preferredLocale, |
|
386 | DateTime::now(), |
|
387 | OtpGenerator::generate(8) |
|
388 | ) |
|
389 | ); |
|
390 | } |
|
391 | } |
|
392 | ||
393 | public function verifyEmail($verificationNonce) |
|
394 | { |