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\Identity\Service; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Value\SecondFactorId; |
22
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\UnverifiedSecondFactor; |
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VerifiedSecondFactor; |
24
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettedSecondFactor; |
25
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\UnverifiedSecondFactorQuery; |
26
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorOfIdentityQuery; |
27
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorQuery; |
28
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VettedSecondFactorQuery; |
29
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository; |
30
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository; |
31
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository; |
32
|
|
|
|
33
|
|
|
class SecondFactorService extends AbstractSearchService |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var UnverifiedSecondFactorRepository |
37
|
|
|
*/ |
38
|
|
|
private $unverifiedRepository; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var VerifiedSecondFactorRepository |
42
|
|
|
*/ |
43
|
|
|
private $verifiedRepository; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var VettedSecondFactorRepository |
47
|
|
|
*/ |
48
|
|
|
private $vettedRepository; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param UnverifiedSecondFactorRepository $unverifiedRepository |
52
|
|
|
* @param VerifiedSecondFactorRepository $verifiedRepository |
53
|
|
|
* @param VettedSecondFactorRepository $vettedRepository |
54
|
|
|
*/ |
55
|
|
|
public function __construct( |
56
|
|
|
UnverifiedSecondFactorRepository $unverifiedRepository, |
57
|
|
|
VerifiedSecondFactorRepository $verifiedRepository, |
58
|
|
|
VettedSecondFactorRepository $vettedRepository |
59
|
|
|
) { |
60
|
|
|
$this->unverifiedRepository = $unverifiedRepository; |
61
|
|
|
$this->verifiedRepository = $verifiedRepository; |
62
|
|
|
$this->vettedRepository = $vettedRepository; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param UnverifiedSecondFactorQuery $query |
67
|
|
|
* @return \Pagerfanta\Pagerfanta |
68
|
|
|
*/ |
69
|
|
|
public function searchUnverifiedSecondFactors(UnverifiedSecondFactorQuery $query) |
70
|
|
|
{ |
71
|
|
|
$doctrineQuery = $this->unverifiedRepository->createSearchQuery($query); |
72
|
|
|
|
73
|
|
|
$paginator = $this->createPaginatorFrom($doctrineQuery, $query); |
74
|
|
|
|
75
|
|
|
return $paginator; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param VerifiedSecondFactorQuery $query |
80
|
|
|
* @return \Pagerfanta\Pagerfanta |
81
|
|
|
*/ |
82
|
|
|
public function searchVerifiedSecondFactors(VerifiedSecondFactorQuery $query) |
83
|
|
|
{ |
84
|
|
|
$doctrineQuery = $this->verifiedRepository->createSearchQuery($query); |
85
|
|
|
|
86
|
|
|
$paginator = $this->createPaginatorFrom($doctrineQuery, $query); |
87
|
|
|
|
88
|
|
|
return $paginator; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param VerifiedSecondFactorOfIdentityQuery $query |
94
|
|
|
* @return \Pagerfanta\Pagerfanta |
95
|
|
|
*/ |
96
|
|
|
public function searchVerifiedSecondFactorsOfIdentity(VerifiedSecondFactorOfIdentityQuery $query) |
97
|
|
|
{ |
98
|
|
|
$doctrineQuery = $this->verifiedRepository->createSearchForIdentityQuery($query); |
99
|
|
|
|
100
|
|
|
$paginator = $this->createPaginatorFrom($doctrineQuery, $query); |
101
|
|
|
|
102
|
|
|
return $paginator; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param VettedSecondFactorQuery $query |
107
|
|
|
* @return \Pagerfanta\Pagerfanta |
108
|
|
|
*/ |
109
|
|
|
public function searchVettedSecondFactors(VettedSecondFactorQuery $query) |
110
|
|
|
{ |
111
|
|
|
$doctrineQuery = $this->vettedRepository->createSearchQuery($query); |
112
|
|
|
|
113
|
|
|
$paginator = $this->createPaginatorFrom($doctrineQuery, $query); |
114
|
|
|
|
115
|
|
|
return $paginator; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param SecondFactorId $id |
120
|
|
|
* @return null|UnverifiedSecondFactor |
121
|
|
|
*/ |
122
|
|
|
public function findUnverified(SecondFactorId $id) |
123
|
|
|
{ |
124
|
|
|
return $this->unverifiedRepository->find($id); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param SecondFactorId $id |
130
|
|
|
* @return null|VerifiedSecondFactor |
131
|
|
|
*/ |
132
|
|
|
public function findVerified(SecondFactorId $id) |
133
|
|
|
{ |
134
|
|
|
return $this->verifiedRepository->find($id); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param SecondFactorId $id |
140
|
|
|
* @return null|VettedSecondFactor |
141
|
|
|
*/ |
142
|
|
|
public function findVetted(SecondFactorId $id) |
143
|
|
|
{ |
144
|
|
|
return $this->vettedRepository->find($id); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|