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