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