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