1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Processor; |
20
|
|
|
|
21
|
|
|
use Broadway\Processor\Processor; |
22
|
|
|
use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent; |
23
|
|
|
use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent; |
24
|
|
|
use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent; |
25
|
|
|
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent; |
26
|
|
|
use Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenEvent; |
27
|
|
|
use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent; |
28
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorMailService; |
29
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Service\VettingLocationService; |
30
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Institution; |
31
|
|
|
|
32
|
|
|
class EmailProcessor extends Processor |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var SecondFactorMailService |
36
|
|
|
*/ |
37
|
|
|
private $mailService; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var VettingLocationService |
41
|
|
|
*/ |
42
|
|
|
private $vettingLocationService; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param SecondFactorMailService $mailService |
46
|
|
|
* @param VettingLocationService $vettingLocationService |
47
|
|
|
*/ |
48
|
|
|
public function __construct(SecondFactorMailService $mailService, VettingLocationService $vettingLocationService) |
49
|
|
|
{ |
50
|
|
|
$this->mailService = $mailService; |
51
|
|
|
$this->vettingLocationService = $vettingLocationService; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function handlePhonePossessionProvenEvent(PhonePossessionProvenEvent $event) |
55
|
|
|
{ |
56
|
|
|
$this->mailService->sendEmailVerificationEmail( |
57
|
|
|
(string) $event->preferredLocale, |
58
|
|
|
(string) $event->commonName, |
59
|
|
|
(string) $event->email, |
60
|
|
|
$event->emailVerificationNonce |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function handleYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event) |
65
|
|
|
{ |
66
|
|
|
$this->mailService->sendEmailVerificationEmail( |
67
|
|
|
(string) $event->preferredLocale, |
68
|
|
|
(string) $event->commonName, |
69
|
|
|
(string) $event->email, |
70
|
|
|
$event->emailVerificationNonce |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function handleGssfPossessionProvenEvent(GssfPossessionProvenEvent $event) |
75
|
|
|
{ |
76
|
|
|
$this->mailService->sendEmailVerificationEmail( |
77
|
|
|
(string) $event->preferredLocale, |
78
|
|
|
(string) $event->commonName, |
79
|
|
|
(string) $event->email, |
80
|
|
|
$event->emailVerificationNonce |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function handleU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event) |
85
|
|
|
{ |
86
|
|
|
$this->mailService->sendEmailVerificationEmail( |
87
|
|
|
(string) $event->preferredLocale, |
88
|
|
|
(string) $event->commonName, |
89
|
|
|
(string) $event->email, |
90
|
|
|
$event->emailVerificationNonce |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function handleEmailVerifiedEvent(EmailVerifiedEvent $event) |
95
|
|
|
{ |
96
|
|
|
$this->mailService->sendRegistrationEmail( |
97
|
|
|
(string) $event->preferredLocale, |
98
|
|
|
(string) $event->commonName, |
99
|
|
|
(string) $event->email, |
100
|
|
|
$event->registrationCode, |
101
|
|
|
$this->vettingLocationService->getVettingLocationsFor( |
102
|
|
|
new Institution($event->identityInstitution->getInstitution()) |
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function handleSecondFactorVettedEvent(SecondFactorVettedEvent $event) |
108
|
|
|
{ |
109
|
|
|
$this->mailService->sendVettedEmail($event->preferredLocale, $event->commonName, $event->email); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|