Failed Conditions
Push — master ( 104856...f1eb38 )
by Florent
02:37
created

PublicKeyCredentialCreationOptions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A jsonSerialize() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace U2FAuthentication\Fido2;
15
16
class PublicKeyCredentialCreationOptions implements \JsonSerializable
17
{
18
    public const ATTESTATION_CONVEYANCE_PREFERENCE_NONE = 'none';
19
    public const ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT = 'indirect';
20
    public const ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT = 'direct';
21
22
23
    /**
24
     * @var PublicKeyCredentialRpEntity
25
     */
26
    private $rp;
27
28
    /**
29
     * @var PublicKeyCredentialUserEntity
30
     */
31
    private $user;
32
33
    /**
34
     * @var string
35
     */
36
    private $challenge;
37
38
    /**
39
     * @var PublicKeyCredentialParameters[]
40
     */
41
    private $pubKeyCredParams;
42
43
    /**
44
     * @var int
45
     */
46
    private $timeout;
47
48
    /**
49
     * @var PublicKeyCredentialDescriptor[]
50
     */
51
    private $excludeCredentials;
52
53
    /**
54
     * @var AuthenticatorSelectionCriteria
55
     */
56
    private $authenticatorSelection;
57
58
    /**
59
     * @var string
60
     */
61
    private $attestation;
62
63
    /**
64
     * @var AuthenticationExtensionsClientInputs $extensions
65
     */
66
    private $extensions;
67
68
    /**
69
     * PublicKeyCredentialCreationOptions constructor.
70
     *
71
     * @param PublicKeyCredentialRpEntity          $rp
72
     * @param PublicKeyCredentialUserEntity        $user
73
     * @param string                               $challenge
74
     * @param PublicKeyCredentialParameters[]      $pubKeyCredParams
75
     * @param int                                  $timeout
76
     * @param PublicKeyCredentialDescriptor[]      $excludeCredentials
77
     * @param AuthenticatorSelectionCriteria       $authenticatorSelection
78
     * @param string                               $attestation
79
     * @param AuthenticationExtensionsClientInputs $extensions
80
     */
81
    public function __construct(PublicKeyCredentialRpEntity $rp, PublicKeyCredentialUserEntity $user, string $challenge, array $pubKeyCredParams, int $timeout, array $excludeCredentials, AuthenticatorSelectionCriteria $authenticatorSelection, string $attestation, AuthenticationExtensionsClientInputs $extensions)
82
    {
83
        $this->rp = $rp;
84
        $this->user = $user;
85
        $this->challenge = $challenge;
86
        $this->pubKeyCredParams = $pubKeyCredParams;
87
        $this->timeout = $timeout;
88
        $this->excludeCredentials = $excludeCredentials;
89
        $this->authenticatorSelection = $authenticatorSelection;
90
        $this->attestation = $attestation;
91
        $this->extensions = $extensions;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function jsonSerialize(): array
98
    {
99
        return [
100
            'rp'                 => $this->rp,
101
            'pubKeyCredParams'   => $this->pubKeyCredParams,
102
            'timeout'            => $this->timeout,
103
            'challenge'          => $this->challenge,
104
            'attestation'        => $this->attestation,
105
            'excludeCredentials' => $this->excludeCredentials,
106
            'user'               => $this->user,
107
        ];
108
    }
109
}
110