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