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\Service; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Configuration\Value\Institution as ConfigurationInstitution; |
22
|
|
|
use Surfnet\Stepup\Identity\Value\Institution as IdentityInstitution; |
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation; |
24
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionWithPersonalRaDetailsService; |
25
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService; |
26
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService; |
27
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials; |
28
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Service\VettingLocationService as VettingLocationServiceInterface; |
29
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Dto\VettingLocation; |
30
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Institution; |
31
|
|
|
|
32
|
|
|
final class VettingLocationService implements VettingLocationServiceInterface |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var InstitutionWithPersonalRaDetailsService |
36
|
|
|
*/ |
37
|
|
|
private $personalRaDetailsService; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var RaLocationService |
41
|
|
|
*/ |
42
|
|
|
private $raLocationService; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var RaListingService |
46
|
|
|
*/ |
47
|
|
|
private $raListingService; |
48
|
|
|
|
49
|
|
|
public function __construct( |
50
|
|
|
InstitutionWithPersonalRaDetailsService $personalRaDetailsService, |
51
|
|
|
RaLocationService $raLocationService, |
52
|
|
|
RaListingService $raListingService |
53
|
|
|
) { |
54
|
|
|
$this->personalRaDetailsService = $personalRaDetailsService; |
55
|
|
|
$this->raLocationService = $raLocationService; |
56
|
|
|
$this->raListingService = $raListingService; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param Institution $institution |
61
|
|
|
* @return VettingLocation[] |
62
|
|
|
*/ |
63
|
|
|
public function getVettingLocationsFor(Institution $institution) |
64
|
|
|
{ |
65
|
|
|
$configurationInstitution = new ConfigurationInstitution($institution->getInstitution()); |
66
|
|
|
|
67
|
|
|
if ($this->personalRaDetailsService->institutionHasPersonalRaDetails($configurationInstitution)) { |
68
|
|
|
$identityInstitution = new IdentityInstitution($institution->getInstitution()); |
69
|
|
|
|
70
|
|
|
return array_map( |
71
|
|
|
function (RegistrationAuthorityCredentials $credentials) { |
72
|
|
|
return new VettingLocation( |
73
|
|
|
$credentials->getCommonName()->getCommonName(), |
74
|
|
|
$credentials->getLocation()->getLocation(), |
75
|
|
|
$credentials->getContactInformation()->getContactInformation() |
76
|
|
|
); |
77
|
|
|
}, |
78
|
|
|
$this->raListingService->listRegistrationAuthoritiesFor($identityInstitution) |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return array_map( |
83
|
|
|
function (RaLocation $raLocation) { |
84
|
|
|
return new VettingLocation( |
85
|
|
|
$raLocation->name->getRaLocationName(), |
86
|
|
|
$raLocation->location->getLocation(), |
87
|
|
|
$raLocation->contactInformation->getContactInformation() |
88
|
|
|
); |
89
|
|
|
}, |
90
|
|
|
$this->raLocationService->listRaLocationsFor($configurationInstitution) |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|