|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright 2020 SURFnet B.V. |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
6
|
|
|
* you may not use this file except in compliance with the License. |
|
7
|
|
|
* You may obtain a copy of the License at |
|
8
|
|
|
* |
|
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
* |
|
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14
|
|
|
* See the License for the specific language governing permissions and |
|
15
|
|
|
* limitations under the License. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Dto; |
|
19
|
|
|
|
|
20
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Assert; |
|
21
|
|
|
|
|
22
|
|
|
class RemoteVettingIdenityProviderDto |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $name; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string[] |
|
31
|
|
|
*/ |
|
32
|
|
|
private $descriptions; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $logo; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $slug; |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $entityId; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
private $ssoUrl; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var string |
|
57
|
|
|
*/ |
|
58
|
|
|
private $privateKey; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
private $certificateFile; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param string $identityId |
|
|
|
|
|
|
67
|
|
|
* @param string $secondFactorId |
|
|
|
|
|
|
68
|
|
|
* @return RemoteVettingIdenityProviderDto |
|
69
|
|
|
*/ |
|
70
|
|
|
public static function create(array $configData) |
|
71
|
|
|
{ |
|
72
|
|
|
Assert::notBlank($configData['name'], 'The name of a remote vetting identity provider must not be blank'); |
|
73
|
|
|
Assert::string($configData['name'], 'The name of a remote vetting identity provider must be of type string'); |
|
74
|
|
|
Assert::allString($configData['description'], 'All description entries must be of type string'); |
|
75
|
|
|
Assert::notBlank($configData['logo'], 'The logo of a remote vetting identity provider must not be blank'); |
|
76
|
|
|
Assert::string($configData['logo'], 'The logo of a remote vetting identity provider must be of type string'); |
|
77
|
|
|
Assert::string($configData['slug'], 'The slug of a remote identity provider must be of type string'); |
|
78
|
|
|
Assert::alnum($configData['slug'], 'The slug must be alphanumeric'); |
|
79
|
|
|
|
|
80
|
|
|
Assert::keyExists($configData, 'entityId', 'entityId should be set'); |
|
81
|
|
|
Assert::keyExists($configData, 'ssoUrl', 'ssoUrl should be set'); |
|
82
|
|
|
Assert::keyExists($configData, 'privateKey', 'privateKey should be set'); |
|
83
|
|
|
Assert::keyExists($configData, 'certificateFile', 'certificateFile should be set'); |
|
84
|
|
|
|
|
85
|
|
|
Assert::url($configData['entityId'], 'entityId should be an url'); |
|
86
|
|
|
Assert::url($configData['ssoUrl'], 'ssoUrl should be an url'); |
|
87
|
|
|
Assert::string($configData['privateKey'], 'privateKey should be a string'); |
|
88
|
|
|
Assert::string($configData['certificateFile'], 'certificateFile should be a string'); |
|
89
|
|
|
|
|
90
|
|
|
$identityProvider = new self(); |
|
91
|
|
|
$identityProvider->name = $configData['name']; |
|
92
|
|
|
$identityProvider->descriptions = $configData['description']; |
|
93
|
|
|
$identityProvider->logo = $configData['logo']; |
|
94
|
|
|
$identityProvider->slug = $configData['slug']; |
|
95
|
|
|
|
|
96
|
|
|
$identityProvider->entityId = $configData['entityId']; |
|
97
|
|
|
$identityProvider->ssoUrl = $configData['ssoUrl']; |
|
98
|
|
|
$identityProvider->privateKey = $configData['privateKey']; |
|
99
|
|
|
$identityProvider->certificateFile = $configData['certificateFile']; |
|
100
|
|
|
|
|
101
|
|
|
return $identityProvider; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getName() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->name; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return string[] |
|
|
|
|
|
|
114
|
|
|
*/ |
|
115
|
|
|
public function getDescription($lang) |
|
116
|
|
|
{ |
|
117
|
|
|
Assert::keyExists($this->descriptions, $lang); |
|
118
|
|
|
return $this->descriptions[$lang]; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return string |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getLogo() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->logo; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @return string |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getSlug() |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->slug; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return string |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getSsoUrl(): string |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->ssoUrl; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return string |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getPrivateKey(): string |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->privateKey; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @return string |
|
155
|
|
|
*/ |
|
156
|
|
|
public function getCertificateFile(): string |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->certificateFile; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @return string |
|
163
|
|
|
*/ |
|
164
|
|
|
public function getEntityId(): string |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->entityId; |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.