@@ 16-170 (lines=155) @@ | ||
13 | * @Entity(repositoryClass="OAuth\Repository\AccessTokenRepository") |
|
14 | * @Table(name="AccessToken") |
|
15 | */ |
|
16 | class AccessToken implements AccessTokenEntityInterface |
|
17 | { |
|
18 | use AccessTokenTrait; |
|
19 | ||
20 | /** |
|
21 | * @var ArrayCollection $scopes |
|
22 | * @ManyToMany(targetEntity="OAuth\Scope", inversedBy="accessTokens") |
|
23 | * @JoinTable(name="AccessTokenScope", |
|
24 | * joinColumns={@JoinColumn(name="scopeId", referencedColumnName="identifier")}, |
|
25 | * inverseJoinColumns={@JoinColumn(name="accessTokenId", referencedColumnName="identifier")} |
|
26 | * ) |
|
27 | */ |
|
28 | protected $scopes; |
|
29 | ||
30 | /** |
|
31 | * @var DateTime |
|
32 | * @Column(type="date",nullable=true) |
|
33 | */ |
|
34 | protected $expiryDateTime; |
|
35 | ||
36 | /** |
|
37 | * @var User |
|
38 | * @Column(type="integer", length=11) |
|
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 | * Set token |
|
63 | * |
|
64 | * @param string $token |
|
65 | * @return AccessToken |
|
66 | */ |
|
67 | public function setToken($token) |
|
68 | { |
|
69 | $this->token = $token; |
|
70 | return $this; |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * Get token |
|
75 | * |
|
76 | * @return string |
|
77 | */ |
|
78 | public function getIdentifier() |
|
79 | { |
|
80 | return $this->identifier; |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * @param string $identifier |
|
85 | */ |
|
86 | public function setIdentifier($identifier) |
|
87 | { |
|
88 | $this->identifier = $identifier; |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * @param ScopeEntityInterface $scope |
|
93 | * @return $this |
|
94 | */ |
|
95 | public function addScope(ScopeEntityInterface $scope) |
|
96 | { |
|
97 | $this->scopes->add($scope); |
|
98 | return $this; |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * Return an array of scopes associated with the token. |
|
103 | * |
|
104 | * @return ScopeEntityInterface[] |
|
105 | */ |
|
106 | public function getScopes() |
|
107 | { |
|
108 | return $this->scopes->toArray(); |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * Get the token's expiry date time. |
|
113 | * |
|
114 | * @return DateTime |
|
115 | */ |
|
116 | public function getExpiryDateTime() |
|
117 | { |
|
118 | return $this->expiryDateTime; |
|
119 | } |
|
120 | ||
121 | /** |
|
122 | * Set the date time when the token expires. |
|
123 | * |
|
124 | * @param DateTime $dateTime |
|
125 | */ |
|
126 | public function setExpiryDateTime(DateTime $dateTime) |
|
127 | { |
|
128 | $this->expiryDateTime = $dateTime; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * @param int $identifier |
|
133 | * @return $this |
|
134 | */ |
|
135 | public function setUserIdentifier($identifier) |
|
136 | { |
|
137 | $this->userIdentifier = $identifier; |
|
138 | return $this; |
|
139 | } |
|
140 | ||
141 | /** |
|
142 | * Get the token user's identifier. |
|
143 | * |
|
144 | * @return int |
|
145 | */ |
|
146 | public function getUserIdentifier() |
|
147 | { |
|
148 | return $this->userIdentifier; |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * Get the client that the token was issued to. |
|
153 | * |
|
154 | * @return ClientEntityInterface |
|
155 | */ |
|
156 | public function getClient() |
|
157 | { |
|
158 | return $this->client; |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * Set the client that the token was issued to. |
|
163 | * |
|
164 | * @param ClientEntityInterface $client |
|
165 | */ |
|
166 | public function setClient(ClientEntityInterface $client) |
|
167 | { |
|
168 | $this->client = $client; |
|
169 | } |
|
170 | } |
@@ 15-176 (lines=162) @@ | ||
12 | * @Entity(repositoryClass="OAuth\Repository\AuthCodeRepository") |
|
13 | * @Table(name="AuthCode") |
|
14 | */ |
|
15 | class AuthCode implements AuthCodeEntityInterface |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var null|string |
|
20 | * @Column(type="string", length=255, nullable=true) |
|
21 | */ |
|
22 | protected $redirectUri; |
|
23 | ||
24 | /** |
|
25 | * @var ArrayCollection $scopes |
|
26 | * @ManyToMany(targetEntity="OAuth\Scope") |
|
27 | * @JoinTable(name="AuthTokenScope", |
|
28 | * joinColumns={@JoinColumn(name="scopeId", referencedColumnName="identifier")}, |
|
29 | * inverseJoinColumns={@JoinColumn(name="authTokenId", referencedColumnName="identifier")}) |
|
30 | */ |
|
31 | protected $scopes; |
|
32 | ||
33 | /** |
|
34 | * @var DateTime |
|
35 | * @Column(type="date",nullable=true) |
|
36 | */ |
|
37 | protected $expiryDateTime; |
|
38 | ||
39 | /** |
|
40 | * @var User |
|
41 | * @OneToOne(targetEntity="OAuth\User") |
|
42 | * @JoinColumn(name="client", referencedColumnName="id") |
|
43 | */ |
|
44 | protected $userIdentifier; |
|
45 | ||
46 | /** |
|
47 | * @var ClientEntityInterface |
|
48 | * @ManyToOne(targetEntity="OAuth\Client") |
|
49 | * @JoinColumn(name="client", referencedColumnName="identifier") |
|
50 | */ |
|
51 | protected $client; |
|
52 | ||
53 | /** |
|
54 | * @var string |
|
55 | * @Id |
|
56 | * @Column(type="string", length=40) |
|
57 | */ |
|
58 | protected $identifier; |
|
59 | ||
60 | public function __construct() |
|
61 | { |
|
62 | $this->scopes = new ArrayCollection(); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * @return string |
|
67 | */ |
|
68 | public function getIdentifier() |
|
69 | { |
|
70 | return $this->identifier; |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * @param string $identifier |
|
75 | */ |
|
76 | public function setIdentifier($identifier) |
|
77 | { |
|
78 | $this->identifier = $identifier; |
|
79 | } |
|
80 | ||
81 | /** |
|
82 | * @param ScopeEntityInterface $scope |
|
83 | * @return $this |
|
84 | */ |
|
85 | public function addScope(ScopeEntityInterface $scope) |
|
86 | { |
|
87 | $this->scopes->add($scope); |
|
88 | return $this; |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Return an array of scopes associated with the token. |
|
93 | * |
|
94 | * @return ScopeEntityInterface[] |
|
95 | */ |
|
96 | public function getScopes() |
|
97 | { |
|
98 | return $this->scopes->toArray(); |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * Get the token's expiry date time. |
|
103 | * |
|
104 | * @return DateTime |
|
105 | */ |
|
106 | public function getExpiryDateTime() |
|
107 | { |
|
108 | return $this->expiryDateTime; |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * Set the date time when the token expires. |
|
113 | * |
|
114 | * @param DateTime $dateTime |
|
115 | */ |
|
116 | public function setExpiryDateTime(DateTime $dateTime) |
|
117 | { |
|
118 | $this->expiryDateTime = $dateTime; |
|
119 | } |
|
120 | ||
121 | /** |
|
122 | * Set the identifier of the user associated with the token. |
|
123 | * |
|
124 | * @param User $identifier The identifier of the user |
|
125 | */ |
|
126 | public function setUserIdentifier($identifier) |
|
127 | { |
|
128 | $this->userIdentifier = $identifier; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * Get the token user's identifier. |
|
133 | * |
|
134 | * @return User |
|
135 | */ |
|
136 | public function getUserIdentifier() |
|
137 | { |
|
138 | return $this->userIdentifier; |
|
139 | } |
|
140 | ||
141 | /** |
|
142 | * Get the client that the token was issued to. |
|
143 | * |
|
144 | * @return ClientEntityInterface |
|
145 | */ |
|
146 | public function getClient() |
|
147 | { |
|
148 | return $this->client; |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * Set the client that the token was issued to. |
|
153 | * |
|
154 | * @param ClientEntityInterface $client |
|
155 | */ |
|
156 | public function setClient(ClientEntityInterface $client) |
|
157 | { |
|
158 | $this->client = $client; |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * @return string |
|
163 | */ |
|
164 | public function getRedirectUri() |
|
165 | { |
|
166 | return $this->redirectUri; |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * @param string $uri |
|
171 | */ |
|
172 | public function setRedirectUri($uri) |
|
173 | { |
|
174 | $this->redirectUri = $uri; |
|
175 | } |
|
176 | } |