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\StepupMiddleware\ApiBundle\Controller; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Value\IdentityId; |
22
|
|
|
use Surfnet\Stepup\Identity\Value\Institution; |
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException; |
24
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\SecondFactorAuditLogQuery; |
25
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\AuditLogService; |
26
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse; |
27
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
28
|
|
|
use Symfony\Component\HttpFoundation\Request; |
29
|
|
|
|
30
|
|
|
final class AuditLogController extends Controller |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var AuditLogService |
34
|
|
|
*/ |
35
|
|
|
private $auditLogService; |
36
|
|
|
|
37
|
|
|
public function __construct(AuditLogService $service) |
38
|
|
|
{ |
39
|
|
|
$this->auditLogService = $service; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function secondFactorAuditLogAction(Request $request, Institution $institution) |
43
|
|
|
{ |
44
|
|
|
$this->denyAccessUnlessGranted(['ROLE_RA']); |
45
|
|
|
|
46
|
|
|
$identityId = $request->get('identityId'); |
47
|
|
|
if (empty($identityId)) { |
48
|
|
|
throw new BadApiRequestException(['This API-call MUST include the identityId as get parameter']); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$query = new SecondFactorAuditLogQuery(); |
52
|
|
|
$query->identityInstitution = $institution; |
53
|
|
|
$query->identityId = new IdentityId($identityId); |
54
|
|
|
$query->orderBy = $request->get('orderBy', $query->orderBy); |
55
|
|
|
$query->orderDirection = $request->get('orderDirection', $query->orderDirection); |
56
|
|
|
$query->pageNumber = $request->get('p', 1); |
57
|
|
|
|
58
|
|
|
$paginator = $this->auditLogService->searchSecondFactorAuditLog($query); |
59
|
|
|
|
60
|
|
|
return JsonCollectionResponse::fromPaginator($paginator); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|