Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace Packback\Lti1p3;
4
 
5
use Packback\Lti1p3\Interfaces\ILtiRegistration;
6
 
7
class LtiRegistration implements ILtiRegistration
8
{
9
    private ?string $issuer;
10
    private ?string $clientId;
11
    private ?string $keySetUrl;
12
    private ?string $authTokenUrl;
13
    private ?string $authLoginUrl;
14
    private ?string $authServer;
15
    private ?string $toolPrivateKey;
16
    private ?string $kid;
17
 
18
    public function __construct(?array $registration = null)
19
    {
20
        $this->issuer = $registration['issuer'] ?? null;
21
        $this->clientId = $registration['clientId'] ?? null;
22
        $this->keySetUrl = $registration['keySetUrl'] ?? null;
23
        $this->authTokenUrl = $registration['authTokenUrl'] ?? null;
24
        $this->authLoginUrl = $registration['authLoginUrl'] ?? null;
25
        $this->authServer = $registration['authServer'] ?? null;
26
        $this->toolPrivateKey = $registration['toolPrivateKey'] ?? null;
27
        $this->kid = $registration['kid'] ?? null;
28
    }
29
 
30
    public static function new(?array $registration = null): self
31
    {
32
        return new LtiRegistration($registration);
33
    }
34
 
35
    public function getIssuer()
36
    {
37
        return $this->issuer;
38
    }
39
 
40
    public function setIssuer(string $issuer): self
41
    {
42
        $this->issuer = $issuer;
43
 
44
        return $this;
45
    }
46
 
47
    public function getClientId()
48
    {
49
        return $this->clientId;
50
    }
51
 
52
    public function setClientId(string $clientId): self
53
    {
54
        $this->clientId = $clientId;
55
 
56
        return $this;
57
    }
58
 
59
    public function getKeySetUrl(): ?string
60
    {
61
        return $this->keySetUrl;
62
    }
63
 
64
    public function setKeySetUrl(?string $keySetUrl): self
65
    {
66
        $this->keySetUrl = $keySetUrl;
67
 
68
        return $this;
69
    }
70
 
71
    public function getAuthTokenUrl(): ?string
72
    {
73
        return $this->authTokenUrl;
74
    }
75
 
76
    public function setAuthTokenUrl(?string $authTokenUrl): self
77
    {
78
        $this->authTokenUrl = $authTokenUrl;
79
 
80
        return $this;
81
    }
82
 
83
    public function getAuthLoginUrl(): ?string
84
    {
85
        return $this->authLoginUrl;
86
    }
87
 
88
    public function setAuthLoginUrl(?string $authLoginUrl): self
89
    {
90
        $this->authLoginUrl = $authLoginUrl;
91
 
92
        return $this;
93
    }
94
 
95
    public function getAuthServer(): ?string
96
    {
97
        return $this->authServer ?? $this->authTokenUrl;
98
    }
99
 
100
    public function setAuthServer(?string $authServer): self
101
    {
102
        $this->authServer = $authServer;
103
 
104
        return $this;
105
    }
106
 
107
    public function getToolPrivateKey()
108
    {
109
        return $this->toolPrivateKey;
110
    }
111
 
112
    public function setToolPrivateKey(string $toolPrivateKey): self
113
    {
114
        $this->toolPrivateKey = $toolPrivateKey;
115
 
116
        return $this;
117
    }
118
 
119
    public function getKid()
120
    {
121
        return $this->kid ?? hash('sha256', trim($this->issuer.$this->clientId));
122
    }
123
 
124
    public function setKid(string $kid): self
125
    {
126
        $this->kid = $kid;
127
 
128
        return $this;
129
    }
130
}