1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Majora\Component\OAuth\Entity; |
4
|
|
|
|
5
|
|
|
use Majora\Component\OAuth\Model\ApplicationInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Basic implementation on ApplicationInterface. |
9
|
|
|
*/ |
10
|
|
|
class Application implements ApplicationInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var int |
14
|
|
|
*/ |
15
|
|
|
protected $id; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $apiKey; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $secret; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $domain; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
protected $allowedScopes; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $allowedGrantTypes; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $roles; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Construct. |
49
|
|
|
*/ |
50
|
|
|
public function __construct() |
51
|
|
|
{ |
52
|
|
|
$this->allowedScopes = array(); |
53
|
|
|
$this->allowedGrantTypes = array(); |
54
|
|
|
$this->roles = array(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return int |
59
|
|
|
*/ |
60
|
|
|
public function getId() |
61
|
|
|
{ |
62
|
|
|
return $this->id; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @see ApplicationInterface::getApiKey() |
67
|
|
|
*/ |
68
|
|
|
public function getApiKey() |
69
|
|
|
{ |
70
|
|
|
return $this->apiKey; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Define Application apiKey value. |
75
|
|
|
* |
76
|
|
|
* @param string $apiKey |
77
|
|
|
* |
78
|
|
|
* @return self |
79
|
|
|
*/ |
80
|
|
|
public function setApiKey($apiKey) |
81
|
|
|
{ |
82
|
|
|
$this->apiKey = $apiKey; |
83
|
|
|
|
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @see ApplicationInterface::getSecret() |
89
|
|
|
*/ |
90
|
|
|
public function getSecret() |
91
|
|
|
{ |
92
|
|
|
return $this->secret; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Define Application secret value. |
97
|
|
|
* |
98
|
|
|
* @param string $secret |
99
|
|
|
* |
100
|
|
|
* @return self |
101
|
|
|
*/ |
102
|
|
|
public function setSecret($secret) |
103
|
|
|
{ |
104
|
|
|
$this->secret = $secret; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @see ApplicationInterface::getDomain() |
111
|
|
|
*/ |
112
|
|
|
public function getDomain() |
113
|
|
|
{ |
114
|
|
|
return $this->domain; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Define Application domain value. |
119
|
|
|
* |
120
|
|
|
* @param string $domain |
121
|
|
|
* |
122
|
|
|
* @return self |
123
|
|
|
*/ |
124
|
|
|
public function setDomain($domain) |
125
|
|
|
{ |
126
|
|
|
$this->domain = $domain; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @see ApplicationInterface::getAllowedScopes() |
133
|
|
|
*/ |
134
|
|
|
public function getAllowedScopes() |
135
|
|
|
{ |
136
|
|
|
return $this->allowedScopes; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Define Application allowedScopes value. |
141
|
|
|
* |
142
|
|
|
* @param array $allowedScopes |
143
|
|
|
* |
144
|
|
|
* @return self |
145
|
|
|
*/ |
146
|
|
|
public function setAllowedScopes(array $allowedScopes) |
147
|
|
|
{ |
148
|
|
|
$this->allowedScopes = $allowedScopes; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @see ApplicationInterface::getAllowedGrantTypes() |
155
|
|
|
*/ |
156
|
|
|
public function getAllowedGrantTypes() |
157
|
|
|
{ |
158
|
|
|
return $this->allowedGrantTypes; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Define Application allowedGrantTypes value. |
163
|
|
|
* |
164
|
|
|
* @param array $allowedGrantTypes |
165
|
|
|
* |
166
|
|
|
* @return self |
167
|
|
|
*/ |
168
|
|
|
public function setAllowedGrantTypes(array $allowedGrantTypes) |
169
|
|
|
{ |
170
|
|
|
$this->allowedGrantTypes = $allowedGrantTypes; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @see ApplicationInterface::getRoles() |
177
|
|
|
*/ |
178
|
|
|
public function getRoles() |
179
|
|
|
{ |
180
|
|
|
return $this->roles; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Define Application roles value. |
185
|
|
|
* |
186
|
|
|
* @param array $roles |
187
|
|
|
* |
188
|
|
|
* @return self |
189
|
|
|
*/ |
190
|
|
|
public function setRoles(array $roles) |
191
|
|
|
{ |
192
|
|
|
$this->roles = $roles; |
193
|
|
|
|
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
|