1 | <?php |
||
35 | class EmailProcessor extends Processor |
||
36 | { |
||
37 | /** |
||
38 | * @var SecondFactorMailService |
||
39 | */ |
||
40 | private $mailService; |
||
41 | |||
42 | /** |
||
43 | * @var RaListingService |
||
44 | */ |
||
45 | private $raListingService; |
||
46 | |||
47 | /** |
||
48 | * @var InstitutionConfigurationOptionsService |
||
49 | */ |
||
50 | private $institutionConfigurationOptionsService; |
||
51 | |||
52 | /** |
||
53 | * @var RaLocationService |
||
54 | */ |
||
55 | private $raLocationsService; |
||
56 | |||
57 | /** |
||
58 | * @param SecondFactorMailService $mailService |
||
59 | * @param RaListingService $raListingService |
||
60 | * @param InstitutionConfigurationOptionsService $institutionConfigurationOptionsService |
||
61 | * @param RaLocationService $raLocationsService |
||
62 | */ |
||
63 | public function __construct( |
||
64 | SecondFactorMailService $mailService, |
||
65 | RaListingService $raListingService, |
||
66 | InstitutionConfigurationOptionsService $institutionConfigurationOptionsService, |
||
|
|||
67 | RaLocationService $raLocationsService |
||
68 | ) { |
||
69 | $this->mailService = $mailService; |
||
70 | $this->raListingService = $raListingService; |
||
71 | $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService; |
||
72 | $this->raLocationsService = $raLocationsService; |
||
73 | } |
||
74 | |||
75 | public function handlePhonePossessionProvenEvent(PhonePossessionProvenEvent $event) |
||
84 | |||
85 | public function handleYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event) |
||
94 | |||
95 | public function handleGssfPossessionProvenEvent(GssfPossessionProvenEvent $event) |
||
104 | |||
105 | public function handleU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event) |
||
114 | |||
115 | public function handleEmailVerifiedEvent(EmailVerifiedEvent $event) |
||
116 | { |
||
117 | $institution = new Institution($event->identityInstitution->getInstitution()); |
||
118 | $institutionConfigurationOptions = $this->institutionConfigurationOptionsService |
||
119 | ->findInstitutionConfigurationOptionsFor($institution); |
||
120 | |||
121 | if ($institutionConfigurationOptions->useRaLocationsOption->isEnabled()) { |
||
122 | $this->sendRegistrationEmailWithRaLocations($event, $institution); |
||
123 | |||
124 | return; |
||
125 | } |
||
126 | |||
127 | $ras = $this->raListingService->listRegistrationAuthoritiesFor($event->identityInstitution); |
||
128 | |||
129 | if ($institutionConfigurationOptions->showRaaContactInformationOption->isEnabled()) { |
||
130 | $this->sendRegistrationEmailWithRas($event, $ras); |
||
131 | |||
132 | return; |
||
133 | } |
||
134 | |||
135 | $rasWithoutRaas = array_filter($ras, function (RegistrationAuthorityCredentials $ra) { |
||
136 | return !$ra->isRaa(); |
||
137 | }); |
||
138 | |||
139 | $this->sendRegistrationEmailWithRas($event, $rasWithoutRaas); |
||
140 | } |
||
141 | |||
142 | public function handleSecondFactorVettedEvent(SecondFactorVettedEvent $event) |
||
146 | |||
147 | /** |
||
148 | * @param EmailVerifiedEvent $event |
||
149 | * @param Institution $institution |
||
150 | */ |
||
151 | private function sendRegistrationEmailWithRaLocations(EmailVerifiedEvent $event, Institution $institution) |
||
161 | |||
162 | /** |
||
163 | * @param EmailVerifiedEvent $event |
||
164 | * @param RegistrationAuthorityCredentials[] $ras |
||
165 | */ |
||
166 | private function sendRegistrationEmailWithRas(EmailVerifiedEvent $event, array $ras) |
||
176 | } |
||
177 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.