1
|
|
|
<?php |
2
|
|
|
/* For licensing terms, see /license.txt */ |
3
|
|
|
|
4
|
|
|
namespace Chamilo\PluginBundle\ImsLti\Entity; |
5
|
|
|
|
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
|
8
|
|
|
#[ORM\Table(name: 'plugin_ims_lti_token')] |
9
|
|
|
#[ORM\Entity] |
10
|
|
|
class Token |
11
|
|
|
{ |
12
|
|
|
public const TOKEN_LIFETIME = 3600; |
13
|
|
|
|
14
|
|
|
#[ORM\Column(name: 'id', type: 'integer')] |
15
|
|
|
#[ORM\Id] |
16
|
|
|
#[ORM\GeneratedValue] |
17
|
|
|
protected ?int $id; |
18
|
|
|
|
19
|
|
|
#[ORM\ManyToOne(targetEntity: ImsLtiTool::class)] |
20
|
|
|
#[ORM\JoinColumn(name: 'tool_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
21
|
|
|
private ImsLtiTool $tool; |
22
|
|
|
|
23
|
|
|
#[ORM\Column(name: 'scope', type: 'json')] |
24
|
|
|
private array $scope; |
25
|
|
|
|
26
|
|
|
#[ORM\Column(name: 'hash', type: 'string')] |
27
|
|
|
private string $hash; |
28
|
|
|
|
29
|
|
|
#[ORM\Column(name: 'created_at', type: 'integer')] |
30
|
|
|
private int $createdAt; |
31
|
|
|
|
32
|
|
|
#[ORM\Column(name: 'expires_at', type: 'integer')] |
33
|
|
|
private int $expiresAt; |
34
|
|
|
|
35
|
|
|
public function getId(): ?int |
36
|
|
|
{ |
37
|
|
|
return $this->id; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getTool(): ImsLtiTool |
41
|
|
|
{ |
42
|
|
|
return $this->tool; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function setTool(ImsLtiTool $tool): static |
46
|
|
|
{ |
47
|
|
|
$this->tool = $tool; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getScope(): array |
53
|
|
|
{ |
54
|
|
|
return $this->scope; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function setScope(array $scope): static |
58
|
|
|
{ |
59
|
|
|
$this->scope = $scope; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getHash(): string |
65
|
|
|
{ |
66
|
|
|
return $this->hash; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setHash(string $hash): static |
70
|
|
|
{ |
71
|
|
|
$this->hash = $hash; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getCreatedAt(): int |
77
|
|
|
{ |
78
|
|
|
return $this->createdAt; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function setCreatedAt(int $createdAt): static |
82
|
|
|
{ |
83
|
|
|
$this->createdAt = $createdAt; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getExpiresAt(): int |
89
|
|
|
{ |
90
|
|
|
return $this->expiresAt; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function setExpiresAt(int $expiresAt): static |
94
|
|
|
{ |
95
|
|
|
$this->expiresAt = $expiresAt; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getScopeInString(): string |
101
|
|
|
{ |
102
|
|
|
return implode(' ', $this->scope); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function generateHash(): static |
106
|
|
|
{ |
107
|
|
|
$this->hash = sha1(uniqid(mt_rand())); |
108
|
|
|
|
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|