Completed
Push — master ( fe5c1f...228ee9 )
by Nic
05:10 queued 02:42
created

TestAuthenticationRequestFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
/**
4
 * Copyright 2017 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\StepupSelfService\SelfServiceBundle\Service\TestSecondFactor;
20
21
use Surfnet\SamlBundle\Entity\IdentityProvider;
22
use Surfnet\SamlBundle\Entity\ServiceProvider;
23
use Surfnet\SamlBundle\SAML2\AuthnRequestFactory;
24
use Surfnet\StepupBundle\Value\Loa;
25
26
final class TestAuthenticationRequestFactory
27
{
28
    /**
29
     * @var ServiceProvider
30
     */
31
    private $serviceProvider;
32
33
    /**
34
     * @var IdentityProvider
35
     */
36
    private $identityProvider;
37
38
    public function __construct(
39
        ServiceProvider $serviceProvider,
40
        IdentityProvider $identityProvider
41
    ) {
42
        $this->serviceProvider = $serviceProvider;
43
        $this->identityProvider = $identityProvider;
44
    }
45
46
    /**
47
     * @param string $nameId
48
     * @param Loa    $loa
49
     *
50
     * @return \Surfnet\SamlBundle\SAML2\AuthnRequest
51
     */
52
    public function createSecondFactorTestRequest($nameId, Loa $loa)
53
    {
54
        $authenticationRequest = AuthnRequestFactory::createNewRequest(
55
            $this->serviceProvider,
56
            $this->identityProvider
57
        );
58
59
        $authenticationRequest->setSubject($nameId);
60
        $authenticationRequest->setAuthenticationContextClassRef((string) $loa);
61
62
        return $authenticationRequest;
63
    }
64
}
65