1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface; |
7
|
|
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface; |
8
|
|
|
use League\OAuth2\Server\Entities\Traits\RefreshTokenTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @Entity(repositoryClass="OAuth\Repository\RefreshTokenRepository") |
12
|
|
|
* @Table(name="RefreshToken") |
13
|
|
|
*/ |
14
|
|
|
class RefreshToken implements RefreshTokenEntityInterface |
15
|
|
|
{ |
16
|
|
|
use RefreshTokenTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
* @Id |
21
|
|
|
* @Column(type="string", length=40) |
22
|
|
|
*/ |
23
|
|
|
protected $identifier; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var AccessTokenEntityInterface |
27
|
|
|
* @OneToOne(targetEntity="OAuth\AccessToken") |
28
|
|
|
* @JoinColumn(name="accessToken", referencedColumnName="identifier") |
29
|
|
|
*/ |
30
|
|
|
protected $accessToken; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var DateTime |
34
|
|
|
* @Column(type="date",nullable=true) |
35
|
|
|
*/ |
36
|
|
|
protected $expiryDateTime; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
1 |
|
public function setAccessToken(AccessTokenEntityInterface $accessToken) |
42
|
|
|
{ |
43
|
1 |
|
$this->accessToken = $accessToken; |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
1 |
|
public function getAccessToken() |
50
|
|
|
{ |
51
|
1 |
|
return $this->accessToken; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get the token's expiry date time. |
56
|
|
|
* |
57
|
|
|
* @return DateTime |
58
|
|
|
*/ |
59
|
1 |
|
public function getExpiryDateTime() |
60
|
|
|
{ |
61
|
1 |
|
return $this->expiryDateTime; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Set the date time when the token expires. |
66
|
|
|
* |
67
|
|
|
* @param DateTime $dateTime |
68
|
|
|
*/ |
69
|
1 |
|
public function setExpiryDateTime(DateTime $dateTime) |
70
|
|
|
{ |
71
|
1 |
|
$this->expiryDateTime = $dateTime; |
72
|
1 |
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return mixed |
76
|
|
|
*/ |
77
|
1 |
|
public function getIdentifier() |
78
|
|
|
{ |
79
|
1 |
|
return $this->identifier; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param mixed $identifier |
84
|
|
|
*/ |
85
|
1 |
|
public function setIdentifier($identifier) |
86
|
|
|
{ |
87
|
1 |
|
$this->identifier = $identifier; |
88
|
|
|
} |
89
|
|
|
} |