1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015 SURFnet bv |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
|
|
|
|
20
|
|
|
|
21
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service; |
22
|
|
|
|
23
|
|
|
use Surfnet\StepupMiddlewareClientBundle\Identity\Command\ProveGssfPossessionCommand; |
24
|
|
|
use Surfnet\StepupMiddlewareClientBundle\Uuid\Uuid; |
25
|
|
|
|
26
|
|
|
final readonly class GssfService |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
public function __construct(private CommandService $commandService) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
|
|
|
|
33
|
|
|
* @param string $identityId |
|
|
|
|
34
|
|
|
* @param string $stepupProvider |
|
|
|
|
35
|
|
|
* @param string $gssfId |
|
|
|
|
36
|
|
|
* @return string|null |
|
|
|
|
37
|
|
|
*/ |
38
|
|
|
public function provePossession($identityId, $stepupProvider, $gssfId): ?string |
39
|
|
|
{ |
40
|
|
|
$command = new ProveGssfPossessionCommand(); |
41
|
|
|
$command->identityId = $identityId; |
42
|
|
|
$command->secondFactorId = Uuid::generate(); |
43
|
|
|
$command->stepupProvider = $stepupProvider; |
44
|
|
|
$command->gssfId = $gssfId; |
45
|
|
|
|
46
|
|
|
$result = $this->commandService->execute($command); |
47
|
|
|
|
48
|
|
|
return $result->isSuccessful() ? $command->secondFactorId : null; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|