1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface; |
8
|
|
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface; |
9
|
|
|
use League\OAuth2\Server\Entities\Traits\RefreshTokenTrait; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @ORM\Entity(repositoryClass="OAuth\Repository\RefreshTokenRepository") |
13
|
|
|
* @ORM\Table(name="RefreshToken") |
14
|
|
|
*/ |
15
|
|
|
class RefreshToken implements RefreshTokenEntityInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @ORM\Id() |
19
|
|
|
* @ORM\GeneratedValue() |
20
|
|
|
* @ORM\Column(type="integer") |
21
|
|
|
* @var int|null |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* @ORM\Column(type="string", length=40) |
28
|
|
|
*/ |
29
|
|
|
protected $identifier; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var AccessTokenEntityInterface |
33
|
|
|
* @ORM\ManyToOne(targetEntity="OAuth\AccessToken") |
34
|
|
|
*/ |
35
|
|
|
protected $accessToken; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var DateTime |
39
|
|
|
* @ORM\Column(type="datetime",nullable=true) |
40
|
|
|
*/ |
41
|
|
|
protected $expiryDateTime; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var bool |
45
|
|
|
* @ORM\Column(type="boolean") |
46
|
|
|
*/ |
47
|
|
|
protected $revoked = false; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
2 |
|
public function setAccessToken(AccessTokenEntityInterface $accessToken) |
53
|
|
|
{ |
54
|
2 |
|
$this->accessToken = $accessToken; |
55
|
2 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
2 |
|
public function getAccessToken() |
61
|
|
|
{ |
62
|
2 |
|
return $this->accessToken; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get the token's expiry date time. |
67
|
|
|
* |
68
|
|
|
* @return DateTime |
69
|
|
|
*/ |
70
|
2 |
|
public function getExpiryDateTime() |
71
|
|
|
{ |
72
|
2 |
|
return $this->expiryDateTime; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set the date time when the token expires. |
77
|
|
|
* |
78
|
|
|
* @param DateTime $dateTime |
79
|
|
|
*/ |
80
|
2 |
|
public function setExpiryDateTime(DateTime $dateTime) |
81
|
|
|
{ |
82
|
2 |
|
$this->expiryDateTime = $dateTime; |
83
|
2 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return mixed |
87
|
|
|
*/ |
88
|
2 |
|
public function getIdentifier() |
89
|
|
|
{ |
90
|
2 |
|
return $this->identifier; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param mixed $identifier |
95
|
|
|
*/ |
96
|
2 |
|
public function setIdentifier($identifier) |
97
|
|
|
{ |
98
|
2 |
|
$this->identifier = $identifier; |
99
|
2 |
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return bool |
103
|
|
|
*/ |
104
|
|
|
public function isRevoked(): bool |
105
|
|
|
{ |
106
|
|
|
return $this->revoked; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param bool $revoked |
111
|
|
|
*/ |
112
|
|
|
public function setRevoked(bool $revoked): void |
113
|
|
|
{ |
114
|
|
|
$this->revoked = $revoked; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return int|null |
119
|
|
|
*/ |
120
|
|
|
public function getId(): ?int |
121
|
|
|
{ |
122
|
|
|
return $this->id; |
123
|
|
|
} |
124
|
|
|
} |