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 Broadway\ReadModel\Projector; |
22
|
|
|
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent; |
23
|
|
|
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent; |
24
|
|
|
use Surfnet\Stepup\Configuration\Event\NumberOfTokensPerIdentityOptionChangedEvent; |
25
|
|
|
use Surfnet\Stepup\Configuration\Event\SelectRaaOptionChangedEvent; |
26
|
|
|
use Surfnet\Stepup\Configuration\Event\ShowRaaContactInformationOptionChangedEvent; |
27
|
|
|
use Surfnet\Stepup\Configuration\Event\UseRaaOptionChangedEvent; |
28
|
|
|
use Surfnet\Stepup\Configuration\Event\UseRaLocationsOptionChangedEvent; |
29
|
|
|
use Surfnet\Stepup\Configuration\Event\UseRaOptionChangedEvent; |
30
|
|
|
use Surfnet\Stepup\Configuration\Event\VerifyEmailOptionChangedEvent; |
31
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionAuthorization; |
32
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions; |
33
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository; |
34
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository; |
35
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository; |
36
|
|
|
|
37
|
|
|
final class InstitutionAuthorizationProjector extends Projector |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @var InstitutionAuthorizationRepository |
41
|
|
|
*/ |
42
|
|
|
private $institutionAuthorizationRepository; |
43
|
|
|
|
44
|
|
|
public function __construct( |
45
|
|
|
InstitutionAuthorizationRepository $institutionAuthorizationRepository |
46
|
|
|
) { |
47
|
|
|
$this->institutionAuthorizationRepository = $institutionAuthorizationRepository; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event) |
51
|
|
|
{ |
52
|
|
|
$institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution); |
53
|
|
|
$institutionAuthorization->useRaOption = $event->useRaOption; |
54
|
|
|
|
55
|
|
|
$this->institutionAuthorizationRepository->save($institutionAuthorization); |
56
|
|
|
} |
57
|
|
|
public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event) |
58
|
|
|
{ |
59
|
|
|
$institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution); |
60
|
|
|
$institutionAuthorization->useRaaOption = $event->useRaaOption; |
61
|
|
|
|
62
|
|
|
$this->institutionAuthorizationRepository->save($institutionAuthorization); |
63
|
|
|
} |
64
|
|
|
public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event) |
65
|
|
|
{ |
66
|
|
|
$institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution); |
67
|
|
|
$institutionAuthorization->selectRaaOption = $event->selectRaaOption; |
68
|
|
|
|
69
|
|
|
$this->institutionAuthorizationRepository->save($institutionAuthorization); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|