|
4 | 4 | use OCP\IConfig; |
5 | 5 | use OCP\IUserManager; |
6 | 6 | use OCP\IUrlGenerator; |
7 | | - |
| 7 | + use OCA\Solid\BaseServerConfig; |
| 8 | + |
8 | 9 | /** |
9 | 10 | * @package OCA\Solid |
10 | 11 | */ |
11 | | - class ServerConfig { |
12 | | - /** @var IConfig */ |
13 | | - private $config; |
| 12 | + class ServerConfig extends BaseServerConfig { |
| 13 | + private IConfig $config; |
| 14 | + private IUrlGenerator $urlGenerator; |
| 15 | + private IUserManager $userManager; |
14 | 16 |
|
15 | 17 | /** |
16 | 18 | * @param IConfig $config |
| 19 | + * @param IUrlGenerator $urlGenerator |
| 20 | + * @param IUserManager $userManager |
17 | 21 | */ |
18 | 22 | public function __construct(IConfig $config, IUrlGenerator $urlGenerator, IUserManager $userManager) { |
19 | 23 | $this->config = $config; |
20 | 24 | $this->userManager = $userManager; |
21 | 25 | $this->urlGenerator = $urlGenerator; |
22 | | - } |
23 | | - |
24 | | - /** |
25 | | - * @return string |
26 | | - */ |
27 | | - public function getPrivateKey() { |
28 | | - $result = $this->config->getAppValue('solid','privateKey'); |
29 | | - if (!$result) { |
30 | | - // generate and save a new set if we don't have a private key; |
31 | | - $keys = $this->generateKeySet(); |
32 | | - $this->config->setAppValue('solid','privateKey',$keys['privateKey']); |
33 | | - $this->config->setAppValue('solid','encryptionKey',$keys['encryptionKey']); |
34 | | - } |
35 | | - return $this->config->getAppValue('solid','privateKey'); |
36 | | - } |
37 | | - |
38 | | - /** |
39 | | - * @param string $privateKey |
40 | | - */ |
41 | | - public function setPrivateKey($privateKey) { |
42 | | - $this->config->setAppValue('solid','privateKey',$privateKey); |
43 | | - } |
44 | | - |
45 | | - /** |
46 | | - * @return string |
47 | | - */ |
48 | | - public function getEncryptionKey() { |
49 | | - return $this->config->getAppValue('solid','encryptionKey'); |
50 | | - } |
51 | | - |
52 | | - /** |
53 | | - * @param string $publicKey |
54 | | - */ |
55 | | - public function setEncryptionKey($publicKey) { |
56 | | - $this->config->setAppValue('solid','encryptionKey',$publicKey); |
| 26 | + parent::__construct($config); |
57 | 27 | } |
58 | 28 |
|
59 | 29 | /** |
@@ -194,22 +164,4 @@ public function setProfileData($userId, $profileData) { |
194 | 164 | $user->setDisplayName($fields['name']); |
195 | 165 | } |
196 | 166 | } |
197 | | - private function generateKeySet() { |
198 | | - $config = array( |
199 | | - "digest_alg" => "sha256", |
200 | | - "private_key_bits" => 2048, |
201 | | - "private_key_type" => OPENSSL_KEYTYPE_RSA, |
202 | | - ); |
203 | | - // Create the private and public key |
204 | | - $key = openssl_pkey_new($config); |
205 | | - |
206 | | - // Extract the private key from $key to $privateKey |
207 | | - openssl_pkey_export($key, $privateKey); |
208 | | - $encryptionKey = base64_encode(random_bytes(32)); |
209 | | - $result = array( |
210 | | - "privateKey" => $privateKey, |
211 | | - "encryptionKey" => $encryptionKey |
212 | | - ); |
213 | | - return $result; |
214 | | - } |
215 | 167 | } |
0 commit comments