1 | <?php |
||
43 | class SecondFactorService |
||
44 | { |
||
45 | /** |
||
46 | * @var \Surfnet\StepupMiddlewareClientBundle\Identity\Service\SecondFactorService |
||
47 | */ |
||
48 | private $secondFactors; |
||
49 | |||
50 | /** |
||
51 | * @var \Surfnet\StepupSelfService\SelfServiceBundle\Service\CommandService |
||
52 | */ |
||
53 | private $commandService; |
||
54 | |||
55 | /** |
||
56 | * @param MiddlewareSecondFactorService $secondFactors |
||
57 | * @param CommandService $commandService |
||
58 | */ |
||
59 | public function __construct( |
||
66 | |||
67 | /** |
||
68 | * @param string $identityId |
||
69 | * @param string $nonce |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function verifyEmail($identityId, $nonce) |
||
82 | |||
83 | /** |
||
84 | * @param RevokeCommand $command |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function revoke(RevokeCommand $command) |
||
88 | { |
||
89 | /** @var UnverifiedSecondFactor|VerifiedSecondFactor|VettedSecondFactor $secondFactor */ |
||
90 | $secondFactor = $command->secondFactor; |
||
91 | |||
92 | $apiCommand = new RevokeOwnSecondFactorCommand(); |
||
93 | $apiCommand->identityId = $command->identity->id; |
||
94 | $apiCommand->secondFactorId = $secondFactor->id; |
||
95 | |||
96 | $result = $this->commandService->execute($apiCommand); |
||
97 | |||
98 | return $result->isSuccessful(); |
||
99 | } |
||
100 | |||
101 | public function selfVet(SelfVetCommand $command): bool |
||
102 | { |
||
103 | $apiCommand = new SelfVetSecondFactorCommand(); |
||
104 | $apiCommand->identityId = $command->identity->id; |
||
105 | $apiCommand->registrationCode = $command->secondFactor->registrationCode; |
||
106 | $apiCommand->secondFactorIdentifier = $command->secondFactor->id; |
||
107 | $apiCommand->secondFactorId = $command->secondFactor->secondFactorIdentifier; |
||
108 | $apiCommand->secondFactorType = $command->secondFactor->type; |
||
109 | $apiCommand->authorityId = $command->identity->id; |
||
110 | $apiCommand->authoringSecondFactorIdentifier = $command->authoringLoa; |
||
111 | |||
112 | $result = $this->commandService->execute($apiCommand); |
||
113 | return $result->isSuccessful(); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Returns whether the given registrant has registered second factors with Step-up. The state of the second factor |
||
118 | * is irrelevant. |
||
119 | * |
||
120 | * @param string $identityId |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function doSecondFactorsExistForIdentity($identityId) |
||
133 | |||
134 | public function identityHasSecondFactorOfStateWithId($identityId, $state, $secondFactorId) |
||
162 | |||
163 | /** |
||
164 | * Returns the given registrant's unverified second factors. |
||
165 | * |
||
166 | * @param string $identityId |
||
167 | * @return UnverifiedSecondFactorCollection |
||
|
|||
168 | */ |
||
169 | public function findUnverifiedByIdentity($identityId) |
||
175 | |||
176 | /** |
||
177 | * Returns the given registrant's verified second factors. |
||
178 | * |
||
179 | * @param string $identityId |
||
180 | * @return VerifiedSecondFactorCollection |
||
181 | */ |
||
182 | public function findVerifiedByIdentity($identityId) |
||
188 | |||
189 | /** |
||
190 | * Returns the given registrant's verified second factors. |
||
191 | * |
||
192 | * @param string $identityId |
||
193 | * @return VettedSecondFactorCollection |
||
194 | */ |
||
195 | public function findVettedByIdentity($identityId) |
||
201 | |||
202 | /** |
||
203 | * @param string $secondFactorId |
||
204 | * @return null|UnverifiedSecondFactor |
||
205 | */ |
||
206 | public function findOneUnverified($secondFactorId) |
||
210 | |||
211 | /** |
||
212 | * @param string $secondFactorId |
||
213 | * @return null|VerifiedSecondFactor |
||
214 | */ |
||
215 | public function findOneVerified($secondFactorId) |
||
219 | |||
220 | /** |
||
221 | * @param string $secondFactorId |
||
222 | * @return null|VettedSecondFactor |
||
223 | */ |
||
224 | public function findOneVetted($secondFactorId) |
||
228 | |||
229 | /** |
||
230 | * @param string $identityId |
||
231 | * @param string $verificationNonce |
||
232 | * @return UnverifiedSecondFactor|null |
||
233 | */ |
||
234 | public function findUnverifiedByVerificationNonce($identityId, $verificationNonce) |
||
253 | |||
254 | /** |
||
255 | * @param array $allSecondFactors |
||
256 | * @param UnverifiedSecondFactorCollection $unverifiedCollection |
||
257 | * @param VerifiedSecondFactorCollection $verifiedCollection |
||
258 | * @param VettedSecondFactorCollection $vettedCollection |
||
259 | * @return array |
||
260 | */ |
||
261 | private function determineAvailable( |
||
272 | |||
273 | /** |
||
274 | * @param array $allSecondFactors |
||
275 | * @param CollectionDto $collection |
||
276 | * @return array |
||
277 | */ |
||
278 | private function filterAvailableSecondFactors(array $allSecondFactors, CollectionDto $collection) |
||
288 | |||
289 | /** |
||
290 | * @param $identity |
||
291 | * @param $allSecondFactors |
||
292 | * @param $allowedSecondFactors |
||
293 | * @param $maximumNumberOfRegistrations |
||
294 | * @return SecondFactorTypeCollection |
||
295 | */ |
||
296 | public function getSecondFactorsForIdentity( |
||
324 | } |
||
325 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.