-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathMountConfig.php
More file actions
94 lines (85 loc) · 2.63 KB
/
Copy pathMountConfig.php
File metadata and controls
94 lines (85 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\EncryptionService;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
/**
* Class to configure mount.json globally and for users
*/
class MountConfig {
public const MOUNT_TYPE_GLOBAL = 'global';
public const MOUNT_TYPE_GROUP = 'group';
public const MOUNT_TYPE_USER = 'user';
public const MOUNT_TYPE_PERSONAL = 'personal';
/**
* @param mixed $input
* @param string|null $userId
* @return mixed
* @throws ContainerExceptionInterface
* @since 16.0.0
* @deprecated 34.0.0 use BackendService instead
*/
public static function substitutePlaceholdersInConfig($input, ?string $userId = null) {
return Server::get(BackendService::class)->applyConfigHandlers($input, $userId);
}
/**
* Test connecting using the given backend configuration
*
* @param string $class backend class name
* @param array $options backend configuration options
* @param boolean $isPersonal
* @return int see self::STATUS_*
* @throws \Exception
* @deprecated 34.0.0 use BackendService instead
*/
public static function getBackendStatus($class, $options) {
return Server::get(BackendService::class)->getBackendStatus($class, $options);
}
/**
* Encrypt passwords in the given config options
*
* @param array $options mount options
* @return array updated options
* @deprecated 34.0.0 use EncryptionService instead
*/
public static function encryptPasswords($options) {
return Server::get(EncryptionService::class)->encryptPasswords($options);
}
/**
* Decrypt passwords in the given config options
*
* @param array $options mount options
* @return array updated options
* @deprecated 34.0.0 use EncryptionService instead
*/
public static function decryptPasswords($options) {
return Server::get(EncryptionService::class)->decryptPasswords($options);
}
/**
* Computes a hash based on the given configuration.
* This is mostly used to find out whether configurations
* are the same.
* @throws \JsonException
*/
public static function makeConfigHash(array $config): string {
$data = json_encode(
[
'c' => $config['backend'],
'a' => $config['authMechanism'],
'm' => $config['mountpoint'],
'o' => $config['options'],
'p' => $config['priority'] ?? -1,
'mo' => $config['mountOptions'] ?? [],
],
JSON_THROW_ON_ERROR
);
return hash('md5', $data);
}
}