1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2016 SURFnet B.V. |
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\ApiBundle\Configuration\Projector; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent; |
22
|
|
|
use Surfnet\Stepup\Projector\Projector; |
23
|
|
|
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent; |
24
|
|
|
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent; |
25
|
|
|
use Surfnet\Stepup\Configuration\Event\NumberOfTokensPerIdentityOptionChangedEvent; |
26
|
|
|
use Surfnet\Stepup\Configuration\Event\SelfAssertedTokensOptionChangedEvent; |
27
|
|
|
use Surfnet\Stepup\Configuration\Event\SelfVetOptionChangedEvent; |
28
|
|
|
use Surfnet\Stepup\Configuration\Event\ShowRaaContactInformationOptionChangedEvent; |
29
|
|
|
use Surfnet\Stepup\Configuration\Event\SsoOn2faOptionChangedEvent; |
30
|
|
|
use Surfnet\Stepup\Configuration\Event\UseRaLocationsOptionChangedEvent; |
31
|
|
|
use Surfnet\Stepup\Configuration\Event\VerifyEmailOptionChangedEvent; |
32
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions; |
33
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository; |
34
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository; |
35
|
|
|
|
36
|
|
|
final class InstitutionConfigurationOptionsProjector extends Projector |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
public function __construct( |
39
|
|
|
private readonly InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository, |
40
|
|
|
private readonly AllowedSecondFactorRepository $allowedSecondFactorRepository, |
41
|
|
|
) { |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void |
45
|
|
|
{ |
46
|
|
|
$institutionConfigurationOptions = InstitutionConfigurationOptions::create( |
47
|
|
|
$event->institution, |
48
|
|
|
$event->useRaLocationsOption, |
49
|
|
|
$event->showRaaContactInformationOption, |
50
|
|
|
$event->verifyEmailOption, |
51
|
|
|
$event->numberOfTokensPerIdentityOption, |
52
|
|
|
$event->ssoOn2faOption, |
53
|
|
|
$event->selfVetOption, |
54
|
|
|
$event->selfAssertedTokensOption, |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event): void |
61
|
|
|
{ |
62
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
63
|
|
|
$event->institution, |
64
|
|
|
); |
65
|
|
|
$institutionConfigurationOptions->useRaLocationsOption = $event->useRaLocationsOption; |
66
|
|
|
|
67
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function applyShowRaaContactInformationOptionChangedEvent(ShowRaaContactInformationOptionChangedEvent $event,): void |
71
|
|
|
{ |
72
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
73
|
|
|
$event->institution, |
74
|
|
|
); |
75
|
|
|
$institutionConfigurationOptions->showRaaContactInformationOption = $event->showRaaContactInformationOption; |
76
|
|
|
|
77
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function applyVerifyEmailOptionChangedEvent(VerifyEmailOptionChangedEvent $event): void |
81
|
|
|
{ |
82
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
83
|
|
|
$event->institution, |
84
|
|
|
); |
85
|
|
|
$institutionConfigurationOptions->verifyEmailOption = $event->verifyEmailOption; |
86
|
|
|
|
87
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function applyNumberOfTokensPerIdentityOptionChangedEvent(NumberOfTokensPerIdentityOptionChangedEvent $event,): void |
91
|
|
|
{ |
92
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
93
|
|
|
$event->institution, |
94
|
|
|
); |
95
|
|
|
$institutionConfigurationOptions->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption; |
96
|
|
|
|
97
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function applySelfVetOptionChangedEvent(SelfVetOptionChangedEvent $event): void |
101
|
|
|
{ |
102
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
103
|
|
|
$event->institution, |
104
|
|
|
); |
105
|
|
|
$institutionConfigurationOptions->selfVetOption = $event->selfVetOption; |
106
|
|
|
|
107
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function applySsoOn2faOptionChangedEvent(SsoOn2faOptionChangedEvent $event): void |
111
|
|
|
{ |
112
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
113
|
|
|
$event->institution, |
114
|
|
|
); |
115
|
|
|
$institutionConfigurationOptions->ssoOn2faOption = $event->ssoOn2faOption; |
116
|
|
|
|
117
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function applySelfAssertedTokensOptionChangedEvent(SelfAssertedTokensOptionChangedEvent $event): void |
121
|
|
|
{ |
122
|
|
|
$institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor( |
123
|
|
|
$event->institution, |
124
|
|
|
); |
125
|
|
|
$institutionConfigurationOptions->selfAssertedTokensOption = $event->selfAssertedTokensOption; |
126
|
|
|
|
127
|
|
|
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions); |
|
|
|
|
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void |
131
|
|
|
{ |
132
|
|
|
$this->institutionConfigurationOptionsRepository->removeConfigurationOptionsFor($event->institution); |
133
|
|
|
$this->allowedSecondFactorRepository->clearAllowedSecondFactorListFor($event->institution); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void { |
|
|
|
|
137
|
|
|
// do nothing, no sensitive data in this projection |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|