Completed
Push — feature/implement-state-handli... ( bd5ae0 )
by Michiel
01:52
created

FixtureService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Surfnet\StepupGateway\Behat\Service;
4
5
use Exception;
6
use Surfnet\StepupGateway\Behat\Repository\SamlEntityRepository;
7
use Surfnet\StepupGateway\Behat\Repository\SecondFactorRepository;
8
use Surfnet\StepupGateway\Behat\Repository\WhitelistRepository;
9
10
class FixtureService
11
{
12
    private $secondFactorRepository;
13
14
    private $samlEntityRepository;
15
16
    private $whitelistRepository;
17
18
    public function __construct(
19
        SecondFactorRepository $secondFactorRepository,
20
        SamlEntityRepository $samlRepository,
21
        WhitelistRepository $whitelistRepository
22
    ) {
23
        $this->secondFactorRepository = $secondFactorRepository;
24
        $this->samlEntityRepository = $samlRepository;
25
        $this->whitelistRepository = $whitelistRepository;
26
    }
27
28
    /**
29
     * @param string $nameId
30
     * @param string $institution
31
     * @return array
32
     * @throws Exception
33
     */
34
    public function registerYubikeyToken($nameId, $institution)
35
    {
36
        return $this->secondFactorRepository->create($nameId, 'yubikey', $institution);
37
    }
38
39
    /**
40
     * @param string $nameId
41
     * @param string $institution
42
     * @return array
43
     * @throws Exception
44
     */
45
    public function registerSmsToken($nameId, $institution)
46
    {
47
        return $this->secondFactorRepository->create($nameId, 'sms', $institution, '+31 (0) 606060606');
48
    }
49
50
    /**
51
     * @param string $entityId
52
     * @param string $certificate
53
     * @param bool $sfoEnabled
54
     * @return array
55
     * @throws Exception
56
     */
57
    public function registerSP($entityId, $certificate, $sfoEnabled = false)
58
    {
59
        return $this->samlEntityRepository->createSpIfNotExists($entityId, $certificate, $sfoEnabled);
60
    }
61
62
    /**
63
     * @param string $entityId
64
     * @param string $certificate
65
     * @return array
66
     * @throws Exception
67
     */
68
    public function registerIdp($entityId, $certificate)
69
    {
70
        return $this->samlEntityRepository->createIdpIfNotExists($entityId, $certificate);
71
    }
72
73
    /**
74
     * @param string $institution
75
     * @return array
76
     * @throws Exception
77
     */
78
    public function whitelist($institution)
79
    {
80
        return $this->whitelistRepository->whitelist($institution);
81
    }
82
83
    public function registerTiqrToken($nameId, $institution)
84
    {
85
        return $this->secondFactorRepository->create($nameId, 'tiqr', $institution, 'foobar');
86
    }
87
}
88