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
|
|
|
use RefreshTokenTrait; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
* @ORM\Id |
22
|
|
|
* @ORM\Column(type="string", length=40) |
23
|
|
|
*/ |
24
|
|
|
protected $identifier; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var AccessTokenEntityInterface |
28
|
|
|
* @ORM\OneToOne(targetEntity="OAuth\AccessToken") |
29
|
|
|
* @ORM\JoinColumn(name="accessToken", referencedColumnName="identifier") |
30
|
|
|
*/ |
31
|
|
|
protected $accessToken; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var DateTime |
35
|
|
|
* @ORM\Column(type="date",nullable=true) |
36
|
|
|
*/ |
37
|
|
|
protected $expiryDateTime; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
1 |
|
public function setAccessToken(AccessTokenEntityInterface $accessToken) |
43
|
|
|
{ |
44
|
1 |
|
$this->accessToken = $accessToken; |
45
|
1 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
1 |
|
public function getAccessToken() |
51
|
|
|
{ |
52
|
1 |
|
return $this->accessToken; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Get the token's expiry date time. |
57
|
|
|
* |
58
|
|
|
* @return DateTime |
59
|
|
|
*/ |
60
|
1 |
|
public function getExpiryDateTime() |
61
|
|
|
{ |
62
|
1 |
|
return $this->expiryDateTime; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Set the date time when the token expires. |
67
|
|
|
* |
68
|
|
|
* @param DateTime $dateTime |
69
|
|
|
*/ |
70
|
1 |
|
public function setExpiryDateTime(DateTime $dateTime) |
71
|
|
|
{ |
72
|
1 |
|
$this->expiryDateTime = $dateTime; |
73
|
1 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return mixed |
77
|
|
|
*/ |
78
|
1 |
|
public function getIdentifier() |
79
|
|
|
{ |
80
|
1 |
|
return $this->identifier; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param mixed $identifier |
85
|
|
|
*/ |
86
|
1 |
|
public function setIdentifier($identifier) |
87
|
|
|
{ |
88
|
1 |
|
$this->identifier = $identifier; |
89
|
|
|
} |
90
|
|
|
} |