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