1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
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\StepupMiddlewareClient\Identity\Service; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\AccessDeniedToResourceException; |
22
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\MalformedResponseException; |
23
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\ResourceReadException; |
24
|
|
|
use Surfnet\StepupMiddlewareClient\Identity\Dto\RaSecondFactorExportQuery; |
25
|
|
|
use Surfnet\StepupMiddlewareClient\Identity\Dto\RaSecondFactorSearchQuery; |
26
|
|
|
use Surfnet\StepupMiddlewareClient\Service\ApiService; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Provides remote read access to the Middleware's second factors for the RA list. |
30
|
|
|
*/ |
31
|
|
|
class RaSecondFactorService |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var ApiService |
35
|
|
|
*/ |
36
|
|
|
private $apiService; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param ApiService $apiService |
40
|
|
|
*/ |
41
|
|
|
public function __construct(ApiService $apiService) |
42
|
|
|
{ |
43
|
|
|
$this->apiService = $apiService; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param RaSecondFactorSearchQuery $query |
48
|
|
|
* @return null|array |
49
|
|
|
* @throws AccessDeniedToResourceException When the consumer isn't authorised to access given resource. |
50
|
|
|
* @throws ResourceReadException When the server doesn't respond with the resource. |
51
|
|
|
* @throws MalformedResponseException When the server doesn't respond with (well-formed) JSON. |
52
|
|
|
*/ |
53
|
|
|
public function search(RaSecondFactorSearchQuery $query) |
54
|
|
|
{ |
55
|
|
|
return $this->apiService->read('ra-second-factors' . $query->toHttpQuery()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param RaSecondFactorExportQuery $query |
60
|
|
|
* @return null|array |
61
|
|
|
* @throws AccessDeniedToResourceException When the consumer isn't authorised to access given resource. |
62
|
|
|
* @throws ResourceReadException When the server doesn't respond with the resource. |
63
|
|
|
* @throws MalformedResponseException When the server doesn't respond with (well-formed) JSON. |
64
|
|
|
*/ |
65
|
|
|
public function searchForExport(RaSecondFactorExportQuery $query) |
66
|
|
|
{ |
67
|
|
|
return $this->apiService->read('ra-second-factors-export' . $query->toHttpQuery()); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|