@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $json = file_get_contents('php://stdin'); |
113 | 113 | } else { |
114 | 114 | if (!file_exists($path)) { |
115 | - $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
115 | + $output->writeln('<error>File not found: '.$path.'</error>'); |
|
116 | 116 | return 1; |
117 | 117 | } |
118 | 118 | $json = file_get_contents($path); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
165 | 165 | $existingMount->getBackendOptions() === $mount->getBackendOptions() |
166 | 166 | ) { |
167 | - $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
167 | + $output->writeln("<error>Duplicate mount (".$mount->getMountPoint().")</error>"); |
|
168 | 168 | return 1; |
169 | 169 | } |
170 | 170 | } |
@@ -41,187 +41,187 @@ |
||
41 | 41 | use Symfony\Component\Console\Output\OutputInterface; |
42 | 42 | |
43 | 43 | class Import extends Base { |
44 | - /** |
|
45 | - * @var GlobalStoragesService |
|
46 | - */ |
|
47 | - private $globalService; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var UserStoragesService |
|
51 | - */ |
|
52 | - private $userService; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var IUserSession |
|
56 | - */ |
|
57 | - private $userSession; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var IUserManager |
|
61 | - */ |
|
62 | - private $userManager; |
|
63 | - |
|
64 | - /** @var ImportLegacyStoragesService */ |
|
65 | - private $importLegacyStorageService; |
|
66 | - |
|
67 | - /** @var BackendService */ |
|
68 | - private $backendService; |
|
69 | - |
|
70 | - public function __construct(GlobalStoragesService $globalService, |
|
71 | - UserStoragesService $userService, |
|
72 | - IUserSession $userSession, |
|
73 | - IUserManager $userManager, |
|
74 | - ImportLegacyStoragesService $importLegacyStorageService, |
|
75 | - BackendService $backendService |
|
76 | - ) { |
|
77 | - parent::__construct(); |
|
78 | - $this->globalService = $globalService; |
|
79 | - $this->userService = $userService; |
|
80 | - $this->userSession = $userSession; |
|
81 | - $this->userManager = $userManager; |
|
82 | - $this->importLegacyStorageService = $importLegacyStorageService; |
|
83 | - $this->backendService = $backendService; |
|
84 | - } |
|
85 | - |
|
86 | - protected function configure() { |
|
87 | - $this |
|
88 | - ->setName('files_external:import') |
|
89 | - ->setDescription('Import mount configurations') |
|
90 | - ->addOption( |
|
91 | - 'user', |
|
92 | - '', |
|
93 | - InputOption::VALUE_OPTIONAL, |
|
94 | - 'user to add the mount configurations for, if not set the mount will be added as system mount' |
|
95 | - ) |
|
96 | - ->addArgument( |
|
97 | - 'path', |
|
98 | - InputArgument::REQUIRED, |
|
99 | - 'path to a json file containing the mounts to import, use "-" to read from stdin' |
|
100 | - ) |
|
101 | - ->addOption( |
|
102 | - 'dry', |
|
103 | - '', |
|
104 | - InputOption::VALUE_NONE, |
|
105 | - 'Don\'t save the imported mounts, only list the new mounts' |
|
106 | - ); |
|
107 | - parent::configure(); |
|
108 | - } |
|
109 | - |
|
110 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
111 | - $user = $input->getOption('user'); |
|
112 | - $path = $input->getArgument('path'); |
|
113 | - if ($path === '-') { |
|
114 | - $json = file_get_contents('php://stdin'); |
|
115 | - } else { |
|
116 | - if (!file_exists($path)) { |
|
117 | - $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
118 | - return 1; |
|
119 | - } |
|
120 | - $json = file_get_contents($path); |
|
121 | - } |
|
122 | - if (!is_string($json) || strlen($json) < 2) { |
|
123 | - $output->writeln('<error>Error while reading json</error>'); |
|
124 | - return 1; |
|
125 | - } |
|
126 | - $data = json_decode($json, true); |
|
127 | - if (!is_array($data)) { |
|
128 | - $output->writeln('<error>Error while parsing json</error>'); |
|
129 | - return 1; |
|
130 | - } |
|
131 | - |
|
132 | - $isLegacy = isset($data['user']) || isset($data['group']); |
|
133 | - if ($isLegacy) { |
|
134 | - $this->importLegacyStorageService->setData($data); |
|
135 | - $mounts = $this->importLegacyStorageService->getAllStorages(); |
|
136 | - foreach ($mounts as $mount) { |
|
137 | - if ($mount->getBackendOption('password') === false) { |
|
138 | - $output->writeln('<error>Failed to decrypt password</error>'); |
|
139 | - return 1; |
|
140 | - } |
|
141 | - } |
|
142 | - } else { |
|
143 | - if (!isset($data[0])) { //normalize to an array of mounts |
|
144 | - $data = [$data]; |
|
145 | - } |
|
146 | - $mounts = array_map([$this, 'parseData'], $data); |
|
147 | - } |
|
148 | - |
|
149 | - if ($user) { |
|
150 | - // ensure applicables are correct for personal mounts |
|
151 | - foreach ($mounts as $mount) { |
|
152 | - $mount->setApplicableGroups([]); |
|
153 | - $mount->setApplicableUsers([$user]); |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - $storageService = $this->getStorageService($user); |
|
158 | - |
|
159 | - $existingMounts = $storageService->getAllStorages(); |
|
160 | - |
|
161 | - foreach ($mounts as $mount) { |
|
162 | - foreach ($existingMounts as $existingMount) { |
|
163 | - if ( |
|
164 | - $existingMount->getMountPoint() === $mount->getMountPoint() && |
|
165 | - $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && |
|
166 | - $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
|
167 | - $existingMount->getBackendOptions() === $mount->getBackendOptions() |
|
168 | - ) { |
|
169 | - $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
170 | - return 1; |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - if ($input->getOption('dry')) { |
|
176 | - if (count($mounts) === 0) { |
|
177 | - $output->writeln('<error>No mounts to be imported</error>'); |
|
178 | - return 1; |
|
179 | - } |
|
180 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
181 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
182 | - $listInput->setOption('output', $input->getOption('output')); |
|
183 | - $listInput->setOption('show-password', true); |
|
184 | - $listCommand->listMounts($user, $mounts, $listInput, $output); |
|
185 | - } else { |
|
186 | - foreach ($mounts as $mount) { |
|
187 | - $storageService->addStorage($mount); |
|
188 | - } |
|
189 | - } |
|
190 | - return 0; |
|
191 | - } |
|
192 | - |
|
193 | - private function parseData(array $data) { |
|
194 | - $mount = new StorageConfig($data['mount_id']); |
|
195 | - $mount->setMountPoint($data['mount_point']); |
|
196 | - $mount->setBackend($this->getBackendByClass($data['storage'])); |
|
197 | - $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']); |
|
198 | - $mount->setAuthMechanism($authBackend); |
|
199 | - $mount->setBackendOptions($data['configuration']); |
|
200 | - $mount->setMountOptions($data['options']); |
|
201 | - $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []); |
|
202 | - $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []); |
|
203 | - return $mount; |
|
204 | - } |
|
205 | - |
|
206 | - private function getBackendByClass($className) { |
|
207 | - $backends = $this->backendService->getBackends(); |
|
208 | - foreach ($backends as $backend) { |
|
209 | - if ($backend->getStorageClass() === $className) { |
|
210 | - return $backend; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - protected function getStorageService($userId) { |
|
216 | - if (!empty($userId)) { |
|
217 | - $user = $this->userManager->get($userId); |
|
218 | - if (is_null($user)) { |
|
219 | - throw new NoUserException("user $userId not found"); |
|
220 | - } |
|
221 | - $this->userSession->setUser($user); |
|
222 | - return $this->userService; |
|
223 | - } else { |
|
224 | - return $this->globalService; |
|
225 | - } |
|
226 | - } |
|
44 | + /** |
|
45 | + * @var GlobalStoragesService |
|
46 | + */ |
|
47 | + private $globalService; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var UserStoragesService |
|
51 | + */ |
|
52 | + private $userService; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var IUserSession |
|
56 | + */ |
|
57 | + private $userSession; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var IUserManager |
|
61 | + */ |
|
62 | + private $userManager; |
|
63 | + |
|
64 | + /** @var ImportLegacyStoragesService */ |
|
65 | + private $importLegacyStorageService; |
|
66 | + |
|
67 | + /** @var BackendService */ |
|
68 | + private $backendService; |
|
69 | + |
|
70 | + public function __construct(GlobalStoragesService $globalService, |
|
71 | + UserStoragesService $userService, |
|
72 | + IUserSession $userSession, |
|
73 | + IUserManager $userManager, |
|
74 | + ImportLegacyStoragesService $importLegacyStorageService, |
|
75 | + BackendService $backendService |
|
76 | + ) { |
|
77 | + parent::__construct(); |
|
78 | + $this->globalService = $globalService; |
|
79 | + $this->userService = $userService; |
|
80 | + $this->userSession = $userSession; |
|
81 | + $this->userManager = $userManager; |
|
82 | + $this->importLegacyStorageService = $importLegacyStorageService; |
|
83 | + $this->backendService = $backendService; |
|
84 | + } |
|
85 | + |
|
86 | + protected function configure() { |
|
87 | + $this |
|
88 | + ->setName('files_external:import') |
|
89 | + ->setDescription('Import mount configurations') |
|
90 | + ->addOption( |
|
91 | + 'user', |
|
92 | + '', |
|
93 | + InputOption::VALUE_OPTIONAL, |
|
94 | + 'user to add the mount configurations for, if not set the mount will be added as system mount' |
|
95 | + ) |
|
96 | + ->addArgument( |
|
97 | + 'path', |
|
98 | + InputArgument::REQUIRED, |
|
99 | + 'path to a json file containing the mounts to import, use "-" to read from stdin' |
|
100 | + ) |
|
101 | + ->addOption( |
|
102 | + 'dry', |
|
103 | + '', |
|
104 | + InputOption::VALUE_NONE, |
|
105 | + 'Don\'t save the imported mounts, only list the new mounts' |
|
106 | + ); |
|
107 | + parent::configure(); |
|
108 | + } |
|
109 | + |
|
110 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
111 | + $user = $input->getOption('user'); |
|
112 | + $path = $input->getArgument('path'); |
|
113 | + if ($path === '-') { |
|
114 | + $json = file_get_contents('php://stdin'); |
|
115 | + } else { |
|
116 | + if (!file_exists($path)) { |
|
117 | + $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
118 | + return 1; |
|
119 | + } |
|
120 | + $json = file_get_contents($path); |
|
121 | + } |
|
122 | + if (!is_string($json) || strlen($json) < 2) { |
|
123 | + $output->writeln('<error>Error while reading json</error>'); |
|
124 | + return 1; |
|
125 | + } |
|
126 | + $data = json_decode($json, true); |
|
127 | + if (!is_array($data)) { |
|
128 | + $output->writeln('<error>Error while parsing json</error>'); |
|
129 | + return 1; |
|
130 | + } |
|
131 | + |
|
132 | + $isLegacy = isset($data['user']) || isset($data['group']); |
|
133 | + if ($isLegacy) { |
|
134 | + $this->importLegacyStorageService->setData($data); |
|
135 | + $mounts = $this->importLegacyStorageService->getAllStorages(); |
|
136 | + foreach ($mounts as $mount) { |
|
137 | + if ($mount->getBackendOption('password') === false) { |
|
138 | + $output->writeln('<error>Failed to decrypt password</error>'); |
|
139 | + return 1; |
|
140 | + } |
|
141 | + } |
|
142 | + } else { |
|
143 | + if (!isset($data[0])) { //normalize to an array of mounts |
|
144 | + $data = [$data]; |
|
145 | + } |
|
146 | + $mounts = array_map([$this, 'parseData'], $data); |
|
147 | + } |
|
148 | + |
|
149 | + if ($user) { |
|
150 | + // ensure applicables are correct for personal mounts |
|
151 | + foreach ($mounts as $mount) { |
|
152 | + $mount->setApplicableGroups([]); |
|
153 | + $mount->setApplicableUsers([$user]); |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + $storageService = $this->getStorageService($user); |
|
158 | + |
|
159 | + $existingMounts = $storageService->getAllStorages(); |
|
160 | + |
|
161 | + foreach ($mounts as $mount) { |
|
162 | + foreach ($existingMounts as $existingMount) { |
|
163 | + if ( |
|
164 | + $existingMount->getMountPoint() === $mount->getMountPoint() && |
|
165 | + $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && |
|
166 | + $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
|
167 | + $existingMount->getBackendOptions() === $mount->getBackendOptions() |
|
168 | + ) { |
|
169 | + $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
170 | + return 1; |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + if ($input->getOption('dry')) { |
|
176 | + if (count($mounts) === 0) { |
|
177 | + $output->writeln('<error>No mounts to be imported</error>'); |
|
178 | + return 1; |
|
179 | + } |
|
180 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
181 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
182 | + $listInput->setOption('output', $input->getOption('output')); |
|
183 | + $listInput->setOption('show-password', true); |
|
184 | + $listCommand->listMounts($user, $mounts, $listInput, $output); |
|
185 | + } else { |
|
186 | + foreach ($mounts as $mount) { |
|
187 | + $storageService->addStorage($mount); |
|
188 | + } |
|
189 | + } |
|
190 | + return 0; |
|
191 | + } |
|
192 | + |
|
193 | + private function parseData(array $data) { |
|
194 | + $mount = new StorageConfig($data['mount_id']); |
|
195 | + $mount->setMountPoint($data['mount_point']); |
|
196 | + $mount->setBackend($this->getBackendByClass($data['storage'])); |
|
197 | + $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']); |
|
198 | + $mount->setAuthMechanism($authBackend); |
|
199 | + $mount->setBackendOptions($data['configuration']); |
|
200 | + $mount->setMountOptions($data['options']); |
|
201 | + $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []); |
|
202 | + $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []); |
|
203 | + return $mount; |
|
204 | + } |
|
205 | + |
|
206 | + private function getBackendByClass($className) { |
|
207 | + $backends = $this->backendService->getBackends(); |
|
208 | + foreach ($backends as $backend) { |
|
209 | + if ($backend->getStorageClass() === $className) { |
|
210 | + return $backend; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + protected function getStorageService($userId) { |
|
216 | + if (!empty($userId)) { |
|
217 | + $user = $this->userManager->get($userId); |
|
218 | + if (is_null($user)) { |
|
219 | + throw new NoUserException("user $userId not found"); |
|
220 | + } |
|
221 | + $this->userSession->setUser($user); |
|
222 | + return $this->userService; |
|
223 | + } else { |
|
224 | + return $this->globalService; |
|
225 | + } |
|
226 | + } |
|
227 | 227 | } |
@@ -34,20 +34,20 @@ |
||
34 | 34 | * @method void setName(string $name) |
35 | 35 | */ |
36 | 36 | class Client extends Entity { |
37 | - /** @var string */ |
|
38 | - protected $name; |
|
39 | - /** @var string */ |
|
40 | - protected $redirectUri; |
|
41 | - /** @var string */ |
|
42 | - protected $clientIdentifier; |
|
43 | - /** @var string */ |
|
44 | - protected $secret; |
|
37 | + /** @var string */ |
|
38 | + protected $name; |
|
39 | + /** @var string */ |
|
40 | + protected $redirectUri; |
|
41 | + /** @var string */ |
|
42 | + protected $clientIdentifier; |
|
43 | + /** @var string */ |
|
44 | + protected $secret; |
|
45 | 45 | |
46 | - public function __construct() { |
|
47 | - $this->addType('id', 'int'); |
|
48 | - $this->addType('name', 'string'); |
|
49 | - $this->addType('redirect_uri', 'string'); |
|
50 | - $this->addType('client_identifier', 'string'); |
|
51 | - $this->addType('secret', 'string'); |
|
52 | - } |
|
46 | + public function __construct() { |
|
47 | + $this->addType('id', 'int'); |
|
48 | + $this->addType('name', 'string'); |
|
49 | + $this->addType('redirect_uri', 'string'); |
|
50 | + $this->addType('client_identifier', 'string'); |
|
51 | + $this->addType('secret', 'string'); |
|
52 | + } |
|
53 | 53 | } |
@@ -31,31 +31,31 @@ |
||
31 | 31 | */ |
32 | 32 | interface ICredentials { |
33 | 33 | |
34 | - /** |
|
35 | - * Get the user UID |
|
36 | - * |
|
37 | - * @since 12 |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getUID(); |
|
34 | + /** |
|
35 | + * Get the user UID |
|
36 | + * |
|
37 | + * @since 12 |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getUID(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Get the login name the users used to login |
|
45 | - * |
|
46 | - * @since 12 |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getLoginName(); |
|
43 | + /** |
|
44 | + * Get the login name the users used to login |
|
45 | + * |
|
46 | + * @since 12 |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getLoginName(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the password |
|
54 | - * |
|
55 | - * @since 12 |
|
56 | - * |
|
57 | - * @return string |
|
58 | - * @throws PasswordUnavailableException |
|
59 | - */ |
|
60 | - public function getPassword(); |
|
52 | + /** |
|
53 | + * Get the password |
|
54 | + * |
|
55 | + * @since 12 |
|
56 | + * |
|
57 | + * @return string |
|
58 | + * @throws PasswordUnavailableException |
|
59 | + */ |
|
60 | + public function getPassword(); |
|
61 | 61 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OC\Files\Cache\Wrapper; |
25 | 25 | |
26 | 26 | class CachePermissionsMask extends CacheWrapper { |
27 | - /** |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $mask; |
|
27 | + /** |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $mask; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param \OCP\Files\Cache\ICache $cache |
|
34 | - * @param int $mask |
|
35 | - */ |
|
36 | - public function __construct($cache, $mask) { |
|
37 | - parent::__construct($cache); |
|
38 | - $this->mask = $mask; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param \OCP\Files\Cache\ICache $cache |
|
34 | + * @param int $mask |
|
35 | + */ |
|
36 | + public function __construct($cache, $mask) { |
|
37 | + parent::__construct($cache); |
|
38 | + $this->mask = $mask; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function formatCacheEntry($entry) { |
|
42 | - if (isset($entry['permissions'])) { |
|
43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
44 | - $entry['permissions'] &= $this->mask; |
|
45 | - } |
|
46 | - return $entry; |
|
47 | - } |
|
41 | + protected function formatCacheEntry($entry) { |
|
42 | + if (isset($entry['permissions'])) { |
|
43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
44 | + $entry['permissions'] &= $this->mask; |
|
45 | + } |
|
46 | + return $entry; |
|
47 | + } |
|
48 | 48 | } |
@@ -71,26 +71,26 @@ |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $app = substr($script, 0, strpos($script, '/')); |
74 | - $script = substr($script, strpos($script, '/')+1); |
|
74 | + $script = substr($script, strpos($script, '/') + 1); |
|
75 | 75 | $app_path = \OC_App::getAppPath($app); |
76 | 76 | $app_url = \OC_App::getAppWebPath($app); |
77 | 77 | |
78 | 78 | // missing translations files fill be ignored |
79 | 79 | if (strpos($script, 'l10n/') === 0) { |
80 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
80 | + $this->appendIfExist($app_path, $script.'.js', $app_url); |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($app_path === false && $app_url === false) { |
85 | 85 | $this->logger->error('Could not find resource {resource} to load', [ |
86 | - 'resource' => $app . '/' . $script . '.js', |
|
86 | + 'resource' => $app.'/'.$script.'.js', |
|
87 | 87 | 'app' => 'jsresourceloader', |
88 | 88 | ]); |
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
93 | - $this->append($app_path, $script . '.js', $app_url); |
|
93 | + $this->append($app_path, $script.'.js', $app_url); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 |
@@ -29,103 +29,103 @@ |
||
29 | 29 | |
30 | 30 | class JSResourceLocator extends ResourceLocator { |
31 | 31 | |
32 | - /** @var JSCombiner */ |
|
33 | - protected $jsCombiner; |
|
34 | - |
|
35 | - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
36 | - parent::__construct($logger, $theme, $core_map, $party_map); |
|
37 | - |
|
38 | - $this->jsCombiner = $JSCombiner; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $script |
|
43 | - */ |
|
44 | - public function doFind($script) { |
|
45 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
46 | - if (strpos($script, '3rdparty') === 0 |
|
47 | - && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
48 | - return; |
|
49 | - } |
|
50 | - |
|
51 | - if (strpos($script, '/l10n/') !== false) { |
|
52 | - // For language files we try to load them all, so themes can overwrite |
|
53 | - // single l10n strings without having to translate all of them. |
|
54 | - $found = 0; |
|
55 | - $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
56 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
57 | - $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
58 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
59 | - $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
60 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
61 | - |
|
62 | - if ($found) { |
|
63 | - return; |
|
64 | - } |
|
65 | - } elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
66 | - || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
67 | - || $this->appendIfExist($this->serverroot, $script.'.js') |
|
68 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
69 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
70 | - || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
71 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
72 | - ) { |
|
73 | - return; |
|
74 | - } |
|
75 | - |
|
76 | - $app = substr($script, 0, strpos($script, '/')); |
|
77 | - $script = substr($script, strpos($script, '/')+1); |
|
78 | - $app_path = \OC_App::getAppPath($app); |
|
79 | - $app_url = \OC_App::getAppWebPath($app); |
|
80 | - |
|
81 | - if ($app_path !== false) { |
|
82 | - // Account for the possibility of having symlinks in app path. Only |
|
83 | - // do this if $app_path is set, because an empty argument to realpath |
|
84 | - // gets turned into cwd. |
|
85 | - $app_path = realpath($app_path); |
|
86 | - } |
|
87 | - |
|
88 | - // missing translations files fill be ignored |
|
89 | - if (strpos($script, 'l10n/') === 0) { |
|
90 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
91 | - return; |
|
92 | - } |
|
93 | - |
|
94 | - if ($app_path === false && $app_url === false) { |
|
95 | - $this->logger->error('Could not find resource {resource} to load', [ |
|
96 | - 'resource' => $app . '/' . $script . '.js', |
|
97 | - 'app' => 'jsresourceloader', |
|
98 | - ]); |
|
99 | - return; |
|
100 | - } |
|
101 | - |
|
102 | - if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
103 | - $this->append($app_path, $script . '.js', $app_url); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $script |
|
109 | - */ |
|
110 | - public function doFindTheme($script) { |
|
111 | - } |
|
112 | - |
|
113 | - protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
114 | - if (is_file($root.'/'.$file)) { |
|
115 | - if ($this->jsCombiner->process($root, $file, $app)) { |
|
116 | - $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
117 | - } else { |
|
118 | - // Add all the files from the json |
|
119 | - $files = $this->jsCombiner->getContent($root, $file); |
|
120 | - $app_url = \OC_App::getAppWebPath($app); |
|
121 | - |
|
122 | - foreach ($files as $jsFile) { |
|
123 | - $this->append($root, $jsFile, $app_url); |
|
124 | - } |
|
125 | - } |
|
126 | - return true; |
|
127 | - } |
|
128 | - |
|
129 | - return false; |
|
130 | - } |
|
32 | + /** @var JSCombiner */ |
|
33 | + protected $jsCombiner; |
|
34 | + |
|
35 | + public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
36 | + parent::__construct($logger, $theme, $core_map, $party_map); |
|
37 | + |
|
38 | + $this->jsCombiner = $JSCombiner; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $script |
|
43 | + */ |
|
44 | + public function doFind($script) { |
|
45 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
46 | + if (strpos($script, '3rdparty') === 0 |
|
47 | + && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
48 | + return; |
|
49 | + } |
|
50 | + |
|
51 | + if (strpos($script, '/l10n/') !== false) { |
|
52 | + // For language files we try to load them all, so themes can overwrite |
|
53 | + // single l10n strings without having to translate all of them. |
|
54 | + $found = 0; |
|
55 | + $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
56 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
57 | + $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
58 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
59 | + $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
60 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
61 | + |
|
62 | + if ($found) { |
|
63 | + return; |
|
64 | + } |
|
65 | + } elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
66 | + || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
67 | + || $this->appendIfExist($this->serverroot, $script.'.js') |
|
68 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
69 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
70 | + || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
71 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
72 | + ) { |
|
73 | + return; |
|
74 | + } |
|
75 | + |
|
76 | + $app = substr($script, 0, strpos($script, '/')); |
|
77 | + $script = substr($script, strpos($script, '/')+1); |
|
78 | + $app_path = \OC_App::getAppPath($app); |
|
79 | + $app_url = \OC_App::getAppWebPath($app); |
|
80 | + |
|
81 | + if ($app_path !== false) { |
|
82 | + // Account for the possibility of having symlinks in app path. Only |
|
83 | + // do this if $app_path is set, because an empty argument to realpath |
|
84 | + // gets turned into cwd. |
|
85 | + $app_path = realpath($app_path); |
|
86 | + } |
|
87 | + |
|
88 | + // missing translations files fill be ignored |
|
89 | + if (strpos($script, 'l10n/') === 0) { |
|
90 | + $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
91 | + return; |
|
92 | + } |
|
93 | + |
|
94 | + if ($app_path === false && $app_url === false) { |
|
95 | + $this->logger->error('Could not find resource {resource} to load', [ |
|
96 | + 'resource' => $app . '/' . $script . '.js', |
|
97 | + 'app' => 'jsresourceloader', |
|
98 | + ]); |
|
99 | + return; |
|
100 | + } |
|
101 | + |
|
102 | + if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
103 | + $this->append($app_path, $script . '.js', $app_url); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $script |
|
109 | + */ |
|
110 | + public function doFindTheme($script) { |
|
111 | + } |
|
112 | + |
|
113 | + protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
114 | + if (is_file($root.'/'.$file)) { |
|
115 | + if ($this->jsCombiner->process($root, $file, $app)) { |
|
116 | + $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
117 | + } else { |
|
118 | + // Add all the files from the json |
|
119 | + $files = $this->jsCombiner->getContent($root, $file); |
|
120 | + $app_url = \OC_App::getAppWebPath($app); |
|
121 | + |
|
122 | + foreach ($files as $jsFile) { |
|
123 | + $this->append($root, $jsFile, $app_url); |
|
124 | + } |
|
125 | + } |
|
126 | + return true; |
|
127 | + } |
|
128 | + |
|
129 | + return false; |
|
130 | + } |
|
131 | 131 | } |
@@ -27,45 +27,45 @@ |
||
27 | 27 | |
28 | 28 | class Config implements \OCP\GlobalScale\IConfig { |
29 | 29 | |
30 | - /** @var IConfig */ |
|
31 | - private $config; |
|
30 | + /** @var IConfig */ |
|
31 | + private $config; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Config constructor. |
|
35 | - * |
|
36 | - * @param IConfig $config |
|
37 | - */ |
|
38 | - public function __construct(IConfig $config) { |
|
39 | - $this->config = $config; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Config constructor. |
|
35 | + * |
|
36 | + * @param IConfig $config |
|
37 | + */ |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + $this->config = $config; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * check if global scale is enabled |
|
44 | - * |
|
45 | - * @since 12.0.1 |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function isGlobalScaleEnabled() { |
|
49 | - $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | - return $enabled !== false; |
|
51 | - } |
|
42 | + /** |
|
43 | + * check if global scale is enabled |
|
44 | + * |
|
45 | + * @since 12.0.1 |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function isGlobalScaleEnabled() { |
|
49 | + $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | + return $enabled !== false; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if federation should only be used internally in a global scale setup |
|
55 | - * |
|
56 | - * @since 12.0.1 |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function onlyInternalFederation() { |
|
60 | - // if global scale is disabled federation works always globally |
|
61 | - $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | - if ($gsEnabled === false) { |
|
63 | - return false; |
|
64 | - } |
|
53 | + /** |
|
54 | + * check if federation should only be used internally in a global scale setup |
|
55 | + * |
|
56 | + * @since 12.0.1 |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function onlyInternalFederation() { |
|
60 | + // if global scale is disabled federation works always globally |
|
61 | + $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | + if ($gsEnabled === false) { |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | |
66 | - $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
66 | + $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
67 | 67 | |
68 | - return $enabled === 'internal'; |
|
69 | - } |
|
68 | + return $enabled === 'internal'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -32,20 +32,20 @@ |
||
32 | 32 | */ |
33 | 33 | interface IConfig { |
34 | 34 | |
35 | - /** |
|
36 | - * check if global scale is enabled |
|
37 | - * |
|
38 | - * @since 12.0.1 |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - public function isGlobalScaleEnabled(); |
|
35 | + /** |
|
36 | + * check if global scale is enabled |
|
37 | + * |
|
38 | + * @since 12.0.1 |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + public function isGlobalScaleEnabled(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * check if federation should only be used internally in a global scale setup |
|
45 | - * |
|
46 | - * @since 12.0.1 |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public function onlyInternalFederation(); |
|
43 | + /** |
|
44 | + * check if federation should only be used internally in a global scale setup |
|
45 | + * |
|
46 | + * @since 12.0.1 |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public function onlyInternalFederation(); |
|
50 | 50 | |
51 | 51 | } |
@@ -35,161 +35,161 @@ |
||
35 | 35 | */ |
36 | 36 | interface IEncryptionModule { |
37 | 37 | |
38 | - /** |
|
39 | - * @return string defining the technical unique id |
|
40 | - * @since 8.1.0 |
|
41 | - */ |
|
42 | - public function getId(); |
|
43 | - |
|
44 | - /** |
|
45 | - * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
46 | - * |
|
47 | - * @return string |
|
48 | - * @since 8.1.0 |
|
49 | - */ |
|
50 | - public function getDisplayName(); |
|
51 | - |
|
52 | - /** |
|
53 | - * start receiving chunks from a file. This is the place where you can |
|
54 | - * perform some initial step before starting encrypting/decrypting the |
|
55 | - * chunks |
|
56 | - * |
|
57 | - * @param string $path to the file |
|
58 | - * @param string $user who read/write the file (null for public access) |
|
59 | - * @param string $mode php stream open mode |
|
60 | - * @param array $header contains the header data read from the file |
|
61 | - * @param array $accessList who has access to the file contains the key 'users' and 'public' |
|
62 | - * |
|
63 | - * $return array $header contain data as key-value pairs which should be |
|
64 | - * written to the header, in case of a write operation |
|
65 | - * or if no additional data is needed return a empty array |
|
66 | - * @since 8.1.0 |
|
67 | - */ |
|
68 | - public function begin($path, $user, $mode, array $header, array $accessList); |
|
69 | - |
|
70 | - /** |
|
71 | - * last chunk received. This is the place where you can perform some final |
|
72 | - * operation and return some remaining data if something is left in your |
|
73 | - * buffer. |
|
74 | - * |
|
75 | - * @param string $path to the file |
|
76 | - * @param string $position id of the last block (looks like "<Number>end") |
|
77 | - * |
|
78 | - * @return string remained data which should be written to the file in case |
|
79 | - * of a write operation |
|
80 | - * |
|
81 | - * @since 8.1.0 |
|
82 | - * @since 9.0.0 parameter $position added |
|
83 | - */ |
|
84 | - public function end($path, $position); |
|
85 | - |
|
86 | - /** |
|
87 | - * encrypt data |
|
88 | - * |
|
89 | - * @param string $data you want to encrypt |
|
90 | - * @param string $position position of the block we want to encrypt (starts with '0') |
|
91 | - * |
|
92 | - * @return mixed encrypted data |
|
93 | - * |
|
94 | - * @since 8.1.0 |
|
95 | - * @since 9.0.0 parameter $position added |
|
96 | - */ |
|
97 | - public function encrypt($data, $position); |
|
98 | - |
|
99 | - /** |
|
100 | - * decrypt data |
|
101 | - * |
|
102 | - * @param string $data you want to decrypt |
|
103 | - * @param string $position position of the block we want to decrypt |
|
104 | - * |
|
105 | - * @return mixed decrypted data |
|
106 | - * |
|
107 | - * @since 8.1.0 |
|
108 | - * @since 9.0.0 parameter $position added |
|
109 | - */ |
|
110 | - public function decrypt($data, $position); |
|
111 | - |
|
112 | - /** |
|
113 | - * update encrypted file, e.g. give additional users access to the file |
|
114 | - * |
|
115 | - * @param string $path path to the file which should be updated |
|
116 | - * @param string $uid of the user who performs the operation |
|
117 | - * @param array $accessList who has access to the file contains the key 'users' and 'public' |
|
118 | - * @return boolean |
|
119 | - * @since 8.1.0 |
|
120 | - */ |
|
121 | - public function update($path, $uid, array $accessList); |
|
122 | - |
|
123 | - /** |
|
124 | - * should the file be encrypted or not |
|
125 | - * |
|
126 | - * @param string $path |
|
127 | - * @return boolean |
|
128 | - * @since 8.1.0 |
|
129 | - */ |
|
130 | - public function shouldEncrypt($path); |
|
131 | - |
|
132 | - /** |
|
133 | - * get size of the unencrypted payload per block. |
|
134 | - * ownCloud read/write files with a block size of 8192 byte |
|
135 | - * |
|
136 | - * @param bool $signed |
|
137 | - * @return int |
|
138 | - * @since 8.1.0 optional parameter $signed was added in 9.0.0 |
|
139 | - */ |
|
140 | - public function getUnencryptedBlockSize($signed = false); |
|
141 | - |
|
142 | - /** |
|
143 | - * check if the encryption module is able to read the file, |
|
144 | - * e.g. if all encryption keys exists |
|
145 | - * |
|
146 | - * @param string $path |
|
147 | - * @param string $uid user for whom we want to check if he can read the file |
|
148 | - * @return boolean |
|
149 | - * @since 8.1.0 |
|
150 | - */ |
|
151 | - public function isReadable($path, $uid); |
|
152 | - |
|
153 | - /** |
|
154 | - * Initial encryption of all files |
|
155 | - * |
|
156 | - * @param InputInterface $input |
|
157 | - * @param OutputInterface $output write some status information to the terminal during encryption |
|
158 | - * @since 8.2.0 |
|
159 | - */ |
|
160 | - public function encryptAll(InputInterface $input, OutputInterface $output); |
|
161 | - |
|
162 | - /** |
|
163 | - * prepare encryption module to decrypt all files |
|
164 | - * |
|
165 | - * @param InputInterface $input |
|
166 | - * @param OutputInterface $output write some status information to the terminal during encryption |
|
167 | - * @param $user (optional) for which the files should be decrypted, default = all users |
|
168 | - * @return bool return false on failure or if it isn't supported by the module |
|
169 | - * @since 8.2.0 |
|
170 | - */ |
|
171 | - public function prepareDecryptAll(InputInterface $input, OutputInterface $output, $user = ''); |
|
172 | - |
|
173 | - /** |
|
174 | - * Check if the module is ready to be used by that specific user. |
|
175 | - * In case a module is not ready - because e.g. key pairs have not been generated |
|
176 | - * upon login this method can return false before any operation starts and might |
|
177 | - * cause issues during operations. |
|
178 | - * |
|
179 | - * @param string $user |
|
180 | - * @return boolean |
|
181 | - * @since 9.1.0 |
|
182 | - */ |
|
183 | - public function isReadyForUser($user); |
|
184 | - |
|
185 | - /** |
|
186 | - * Does the encryption module needs a detailed list of users with access to the file? |
|
187 | - * For example if the encryption module uses per-user encryption keys and needs to know |
|
188 | - * the users with access to the file to encrypt/decrypt it. |
|
189 | - * |
|
190 | - * @since 13.0.0 |
|
191 | - * @return bool |
|
192 | - */ |
|
193 | - public function needDetailedAccessList(); |
|
38 | + /** |
|
39 | + * @return string defining the technical unique id |
|
40 | + * @since 8.1.0 |
|
41 | + */ |
|
42 | + public function getId(); |
|
43 | + |
|
44 | + /** |
|
45 | + * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
46 | + * |
|
47 | + * @return string |
|
48 | + * @since 8.1.0 |
|
49 | + */ |
|
50 | + public function getDisplayName(); |
|
51 | + |
|
52 | + /** |
|
53 | + * start receiving chunks from a file. This is the place where you can |
|
54 | + * perform some initial step before starting encrypting/decrypting the |
|
55 | + * chunks |
|
56 | + * |
|
57 | + * @param string $path to the file |
|
58 | + * @param string $user who read/write the file (null for public access) |
|
59 | + * @param string $mode php stream open mode |
|
60 | + * @param array $header contains the header data read from the file |
|
61 | + * @param array $accessList who has access to the file contains the key 'users' and 'public' |
|
62 | + * |
|
63 | + * $return array $header contain data as key-value pairs which should be |
|
64 | + * written to the header, in case of a write operation |
|
65 | + * or if no additional data is needed return a empty array |
|
66 | + * @since 8.1.0 |
|
67 | + */ |
|
68 | + public function begin($path, $user, $mode, array $header, array $accessList); |
|
69 | + |
|
70 | + /** |
|
71 | + * last chunk received. This is the place where you can perform some final |
|
72 | + * operation and return some remaining data if something is left in your |
|
73 | + * buffer. |
|
74 | + * |
|
75 | + * @param string $path to the file |
|
76 | + * @param string $position id of the last block (looks like "<Number>end") |
|
77 | + * |
|
78 | + * @return string remained data which should be written to the file in case |
|
79 | + * of a write operation |
|
80 | + * |
|
81 | + * @since 8.1.0 |
|
82 | + * @since 9.0.0 parameter $position added |
|
83 | + */ |
|
84 | + public function end($path, $position); |
|
85 | + |
|
86 | + /** |
|
87 | + * encrypt data |
|
88 | + * |
|
89 | + * @param string $data you want to encrypt |
|
90 | + * @param string $position position of the block we want to encrypt (starts with '0') |
|
91 | + * |
|
92 | + * @return mixed encrypted data |
|
93 | + * |
|
94 | + * @since 8.1.0 |
|
95 | + * @since 9.0.0 parameter $position added |
|
96 | + */ |
|
97 | + public function encrypt($data, $position); |
|
98 | + |
|
99 | + /** |
|
100 | + * decrypt data |
|
101 | + * |
|
102 | + * @param string $data you want to decrypt |
|
103 | + * @param string $position position of the block we want to decrypt |
|
104 | + * |
|
105 | + * @return mixed decrypted data |
|
106 | + * |
|
107 | + * @since 8.1.0 |
|
108 | + * @since 9.0.0 parameter $position added |
|
109 | + */ |
|
110 | + public function decrypt($data, $position); |
|
111 | + |
|
112 | + /** |
|
113 | + * update encrypted file, e.g. give additional users access to the file |
|
114 | + * |
|
115 | + * @param string $path path to the file which should be updated |
|
116 | + * @param string $uid of the user who performs the operation |
|
117 | + * @param array $accessList who has access to the file contains the key 'users' and 'public' |
|
118 | + * @return boolean |
|
119 | + * @since 8.1.0 |
|
120 | + */ |
|
121 | + public function update($path, $uid, array $accessList); |
|
122 | + |
|
123 | + /** |
|
124 | + * should the file be encrypted or not |
|
125 | + * |
|
126 | + * @param string $path |
|
127 | + * @return boolean |
|
128 | + * @since 8.1.0 |
|
129 | + */ |
|
130 | + public function shouldEncrypt($path); |
|
131 | + |
|
132 | + /** |
|
133 | + * get size of the unencrypted payload per block. |
|
134 | + * ownCloud read/write files with a block size of 8192 byte |
|
135 | + * |
|
136 | + * @param bool $signed |
|
137 | + * @return int |
|
138 | + * @since 8.1.0 optional parameter $signed was added in 9.0.0 |
|
139 | + */ |
|
140 | + public function getUnencryptedBlockSize($signed = false); |
|
141 | + |
|
142 | + /** |
|
143 | + * check if the encryption module is able to read the file, |
|
144 | + * e.g. if all encryption keys exists |
|
145 | + * |
|
146 | + * @param string $path |
|
147 | + * @param string $uid user for whom we want to check if he can read the file |
|
148 | + * @return boolean |
|
149 | + * @since 8.1.0 |
|
150 | + */ |
|
151 | + public function isReadable($path, $uid); |
|
152 | + |
|
153 | + /** |
|
154 | + * Initial encryption of all files |
|
155 | + * |
|
156 | + * @param InputInterface $input |
|
157 | + * @param OutputInterface $output write some status information to the terminal during encryption |
|
158 | + * @since 8.2.0 |
|
159 | + */ |
|
160 | + public function encryptAll(InputInterface $input, OutputInterface $output); |
|
161 | + |
|
162 | + /** |
|
163 | + * prepare encryption module to decrypt all files |
|
164 | + * |
|
165 | + * @param InputInterface $input |
|
166 | + * @param OutputInterface $output write some status information to the terminal during encryption |
|
167 | + * @param $user (optional) for which the files should be decrypted, default = all users |
|
168 | + * @return bool return false on failure or if it isn't supported by the module |
|
169 | + * @since 8.2.0 |
|
170 | + */ |
|
171 | + public function prepareDecryptAll(InputInterface $input, OutputInterface $output, $user = ''); |
|
172 | + |
|
173 | + /** |
|
174 | + * Check if the module is ready to be used by that specific user. |
|
175 | + * In case a module is not ready - because e.g. key pairs have not been generated |
|
176 | + * upon login this method can return false before any operation starts and might |
|
177 | + * cause issues during operations. |
|
178 | + * |
|
179 | + * @param string $user |
|
180 | + * @return boolean |
|
181 | + * @since 9.1.0 |
|
182 | + */ |
|
183 | + public function isReadyForUser($user); |
|
184 | + |
|
185 | + /** |
|
186 | + * Does the encryption module needs a detailed list of users with access to the file? |
|
187 | + * For example if the encryption module uses per-user encryption keys and needs to know |
|
188 | + * the users with access to the file to encrypt/decrypt it. |
|
189 | + * |
|
190 | + * @since 13.0.0 |
|
191 | + * @return bool |
|
192 | + */ |
|
193 | + public function needDetailedAccessList(); |
|
194 | 194 | |
195 | 195 | } |
@@ -35,43 +35,43 @@ |
||
35 | 35 | class SetMasterKeyStatus implements IRepairStep { |
36 | 36 | |
37 | 37 | |
38 | - /** @var IConfig */ |
|
39 | - private $config; |
|
38 | + /** @var IConfig */ |
|
39 | + private $config; |
|
40 | 40 | |
41 | 41 | |
42 | - public function __construct(IConfig $config) { |
|
43 | - $this->config = $config; |
|
44 | - } |
|
42 | + public function __construct(IConfig $config) { |
|
43 | + $this->config = $config; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns the step's name |
|
48 | - * |
|
49 | - * @return string |
|
50 | - * @since 9.1.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return 'Write default encryption module configuration to the database'; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Returns the step's name |
|
48 | + * |
|
49 | + * @return string |
|
50 | + * @since 9.1.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return 'Write default encryption module configuration to the database'; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param IOutput $output |
|
58 | - */ |
|
59 | - public function run(IOutput $output) { |
|
60 | - if (!$this->shouldRun()) { |
|
61 | - return; |
|
62 | - } |
|
56 | + /** |
|
57 | + * @param IOutput $output |
|
58 | + */ |
|
59 | + public function run(IOutput $output) { |
|
60 | + if (!$this->shouldRun()) { |
|
61 | + return; |
|
62 | + } |
|
63 | 63 | |
64 | - // if no config for the master key is set we set it explicitly to '0' in |
|
65 | - // order not to break old installations because the default changed to '1'. |
|
66 | - $configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false); |
|
67 | - if ($configAlreadySet === false) { |
|
68 | - $this->config->setAppValue('encryption', 'useMasterKey', '0'); |
|
69 | - } |
|
70 | - } |
|
64 | + // if no config for the master key is set we set it explicitly to '0' in |
|
65 | + // order not to break old installations because the default changed to '1'. |
|
66 | + $configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false); |
|
67 | + if ($configAlreadySet === false) { |
|
68 | + $this->config->setAppValue('encryption', 'useMasterKey', '0'); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - protected function shouldRun() { |
|
73 | - $appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0'); |
|
74 | - return version_compare($appVersion, '2.0.0', '<'); |
|
75 | - } |
|
72 | + protected function shouldRun() { |
|
73 | + $appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0'); |
|
74 | + return version_compare($appVersion, '2.0.0', '<'); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |