44 use OCP \IConfig ;
55 use OCP \IUserManager ;
66 use OCP \IUrlGenerator ;
7-
7+ use OCA \Solid \BaseServerConfig ;
8+
89 /**
910 * @package OCA\Solid
1011 */
11- class ServerConfig {
12+ class ServerConfig extends BaseServerConfig {
1213 private IConfig $ config ;
1314 private IUrlGenerator $ urlGenerator ;
1415 private IUserManager $ userManager ;
@@ -24,41 +25,6 @@ public function __construct(IConfig $config, IUrlGenerator $urlGenerator, IUserM
2425 $ this ->urlGenerator = $ urlGenerator ;
2526 }
2627
27- /**
28- * @return string
29- */
30- public function getPrivateKey () {
31- $ result = $ this ->config ->getAppValue ('solid ' ,'privateKey ' );
32- if (!$ result ) {
33- // generate and save a new set if we don't have a private key;
34- $ keys = $ this ->generateKeySet ();
35- $ this ->config ->setAppValue ('solid ' ,'privateKey ' ,$ keys ['privateKey ' ]);
36- $ this ->config ->setAppValue ('solid ' ,'encryptionKey ' ,$ keys ['encryptionKey ' ]);
37- }
38- return $ this ->config ->getAppValue ('solid ' ,'privateKey ' );
39- }
40-
41- /**
42- * @param string $privateKey
43- */
44- public function setPrivateKey ($ privateKey ) {
45- $ this ->config ->setAppValue ('solid ' ,'privateKey ' ,$ privateKey );
46- }
47-
48- /**
49- * @return string
50- */
51- public function getEncryptionKey () {
52- return $ this ->config ->getAppValue ('solid ' ,'encryptionKey ' );
53- }
54-
55- /**
56- * @param string $publicKey
57- */
58- public function setEncryptionKey ($ publicKey ) {
59- $ this ->config ->setAppValue ('solid ' ,'encryptionKey ' ,$ publicKey );
60- }
61-
6228 /**
6329 * @param string $clientId
6430 * @return array|null
@@ -197,22 +163,4 @@ public function setProfileData($userId, $profileData) {
197163 $ user ->setDisplayName ($ fields ['name ' ]);
198164 }
199165 }
200- private function generateKeySet () {
201- $ config = array (
202- "digest_alg " => "sha256 " ,
203- "private_key_bits " => 2048 ,
204- "private_key_type " => OPENSSL_KEYTYPE_RSA ,
205- );
206- // Create the private and public key
207- $ key = openssl_pkey_new ($ config );
208-
209- // Extract the private key from $key to $privateKey
210- openssl_pkey_export ($ key , $ privateKey );
211- $ encryptionKey = base64_encode (random_bytes (32 ));
212- $ result = array (
213- "privateKey " => $ privateKey ,
214- "encryptionKey " => $ encryptionKey
215- );
216- return $ result ;
217- }
218166 }
0 commit comments