1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use League\OAuth2\Server\Entities\AuthCodeEntityInterface; |
8
|
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface; |
9
|
|
|
use League\OAuth2\Server\Entities\ScopeEntityInterface; |
10
|
|
|
|
11
|
|
|
class AuthCode implements AuthCodeEntityInterface |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var null|string |
16
|
|
|
* @Column(type="string", length=255, nullable=true) |
17
|
|
|
*/ |
18
|
|
|
protected $redirectUri; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var ArrayCollection $scopes |
22
|
|
|
* @ManyToMany(targetEntity="OAuth\Scope") |
23
|
|
|
* @JoinTable(name="AuthTokenScope", |
24
|
|
|
* joinColumns={@JoinColumn(name="scopeId", referencedColumnName="identifier")}, |
25
|
|
|
* inverseJoinColumns={@JoinColumn(name="authTokenId", referencedColumnName="identifier")} |
26
|
|
|
*/ |
27
|
|
|
protected $scopes; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var DateTime |
31
|
|
|
* @Column(type="date",nullable=true) |
32
|
|
|
*/ |
33
|
|
|
protected $expiryDateTime; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var User |
37
|
|
|
* @ManyToOne(targetEntity="OAuth\User") |
38
|
|
|
* @JoinColumn(name="client", referencedColumnName="id") |
39
|
|
|
*/ |
40
|
|
|
protected $userIdentifier; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var ClientEntityInterface |
44
|
|
|
* @ManyToOne(targetEntity="OAuth\Client") |
45
|
|
|
* @JoinColumn(name="client", referencedColumnName="identifier") |
46
|
|
|
*/ |
47
|
|
|
protected $client; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
* @Id |
52
|
|
|
* @Column(type="string", length=40) |
53
|
|
|
*/ |
54
|
|
|
protected $identifier; |
55
|
|
|
|
56
|
|
|
public function __construct() |
57
|
|
|
{ |
58
|
|
|
$this->scopes = new ArrayCollection(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return mixed |
63
|
|
|
*/ |
64
|
|
|
public function getIdentifier() |
65
|
|
|
{ |
66
|
|
|
return $this->identifier; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param mixed $identifier |
71
|
|
|
*/ |
72
|
|
|
public function setIdentifier($identifier) |
73
|
|
|
{ |
74
|
|
|
$this->identifier = $identifier; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Associate a scope with the token. |
79
|
|
|
* |
80
|
|
|
* @param ScopeEntityInterface $scope |
81
|
|
|
*/ |
82
|
|
|
public function addScope(ScopeEntityInterface $scope) |
83
|
|
|
{ |
84
|
|
|
$this->scopes[$scope->getIdentifier()] = $scope; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Return an array of scopes associated with the token. |
89
|
|
|
* |
90
|
|
|
* @return ScopeEntityInterface[] |
91
|
|
|
*/ |
92
|
|
|
public function getScopes() |
93
|
|
|
{ |
94
|
|
|
return array_values($this->scopes); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Get the token's expiry date time. |
99
|
|
|
* |
100
|
|
|
* @return \DateTime |
101
|
|
|
*/ |
102
|
|
|
public function getExpiryDateTime() |
103
|
|
|
{ |
104
|
|
|
return $this->expiryDateTime; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set the date time when the token expires. |
109
|
|
|
* |
110
|
|
|
* @param DateTime $dateTime |
111
|
|
|
*/ |
112
|
|
|
public function setExpiryDateTime(DateTime $dateTime) |
113
|
|
|
{ |
114
|
|
|
$this->expiryDateTime = $dateTime; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Set the identifier of the user associated with the token. |
119
|
|
|
* |
120
|
|
|
* @param string|int $identifier The identifier of the user |
121
|
|
|
*/ |
122
|
|
|
public function setUserIdentifier($identifier) |
123
|
|
|
{ |
124
|
|
|
$this->userIdentifier = $identifier; |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Get the token user's identifier. |
129
|
|
|
* |
130
|
|
|
* @return string|int |
131
|
|
|
*/ |
132
|
|
|
public function getUserIdentifier() |
133
|
|
|
{ |
134
|
|
|
return $this->userIdentifier; |
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Get the client that the token was issued to. |
139
|
|
|
* |
140
|
|
|
* @return ClientEntityInterface |
141
|
|
|
*/ |
142
|
|
|
public function getClient() |
143
|
|
|
{ |
144
|
|
|
return $this->client; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Set the client that the token was issued to. |
149
|
|
|
* |
150
|
|
|
* @param ClientEntityInterface $client |
151
|
|
|
*/ |
152
|
|
|
public function setClient(ClientEntityInterface $client) |
153
|
|
|
{ |
154
|
|
|
$this->client = $client; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return string |
159
|
|
|
*/ |
160
|
|
|
public function getRedirectUri() |
161
|
|
|
{ |
162
|
|
|
return $this->redirectUri; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param string $uri |
167
|
|
|
*/ |
168
|
|
|
public function setRedirectUri($uri) |
169
|
|
|
{ |
170
|
|
|
$this->redirectUri = $uri; |
171
|
|
|
} |
172
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..