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