Passed
Push — master ( 33a29d...4282cd )
by Robbie
02:17 queued 25s
created

getAttestationStatementSupportManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php declare(strict_types=1);
2
3
namespace SilverStripe\WebAuthn;
4
5
use CBOR\Decoder;
6
use CBOR\OtherObject\OtherObjectManager;
7
use CBOR\Tag\TagObjectManager;
8
use Webauthn\AttestationStatement\AttestationObjectLoader;
9
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
10
use Webauthn\AttestationStatement\FidoU2FAttestationStatementSupport;
11
use Webauthn\AttestationStatement\NoneAttestationStatementSupport;
12
use Webauthn\PublicKeyCredentialLoader;
13
14
/**
15
 * Contains logic which is shared between both WebAuthn's RegisterHandler and VerifyHandler, such as
16
 * the attestation configuration options.
17
 */
18
trait BaseHandlerTrait
19
{
20
    /**
21
     * @return Decoder
22
     */
23
    protected function getDecoder(): Decoder
24
    {
25
        return new Decoder(new TagObjectManager(), new OtherObjectManager());
26
    }
27
28
    /**
29
     * @param Decoder $decoder
30
     * @return AttestationStatementSupportManager
31
     */
32
    protected function getAttestationStatementSupportManager(Decoder $decoder): AttestationStatementSupportManager
33
    {
34
        $manager = new AttestationStatementSupportManager();
35
        $manager->add(new NoneAttestationStatementSupport());
36
        $manager->add(new FidoU2FAttestationStatementSupport($decoder));
37
        return $manager;
38
    }
39
40
    /**
41
     * @param AttestationStatementSupportManager $attestationStatementSupportManager
42
     * @param Decoder $decoder
43
     * @return AttestationObjectLoader
44
     */
45
    protected function getAttestationObjectLoader(
46
        AttestationStatementSupportManager $attestationStatementSupportManager,
47
        Decoder $decoder
48
    ): AttestationObjectLoader {
49
        return new AttestationObjectLoader($attestationStatementSupportManager, $decoder);
50
    }
51
52
    /**
53
     * @param AttestationObjectLoader $attestationObjectLoader
54
     * @param Decoder $decoder
55
     * @return PublicKeyCredentialLoader
56
     */
57
    protected function getPublicKeyCredentialLoader(
58
        AttestationObjectLoader $attestationObjectLoader,
59
        Decoder $decoder
60
    ): PublicKeyCredentialLoader {
61
        return new PublicKeyCredentialLoader($attestationObjectLoader, $decoder);
62
    }
63
}
64