|
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\Stepup\Configuration\Event; |
|
20
|
|
|
|
|
21
|
|
|
use Broadway\Serializer\Serializable as SerializableInterface; |
|
22
|
|
|
use Surfnet\Stepup\Configuration\Value\Institution; |
|
23
|
|
|
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId; |
|
24
|
|
|
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption; |
|
25
|
|
|
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption; |
|
|
|
|
|
|
26
|
|
|
use Surfnet\Stepup\Configuration\Value\SelfVetOption; |
|
|
|
|
|
|
27
|
|
|
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption; |
|
28
|
|
|
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption; |
|
|
|
|
|
|
29
|
|
|
use Surfnet\Stepup\Configuration\Value\SsoRegistrationBypassOption; |
|
|
|
|
|
|
30
|
|
|
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption; |
|
31
|
|
|
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* When the institution configuration contains a new institution, this event is used |
|
35
|
|
|
* to record that institution into the institution configuration. |
|
36
|
|
|
*/ |
|
|
|
|
|
|
37
|
|
|
class NewInstitutionConfigurationCreatedEvent implements SerializableInterface |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
|
|
|
|
|
41
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList) |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct( |
|
44
|
|
|
public InstitutionConfigurationId $institutionConfigurationId, |
|
45
|
|
|
public Institution $institution, |
|
46
|
|
|
public UseRaLocationsOption $useRaLocationsOption, |
|
47
|
|
|
public ShowRaaContactInformationOption $showRaaContactInformationOption, |
|
48
|
|
|
public VerifyEmailOption $verifyEmailOption, |
|
49
|
|
|
public NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption, |
|
50
|
|
|
public SsoOn2faOption $ssoOn2faOption, |
|
51
|
|
|
public SsoRegistrationBypassOption $ssoRegistrationBypassOption, |
|
52
|
|
|
public SelfVetOption $selfVetOption, |
|
53
|
|
|
public SelfAssertedTokensOption $selfAssertedTokensOption |
|
54
|
|
|
) { |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public static function deserialize(array $data): self |
|
58
|
|
|
{ |
|
59
|
|
|
if (!isset($data['verify_email_option'])) { |
|
60
|
|
|
$data['verify_email_option'] = true; |
|
61
|
|
|
} |
|
62
|
|
|
if (!isset($data['number_of_tokens_per_identity_option'])) { |
|
63
|
|
|
$data['number_of_tokens_per_identity_option'] = NumberOfTokensPerIdentityOption::DISABLED; |
|
64
|
|
|
} |
|
65
|
|
|
// If sso on 2fa option is not yet present, default to false |
|
66
|
|
|
if (!isset($data['sso_on_2fa_option'])) { |
|
67
|
|
|
$data['sso_on_2fa_option'] = false; |
|
68
|
|
|
} |
|
69
|
|
|
// If GSSP fallback (sso registration bypass) option is not yet present, default to false |
|
70
|
|
|
if (!isset($data['sso_registration_bypass_option'])) { |
|
71
|
|
|
$data['sso_registration_bypass_option'] = false; |
|
72
|
|
|
} |
|
73
|
|
|
// If self vet option is not yet present, default to false |
|
74
|
|
|
if (!isset($data['self_vet_option'])) { |
|
75
|
|
|
$data['self_vet_option'] = false; |
|
76
|
|
|
} |
|
77
|
|
|
// If self asserted tokens option is not yet present, default to false |
|
78
|
|
|
if (!isset($data['self_asserted_tokens_option'])) { |
|
79
|
|
|
$data['self_asserted_tokens_option'] = false; |
|
80
|
|
|
} |
|
81
|
|
|
return new self( |
|
82
|
|
|
new InstitutionConfigurationId($data['institution_configuration_id']), |
|
83
|
|
|
new Institution($data['institution']), |
|
84
|
|
|
new UseRaLocationsOption($data['use_ra_locations_option']), |
|
85
|
|
|
new ShowRaaContactInformationOption($data['show_raa_contact_information_option']), |
|
86
|
|
|
new VerifyEmailOption($data['verify_email_option']), |
|
87
|
|
|
new NumberOfTokensPerIdentityOption($data['number_of_tokens_per_identity_option']), |
|
88
|
|
|
new SsoOn2faOption($data['sso_on_2fa_option']), |
|
89
|
|
|
new SsoRegistrationBypassOption($data['sso_registration_bypass_option']), // Fallback authentication |
|
90
|
|
|
new SelfVetOption($data['self_vet_option']), |
|
91
|
|
|
new SelfAssertedTokensOption($data['self_asserted_tokens_option']), |
|
92
|
|
|
); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function serialize(): array |
|
96
|
|
|
{ |
|
97
|
|
|
return [ |
|
98
|
|
|
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(), |
|
99
|
|
|
'institution' => $this->institution->getInstitution(), |
|
100
|
|
|
'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(), |
|
101
|
|
|
'show_raa_contact_information_option' => $this->showRaaContactInformationOption->isEnabled(), |
|
102
|
|
|
'verify_email_option' => $this->verifyEmailOption->isEnabled(), |
|
103
|
|
|
'number_of_tokens_per_identity_option' => $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(), |
|
104
|
|
|
'sso_on_2fa_option' => $this->ssoOn2faOption->isEnabled(), |
|
105
|
|
|
'sso_registration_bypass_option' => $this->ssoRegistrationBypassOption->isEnabled(), |
|
106
|
|
|
'self_vet_option' => $this->selfVetOption->isEnabled(), |
|
107
|
|
|
'self_asserted_tokens_option' => $this->selfAssertedTokensOption->isEnabled(), |
|
108
|
|
|
]; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|