@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class CrossSiteRequestForgeryException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class AppNotEnabledException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class NotLoggedInException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | + } |
|
40 | 40 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | } |
34 | 34 | if ($table !== null) { |
35 | 35 | $suffix = '_SEQ'; |
36 | - $table = '"' . $table . $suffix . '"'; |
|
36 | + $table = '"'.$table.$suffix.'"'; |
|
37 | 37 | } |
38 | 38 | return $this->conn->realLastInsertId($table); |
39 | 39 | } |
@@ -26,24 +26,24 @@ |
||
26 | 26 | namespace OC\DB; |
27 | 27 | |
28 | 28 | class AdapterOCI8 extends Adapter { |
29 | - public function lastInsertId($table) { |
|
30 | - if (is_null($table)) { |
|
31 | - throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); |
|
32 | - } |
|
33 | - if ($table !== null) { |
|
34 | - $suffix = '_SEQ'; |
|
35 | - $table = '"' . $table . $suffix . '"'; |
|
36 | - } |
|
37 | - return $this->conn->realLastInsertId($table); |
|
38 | - } |
|
29 | + public function lastInsertId($table) { |
|
30 | + if (is_null($table)) { |
|
31 | + throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); |
|
32 | + } |
|
33 | + if ($table !== null) { |
|
34 | + $suffix = '_SEQ'; |
|
35 | + $table = '"' . $table . $suffix . '"'; |
|
36 | + } |
|
37 | + return $this->conn->realLastInsertId($table); |
|
38 | + } |
|
39 | 39 | |
40 | - public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400"; |
|
40 | + public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400"; |
|
41 | 41 | |
42 | - public function fixupStatement($statement) { |
|
43 | - $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); |
|
44 | - $statement = str_replace('`', '"', $statement); |
|
45 | - $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement); |
|
46 | - $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); |
|
47 | - return $statement; |
|
48 | - } |
|
42 | + public function fixupStatement($statement) { |
|
43 | + $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); |
|
44 | + $statement = str_replace('`', '"', $statement); |
|
45 | + $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement); |
|
46 | + $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); |
|
47 | + return $statement; |
|
48 | + } |
|
49 | 49 | } |
@@ -28,41 +28,41 @@ |
||
28 | 28 | use OCP\Preview\IProvider; |
29 | 29 | |
30 | 30 | abstract class Provider implements IProvider { |
31 | - private $options; |
|
31 | + private $options; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param array $options |
|
37 | - */ |
|
38 | - public function __construct(array $options = []) { |
|
39 | - $this->options = $options; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param array $options |
|
37 | + */ |
|
38 | + public function __construct(array $options = []) { |
|
39 | + $this->options = $options; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Regex with the mimetypes that are supported by this provider |
|
44 | - */ |
|
45 | - abstract public function getMimeType(); |
|
42 | + /** |
|
43 | + * @return string Regex with the mimetypes that are supported by this provider |
|
44 | + */ |
|
45 | + abstract public function getMimeType(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Check if a preview can be generated for $path |
|
49 | - * |
|
50 | - * @param \OCP\Files\FileInfo $file |
|
51 | - * @return bool |
|
52 | - */ |
|
53 | - public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | - return true; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Check if a preview can be generated for $path |
|
49 | + * |
|
50 | + * @param \OCP\Files\FileInfo $file |
|
51 | + * @return bool |
|
52 | + */ |
|
53 | + public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | + return true; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | - * |
|
60 | - * @param string $path Path of file |
|
61 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | - * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | - * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | - * @return bool|\OCP\IImage false if no preview was generated |
|
66 | - */ |
|
67 | - abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
57 | + /** |
|
58 | + * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | + * |
|
60 | + * @param string $path Path of file |
|
61 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | + * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | + * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | + * @return bool|\OCP\IImage false if no preview was generated |
|
66 | + */ |
|
67 | + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
68 | 68 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param string $name |
33 | 33 | */ |
34 | 34 | public function __construct($id, $name) { |
35 | - parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); |
|
35 | + parent::__construct('Id "'.$id.'" already used by encryption module "'.$name.'"'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | use OCP\Encryption\Exceptions\GenericEncryptionException; |
26 | 26 | |
27 | 27 | class ModuleAlreadyExistsException extends GenericEncryptionException { |
28 | - /** |
|
29 | - * @param string $id |
|
30 | - * @param string $name |
|
31 | - */ |
|
32 | - public function __construct($id, $name) { |
|
33 | - parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); |
|
34 | - } |
|
28 | + /** |
|
29 | + * @param string $id |
|
30 | + * @param string $name |
|
31 | + */ |
|
32 | + public function __construct($id, $name) { |
|
33 | + parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); |
|
34 | + } |
|
35 | 35 | } |
@@ -274,7 +274,7 @@ |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | // check if key storage is mounted correctly |
277 | - if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) { |
|
277 | + if ($this->rootView->file_exists($rootDir.'/'.Storage::KEY_STORAGE_MARKER)) { |
|
278 | 278 | return true; |
279 | 279 | } |
280 | 280 |
@@ -21,210 +21,210 @@ |
||
21 | 21 | use Psr\Log\LoggerInterface; |
22 | 22 | |
23 | 23 | class Manager implements IManager { |
24 | - protected array $encryptionModules; |
|
25 | - |
|
26 | - public function __construct( |
|
27 | - protected IConfig $config, |
|
28 | - protected LoggerInterface $logger, |
|
29 | - protected IL10N $l, |
|
30 | - protected View $rootView, |
|
31 | - protected Util $util, |
|
32 | - protected ArrayCache $arrayCache, |
|
33 | - ) { |
|
34 | - $this->encryptionModules = []; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Check if encryption is enabled |
|
39 | - * |
|
40 | - * @return bool true if enabled, false if not |
|
41 | - */ |
|
42 | - public function isEnabled() { |
|
43 | - $installed = $this->config->getSystemValueBool('installed', false); |
|
44 | - if (!$installed) { |
|
45 | - return false; |
|
46 | - } |
|
47 | - |
|
48 | - $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); |
|
49 | - return $enabled === 'yes'; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * check if new encryption is ready |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - * @throws ServiceUnavailableException |
|
57 | - */ |
|
58 | - public function isReady() { |
|
59 | - if ($this->isKeyStorageReady() === false) { |
|
60 | - throw new ServiceUnavailableException('Key Storage is not ready'); |
|
61 | - } |
|
62 | - |
|
63 | - return true; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $user |
|
68 | - */ |
|
69 | - public function isReadyForUser($user) { |
|
70 | - if (!$this->isReady()) { |
|
71 | - return false; |
|
72 | - } |
|
73 | - |
|
74 | - foreach ($this->getEncryptionModules() as $module) { |
|
75 | - /** @var IEncryptionModule $m */ |
|
76 | - $m = call_user_func($module['callback']); |
|
77 | - if (!$m->isReadyForUser($user)) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - return true; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Registers an callback function which must return an encryption module instance |
|
87 | - * |
|
88 | - * @param string $id |
|
89 | - * @param string $displayName |
|
90 | - * @param callable $callback |
|
91 | - * @throws Exceptions\ModuleAlreadyExistsException |
|
92 | - */ |
|
93 | - public function registerEncryptionModule($id, $displayName, callable $callback) { |
|
94 | - if (isset($this->encryptionModules[$id])) { |
|
95 | - throw new Exceptions\ModuleAlreadyExistsException($id, $displayName); |
|
96 | - } |
|
97 | - |
|
98 | - $this->encryptionModules[$id] = [ |
|
99 | - 'id' => $id, |
|
100 | - 'displayName' => $displayName, |
|
101 | - 'callback' => $callback, |
|
102 | - ]; |
|
103 | - |
|
104 | - $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); |
|
105 | - |
|
106 | - if (empty($defaultEncryptionModuleId)) { |
|
107 | - $this->setDefaultEncryptionModule($id); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Unregisters an encryption module |
|
113 | - * |
|
114 | - * @param string $moduleId |
|
115 | - */ |
|
116 | - public function unregisterEncryptionModule($moduleId) { |
|
117 | - unset($this->encryptionModules[$moduleId]); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * get a list of all encryption modules |
|
122 | - * |
|
123 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
124 | - */ |
|
125 | - public function getEncryptionModules() { |
|
126 | - return $this->encryptionModules; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * get a specific encryption module |
|
131 | - * |
|
132 | - * @param string $moduleId |
|
133 | - * @return IEncryptionModule |
|
134 | - * @throws Exceptions\ModuleDoesNotExistsException |
|
135 | - */ |
|
136 | - public function getEncryptionModule($moduleId = '') { |
|
137 | - if (empty($moduleId)) { |
|
138 | - return $this->getDefaultEncryptionModule(); |
|
139 | - } |
|
140 | - if (isset($this->encryptionModules[$moduleId])) { |
|
141 | - return call_user_func($this->encryptionModules[$moduleId]['callback']); |
|
142 | - } |
|
143 | - $message = "Module with ID: $moduleId does not exist."; |
|
144 | - $hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]); |
|
145 | - throw new Exceptions\ModuleDoesNotExistsException($message, $hint); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * get default encryption module |
|
150 | - * |
|
151 | - * @return \OCP\Encryption\IEncryptionModule |
|
152 | - * @throws Exceptions\ModuleDoesNotExistsException |
|
153 | - */ |
|
154 | - protected function getDefaultEncryptionModule() { |
|
155 | - $defaultModuleId = $this->getDefaultEncryptionModuleId(); |
|
156 | - if (empty($defaultModuleId)) { |
|
157 | - $message = 'No default encryption module defined'; |
|
158 | - throw new Exceptions\ModuleDoesNotExistsException($message); |
|
159 | - } |
|
160 | - if (isset($this->encryptionModules[$defaultModuleId])) { |
|
161 | - return call_user_func($this->encryptionModules[$defaultModuleId]['callback']); |
|
162 | - } |
|
163 | - $message = 'Default encryption module not loaded'; |
|
164 | - throw new Exceptions\ModuleDoesNotExistsException($message); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * set default encryption module Id |
|
169 | - * |
|
170 | - * @param string $moduleId |
|
171 | - * @return bool |
|
172 | - */ |
|
173 | - public function setDefaultEncryptionModule($moduleId) { |
|
174 | - try { |
|
175 | - $this->getEncryptionModule($moduleId); |
|
176 | - } catch (\Exception $e) { |
|
177 | - return false; |
|
178 | - } |
|
179 | - |
|
180 | - $this->config->setAppValue('core', 'default_encryption_module', $moduleId); |
|
181 | - return true; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * get default encryption module Id |
|
186 | - * |
|
187 | - * @return string |
|
188 | - */ |
|
189 | - public function getDefaultEncryptionModuleId() { |
|
190 | - return $this->config->getAppValue('core', 'default_encryption_module'); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Add storage wrapper |
|
195 | - */ |
|
196 | - public function setupStorage() { |
|
197 | - // If encryption is disabled and there are no loaded modules it makes no sense to load the wrapper |
|
198 | - if (!empty($this->encryptionModules) || $this->isEnabled()) { |
|
199 | - $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger); |
|
200 | - Filesystem::addStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage'], 2); |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - public function forceWrapStorage(IMountPoint $mountPoint, IStorage $storage) { |
|
205 | - $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger); |
|
206 | - return $encryptionWrapper->wrapStorage($mountPoint->getMountPoint(), $storage, $mountPoint, true); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * check if key storage is ready |
|
212 | - * |
|
213 | - * @return bool |
|
214 | - */ |
|
215 | - protected function isKeyStorageReady() { |
|
216 | - $rootDir = $this->util->getKeyStorageRoot(); |
|
217 | - |
|
218 | - // the default root is always valid |
|
219 | - if ($rootDir === '') { |
|
220 | - return true; |
|
221 | - } |
|
222 | - |
|
223 | - // check if key storage is mounted correctly |
|
224 | - if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) { |
|
225 | - return true; |
|
226 | - } |
|
227 | - |
|
228 | - return false; |
|
229 | - } |
|
24 | + protected array $encryptionModules; |
|
25 | + |
|
26 | + public function __construct( |
|
27 | + protected IConfig $config, |
|
28 | + protected LoggerInterface $logger, |
|
29 | + protected IL10N $l, |
|
30 | + protected View $rootView, |
|
31 | + protected Util $util, |
|
32 | + protected ArrayCache $arrayCache, |
|
33 | + ) { |
|
34 | + $this->encryptionModules = []; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Check if encryption is enabled |
|
39 | + * |
|
40 | + * @return bool true if enabled, false if not |
|
41 | + */ |
|
42 | + public function isEnabled() { |
|
43 | + $installed = $this->config->getSystemValueBool('installed', false); |
|
44 | + if (!$installed) { |
|
45 | + return false; |
|
46 | + } |
|
47 | + |
|
48 | + $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); |
|
49 | + return $enabled === 'yes'; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * check if new encryption is ready |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + * @throws ServiceUnavailableException |
|
57 | + */ |
|
58 | + public function isReady() { |
|
59 | + if ($this->isKeyStorageReady() === false) { |
|
60 | + throw new ServiceUnavailableException('Key Storage is not ready'); |
|
61 | + } |
|
62 | + |
|
63 | + return true; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $user |
|
68 | + */ |
|
69 | + public function isReadyForUser($user) { |
|
70 | + if (!$this->isReady()) { |
|
71 | + return false; |
|
72 | + } |
|
73 | + |
|
74 | + foreach ($this->getEncryptionModules() as $module) { |
|
75 | + /** @var IEncryptionModule $m */ |
|
76 | + $m = call_user_func($module['callback']); |
|
77 | + if (!$m->isReadyForUser($user)) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + return true; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Registers an callback function which must return an encryption module instance |
|
87 | + * |
|
88 | + * @param string $id |
|
89 | + * @param string $displayName |
|
90 | + * @param callable $callback |
|
91 | + * @throws Exceptions\ModuleAlreadyExistsException |
|
92 | + */ |
|
93 | + public function registerEncryptionModule($id, $displayName, callable $callback) { |
|
94 | + if (isset($this->encryptionModules[$id])) { |
|
95 | + throw new Exceptions\ModuleAlreadyExistsException($id, $displayName); |
|
96 | + } |
|
97 | + |
|
98 | + $this->encryptionModules[$id] = [ |
|
99 | + 'id' => $id, |
|
100 | + 'displayName' => $displayName, |
|
101 | + 'callback' => $callback, |
|
102 | + ]; |
|
103 | + |
|
104 | + $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); |
|
105 | + |
|
106 | + if (empty($defaultEncryptionModuleId)) { |
|
107 | + $this->setDefaultEncryptionModule($id); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Unregisters an encryption module |
|
113 | + * |
|
114 | + * @param string $moduleId |
|
115 | + */ |
|
116 | + public function unregisterEncryptionModule($moduleId) { |
|
117 | + unset($this->encryptionModules[$moduleId]); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * get a list of all encryption modules |
|
122 | + * |
|
123 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
124 | + */ |
|
125 | + public function getEncryptionModules() { |
|
126 | + return $this->encryptionModules; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * get a specific encryption module |
|
131 | + * |
|
132 | + * @param string $moduleId |
|
133 | + * @return IEncryptionModule |
|
134 | + * @throws Exceptions\ModuleDoesNotExistsException |
|
135 | + */ |
|
136 | + public function getEncryptionModule($moduleId = '') { |
|
137 | + if (empty($moduleId)) { |
|
138 | + return $this->getDefaultEncryptionModule(); |
|
139 | + } |
|
140 | + if (isset($this->encryptionModules[$moduleId])) { |
|
141 | + return call_user_func($this->encryptionModules[$moduleId]['callback']); |
|
142 | + } |
|
143 | + $message = "Module with ID: $moduleId does not exist."; |
|
144 | + $hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]); |
|
145 | + throw new Exceptions\ModuleDoesNotExistsException($message, $hint); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * get default encryption module |
|
150 | + * |
|
151 | + * @return \OCP\Encryption\IEncryptionModule |
|
152 | + * @throws Exceptions\ModuleDoesNotExistsException |
|
153 | + */ |
|
154 | + protected function getDefaultEncryptionModule() { |
|
155 | + $defaultModuleId = $this->getDefaultEncryptionModuleId(); |
|
156 | + if (empty($defaultModuleId)) { |
|
157 | + $message = 'No default encryption module defined'; |
|
158 | + throw new Exceptions\ModuleDoesNotExistsException($message); |
|
159 | + } |
|
160 | + if (isset($this->encryptionModules[$defaultModuleId])) { |
|
161 | + return call_user_func($this->encryptionModules[$defaultModuleId]['callback']); |
|
162 | + } |
|
163 | + $message = 'Default encryption module not loaded'; |
|
164 | + throw new Exceptions\ModuleDoesNotExistsException($message); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * set default encryption module Id |
|
169 | + * |
|
170 | + * @param string $moduleId |
|
171 | + * @return bool |
|
172 | + */ |
|
173 | + public function setDefaultEncryptionModule($moduleId) { |
|
174 | + try { |
|
175 | + $this->getEncryptionModule($moduleId); |
|
176 | + } catch (\Exception $e) { |
|
177 | + return false; |
|
178 | + } |
|
179 | + |
|
180 | + $this->config->setAppValue('core', 'default_encryption_module', $moduleId); |
|
181 | + return true; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * get default encryption module Id |
|
186 | + * |
|
187 | + * @return string |
|
188 | + */ |
|
189 | + public function getDefaultEncryptionModuleId() { |
|
190 | + return $this->config->getAppValue('core', 'default_encryption_module'); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Add storage wrapper |
|
195 | + */ |
|
196 | + public function setupStorage() { |
|
197 | + // If encryption is disabled and there are no loaded modules it makes no sense to load the wrapper |
|
198 | + if (!empty($this->encryptionModules) || $this->isEnabled()) { |
|
199 | + $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger); |
|
200 | + Filesystem::addStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage'], 2); |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + public function forceWrapStorage(IMountPoint $mountPoint, IStorage $storage) { |
|
205 | + $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger); |
|
206 | + return $encryptionWrapper->wrapStorage($mountPoint->getMountPoint(), $storage, $mountPoint, true); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * check if key storage is ready |
|
212 | + * |
|
213 | + * @return bool |
|
214 | + */ |
|
215 | + protected function isKeyStorageReady() { |
|
216 | + $rootDir = $this->util->getKeyStorageRoot(); |
|
217 | + |
|
218 | + // the default root is always valid |
|
219 | + if ($rootDir === '') { |
|
220 | + return true; |
|
221 | + } |
|
222 | + |
|
223 | + // check if key storage is mounted correctly |
|
224 | + if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) { |
|
225 | + return true; |
|
226 | + } |
|
227 | + |
|
228 | + return false; |
|
229 | + } |
|
230 | 230 | } |
@@ -26,8 +26,8 @@ |
||
26 | 26 | $server = \OC::$server; |
27 | 27 | |
28 | 28 | $controller = new \OC\OCS\Provider( |
29 | - 'ocs_provider', |
|
30 | - $server->getRequest(), |
|
31 | - $server->getAppManager() |
|
29 | + 'ocs_provider', |
|
30 | + $server->getRequest(), |
|
31 | + $server->getAppManager() |
|
32 | 32 | ); |
33 | 33 | echo $controller->buildProviderList()->render(); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * SPDX-License-Identifier: AGPL-3.0-only |
6 | 6 | */ |
7 | 7 | |
8 | -require_once __DIR__ . '/../lib/base.php'; |
|
8 | +require_once __DIR__.'/../lib/base.php'; |
|
9 | 9 | |
10 | 10 | header('Content-Type: application/json'); |
11 | 11 |
@@ -70,12 +70,12 @@ |
||
70 | 70 | $configName = $input->getArgument('name'); |
71 | 71 | |
72 | 72 | if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
73 | - $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
73 | + $output->writeln('<error>Config '.$configName.' of app '.$appName.' could not be deleted because it did not exist</error>'); |
|
74 | 74 | return 1; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $this->config->deleteAppValue($appName, $configName); |
78 | - $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
78 | + $output->writeln('<info>Config value '.$configName.' of app '.$appName.' deleted</info>'); |
|
79 | 79 | return 0; |
80 | 80 | } |
81 | 81 | } |
@@ -14,48 +14,48 @@ |
||
14 | 14 | use Symfony\Component\Console\Output\OutputInterface; |
15 | 15 | |
16 | 16 | class DeleteConfig extends Base { |
17 | - public function __construct( |
|
18 | - protected IConfig $config, |
|
19 | - ) { |
|
20 | - parent::__construct(); |
|
21 | - } |
|
22 | - |
|
23 | - protected function configure() { |
|
24 | - parent::configure(); |
|
25 | - |
|
26 | - $this |
|
27 | - ->setName('config:app:delete') |
|
28 | - ->setDescription('Delete an app config value') |
|
29 | - ->addArgument( |
|
30 | - 'app', |
|
31 | - InputArgument::REQUIRED, |
|
32 | - 'Name of the app' |
|
33 | - ) |
|
34 | - ->addArgument( |
|
35 | - 'name', |
|
36 | - InputArgument::REQUIRED, |
|
37 | - 'Name of the config to delete' |
|
38 | - ) |
|
39 | - ->addOption( |
|
40 | - 'error-if-not-exists', |
|
41 | - null, |
|
42 | - InputOption::VALUE_NONE, |
|
43 | - 'Checks whether the config exists before deleting it' |
|
44 | - ) |
|
45 | - ; |
|
46 | - } |
|
47 | - |
|
48 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
49 | - $appName = $input->getArgument('app'); |
|
50 | - $configName = $input->getArgument('name'); |
|
51 | - |
|
52 | - if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
53 | - $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
54 | - return 1; |
|
55 | - } |
|
56 | - |
|
57 | - $this->config->deleteAppValue($appName, $configName); |
|
58 | - $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
59 | - return 0; |
|
60 | - } |
|
17 | + public function __construct( |
|
18 | + protected IConfig $config, |
|
19 | + ) { |
|
20 | + parent::__construct(); |
|
21 | + } |
|
22 | + |
|
23 | + protected function configure() { |
|
24 | + parent::configure(); |
|
25 | + |
|
26 | + $this |
|
27 | + ->setName('config:app:delete') |
|
28 | + ->setDescription('Delete an app config value') |
|
29 | + ->addArgument( |
|
30 | + 'app', |
|
31 | + InputArgument::REQUIRED, |
|
32 | + 'Name of the app' |
|
33 | + ) |
|
34 | + ->addArgument( |
|
35 | + 'name', |
|
36 | + InputArgument::REQUIRED, |
|
37 | + 'Name of the config to delete' |
|
38 | + ) |
|
39 | + ->addOption( |
|
40 | + 'error-if-not-exists', |
|
41 | + null, |
|
42 | + InputOption::VALUE_NONE, |
|
43 | + 'Checks whether the config exists before deleting it' |
|
44 | + ) |
|
45 | + ; |
|
46 | + } |
|
47 | + |
|
48 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
49 | + $appName = $input->getArgument('app'); |
|
50 | + $configName = $input->getArgument('name'); |
|
51 | + |
|
52 | + if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
53 | + $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
54 | + return 1; |
|
55 | + } |
|
56 | + |
|
57 | + $this->config->deleteAppValue($appName, $configName); |
|
58 | + $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
59 | + return 0; |
|
60 | + } |
|
61 | 61 | } |