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