Completed
Push — master ( 49662f...f67d94 )
by Joas
99:38 queued 81:58
created
lib/private/Files/Cache/Wrapper/CachePermissionsMask.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/oauth2/lib/Db/ClientMapper.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -28,62 +28,62 @@
 block discarded – undo
28 28
 
29 29
 class ClientMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * @param IDBConnection $db
33
-	 */
34
-	public function __construct(IDBConnection $db) {
35
-		parent::__construct($db, 'oauth2_clients');
36
-	}
31
+    /**
32
+     * @param IDBConnection $db
33
+     */
34
+    public function __construct(IDBConnection $db) {
35
+        parent::__construct($db, 'oauth2_clients');
36
+    }
37 37
 
38
-	/**
39
-	 * @param string $clientIdentifier
40
-	 * @return Client
41
-	 * @throws ClientNotFoundException
42
-	 */
43
-	public function getByIdentifier($clientIdentifier) {
44
-		$qb = $this->db->getQueryBuilder();
45
-		$qb
46
-			->select('*')
47
-			->from($this->tableName)
48
-			->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier)));
49
-		$result = $qb->execute();
50
-		$row = $result->fetch();
51
-		$result->closeCursor();
52
-		if($row === false) {
53
-			throw new ClientNotFoundException();
54
-		}
55
-		return Client::fromRow($row);
56
-	}
38
+    /**
39
+     * @param string $clientIdentifier
40
+     * @return Client
41
+     * @throws ClientNotFoundException
42
+     */
43
+    public function getByIdentifier($clientIdentifier) {
44
+        $qb = $this->db->getQueryBuilder();
45
+        $qb
46
+            ->select('*')
47
+            ->from($this->tableName)
48
+            ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier)));
49
+        $result = $qb->execute();
50
+        $row = $result->fetch();
51
+        $result->closeCursor();
52
+        if($row === false) {
53
+            throw new ClientNotFoundException();
54
+        }
55
+        return Client::fromRow($row);
56
+    }
57 57
 
58
-	/**
59
-	 * @param string $uid internal uid of the client
60
-	 * @return Client
61
-	 * @throws ClientNotFoundException
62
-	 */
63
-	public function getByUid($uid) {
64
-		$qb = $this->db->getQueryBuilder();
65
-		$qb
66
-			->select('*')
67
-			->from($this->tableName)
68
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT)));
69
-		$result = $qb->execute();
70
-		$row = $result->fetch();
71
-		$result->closeCursor();
72
-		if($row === false) {
73
-			throw new ClientNotFoundException();
74
-		}
75
-		return Client::fromRow($row);
76
-	}
58
+    /**
59
+     * @param string $uid internal uid of the client
60
+     * @return Client
61
+     * @throws ClientNotFoundException
62
+     */
63
+    public function getByUid($uid) {
64
+        $qb = $this->db->getQueryBuilder();
65
+        $qb
66
+            ->select('*')
67
+            ->from($this->tableName)
68
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT)));
69
+        $result = $qb->execute();
70
+        $row = $result->fetch();
71
+        $result->closeCursor();
72
+        if($row === false) {
73
+            throw new ClientNotFoundException();
74
+        }
75
+        return Client::fromRow($row);
76
+    }
77 77
 
78
-	/**
79
-	 * @return Client[]
80
-	 */
81
-	public function getClients() {
82
-		$qb = $this->db->getQueryBuilder();
83
-		$qb
84
-			->select('*')
85
-			->from($this->tableName);
78
+    /**
79
+     * @return Client[]
80
+     */
81
+    public function getClients() {
82
+        $qb = $this->db->getQueryBuilder();
83
+        $qb
84
+            ->select('*')
85
+            ->from($this->tableName);
86 86
 
87
-		return $this->findEntities($qb->getSQL());
88
-	}
87
+        return $this->findEntities($qb->getSQL());
88
+    }
89 89
 }
Please login to merge, or discard this patch.
apps/oauth2/lib/Db/AccessTokenMapper.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,43 +28,43 @@
 block discarded – undo
28 28
 
29 29
 class AccessTokenMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * @param IDBConnection $db
33
-	 */
34
-	public function __construct(IDBConnection $db) {
35
-		parent::__construct($db, 'oauth2_access_tokens');
36
-	}
31
+    /**
32
+     * @param IDBConnection $db
33
+     */
34
+    public function __construct(IDBConnection $db) {
35
+        parent::__construct($db, 'oauth2_access_tokens');
36
+    }
37 37
 
38
-	/**
39
-	 * @param string $code
40
-	 * @return AccessToken
41
-	 * @throws AccessTokenNotFoundException
42
-	 */
43
-	public function getByCode($code) {
44
-		$qb = $this->db->getQueryBuilder();
45
-		$qb
46
-			->select('*')
47
-			->from($this->tableName)
48
-			->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code))));
49
-		$result = $qb->execute();
50
-		$row = $result->fetch();
51
-		$result->closeCursor();
52
-		if($row === false) {
53
-			throw new AccessTokenNotFoundException();
54
-		}
55
-		return AccessToken::fromRow($row);
56
-	}
38
+    /**
39
+     * @param string $code
40
+     * @return AccessToken
41
+     * @throws AccessTokenNotFoundException
42
+     */
43
+    public function getByCode($code) {
44
+        $qb = $this->db->getQueryBuilder();
45
+        $qb
46
+            ->select('*')
47
+            ->from($this->tableName)
48
+            ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code))));
49
+        $result = $qb->execute();
50
+        $row = $result->fetch();
51
+        $result->closeCursor();
52
+        if($row === false) {
53
+            throw new AccessTokenNotFoundException();
54
+        }
55
+        return AccessToken::fromRow($row);
56
+    }
57 57
 
58
-	/**
59
-	 * delete all access token from a given client
60
-	 *
61
-	 * @param int $id
62
-	 */
63
-	public function deleteByClientId($id) {
64
-		$qb = $this->db->getQueryBuilder();
65
-		$qb
66
-			->delete($this->tableName)
67
-			->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
68
-		$qb->execute();
69
-	}
58
+    /**
59
+     * delete all access token from a given client
60
+     *
61
+     * @param int $id
62
+     */
63
+    public function deleteByClientId($id) {
64
+        $qb = $this->db->getQueryBuilder();
65
+        $qb
66
+            ->delete($this->tableName)
67
+            ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
68
+        $qb->execute();
69
+    }
70 70
 }
Please login to merge, or discard this patch.
lib/private/Settings/Personal/Additional.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@
 block discarded – undo
29 29
 
30 30
 class Additional implements ISettings {
31 31
 
32
-	/**
33
-	 * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
34
-	 * @since 9.1
35
-	 */
36
-	public function getForm() {
37
-		return new TemplateResponse('settings', 'settings/empty');
38
-	}
32
+    /**
33
+     * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
34
+     * @since 9.1
35
+     */
36
+    public function getForm() {
37
+        return new TemplateResponse('settings', 'settings/empty');
38
+    }
39 39
 
40
-	/**
41
-	 * @return string the section ID, e.g. 'sharing'
42
-	 * @since 9.1
43
-	 */
44
-	public function getSection() {
45
-		return 'additional';
46
-	}
40
+    /**
41
+     * @return string the section ID, e.g. 'sharing'
42
+     * @since 9.1
43
+     */
44
+    public function getSection() {
45
+        return 'additional';
46
+    }
47 47
 
48
-	/**
49
-	 * @return int whether the form should be rather on the top or bottom of
50
-	 * the admin section. The forms are arranged in ascending order of the
51
-	 * priority values. It is required to return a value between 0 and 100.
52
-	 *
53
-	 * E.g.: 70
54
-	 * @since 9.1
55
-	 */
56
-	public function getPriority() {
57
-		return '5';
58
-	}
48
+    /**
49
+     * @return int whether the form should be rather on the top or bottom of
50
+     * the admin section. The forms are arranged in ascending order of the
51
+     * priority values. It is required to return a value between 0 and 100.
52
+     *
53
+     * E.g.: 70
54
+     * @since 9.1
55
+     */
56
+    public function getPriority() {
57
+        return '5';
58
+    }
59 59
 }
Please login to merge, or discard this patch.
lib/private/ServerContainer.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -34,101 +34,101 @@
 block discarded – undo
34 34
  * @package OC
35 35
  */
36 36
 class ServerContainer extends SimpleContainer {
37
-	/** @var DIContainer[] */
38
-	protected $appContainers;
37
+    /** @var DIContainer[] */
38
+    protected $appContainers;
39 39
 
40
-	/** @var string[] */
41
-	protected $hasNoAppContainer;
40
+    /** @var string[] */
41
+    protected $hasNoAppContainer;
42 42
 
43
-	/** @var string[] */
44
-	protected $namespaces;
43
+    /** @var string[] */
44
+    protected $namespaces;
45 45
 
46
-	/**
47
-	 * ServerContainer constructor.
48
-	 */
49
-	public function __construct() {
50
-		parent::__construct();
51
-		$this->appContainers = [];
52
-		$this->namespaces = [];
53
-		$this->hasNoAppContainer = [];
54
-	}
46
+    /**
47
+     * ServerContainer constructor.
48
+     */
49
+    public function __construct() {
50
+        parent::__construct();
51
+        $this->appContainers = [];
52
+        $this->namespaces = [];
53
+        $this->hasNoAppContainer = [];
54
+    }
55 55
 
56
-	/**
57
-	 * @param string $appName
58
-	 * @param string $appNamespace
59
-	 */
60
-	public function registerNamespace($appName, $appNamespace) {
61
-		// Cut of OCA\ and lowercase
62
-		$appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1));
63
-		$this->namespaces[$appNamespace] = $appName;
64
-	}
56
+    /**
57
+     * @param string $appName
58
+     * @param string $appNamespace
59
+     */
60
+    public function registerNamespace($appName, $appNamespace) {
61
+        // Cut of OCA\ and lowercase
62
+        $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1));
63
+        $this->namespaces[$appNamespace] = $appName;
64
+    }
65 65
 
66
-	/**
67
-	 * @param string $appName
68
-	 * @param DIContainer $container
69
-	 */
70
-	public function registerAppContainer($appName, DIContainer $container) {
71
-		$this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container;
72
-	}
66
+    /**
67
+     * @param string $appName
68
+     * @param DIContainer $container
69
+     */
70
+    public function registerAppContainer($appName, DIContainer $container) {
71
+        $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container;
72
+    }
73 73
 
74
-	/**
75
-	 * @param string $namespace
76
-	 * @param string $sensitiveNamespace
77
-	 * @return DIContainer
78
-	 * @throws QueryException
79
-	 */
80
-	protected function getAppContainer($namespace, $sensitiveNamespace) {
81
-		if (isset($this->appContainers[$namespace])) {
82
-			return $this->appContainers[$namespace];
83
-		}
74
+    /**
75
+     * @param string $namespace
76
+     * @param string $sensitiveNamespace
77
+     * @return DIContainer
78
+     * @throws QueryException
79
+     */
80
+    protected function getAppContainer($namespace, $sensitiveNamespace) {
81
+        if (isset($this->appContainers[$namespace])) {
82
+            return $this->appContainers[$namespace];
83
+        }
84 84
 
85
-		if (isset($this->namespaces[$namespace])) {
86
-			if (!isset($this->hasNoAppContainer[$namespace])) {
87
-				$applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application';
88
-				if (class_exists($applicationClassName)) {
89
-					new $applicationClassName();
90
-					if (isset($this->appContainers[$namespace])) {
91
-						return $this->appContainers[$namespace];
92
-					}
93
-				}
94
-				$this->hasNoAppContainer[$namespace] = true;
95
-			}
85
+        if (isset($this->namespaces[$namespace])) {
86
+            if (!isset($this->hasNoAppContainer[$namespace])) {
87
+                $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application';
88
+                if (class_exists($applicationClassName)) {
89
+                    new $applicationClassName();
90
+                    if (isset($this->appContainers[$namespace])) {
91
+                        return $this->appContainers[$namespace];
92
+                    }
93
+                }
94
+                $this->hasNoAppContainer[$namespace] = true;
95
+            }
96 96
 
97
-			return new DIContainer($this->namespaces[$namespace]);
98
-		}
99
-		throw new QueryException();
100
-	}
97
+            return new DIContainer($this->namespaces[$namespace]);
98
+        }
99
+        throw new QueryException();
100
+    }
101 101
 
102
-	/**
103
-	 * @param string $name name of the service to query for
104
-	 * @return mixed registered service for the given $name
105
-	 * @throws QueryException if the query could not be resolved
106
-	 */
107
-	public function query($name) {
108
-		$name = $this->sanitizeName($name);
102
+    /**
103
+     * @param string $name name of the service to query for
104
+     * @return mixed registered service for the given $name
105
+     * @throws QueryException if the query could not be resolved
106
+     */
107
+    public function query($name) {
108
+        $name = $this->sanitizeName($name);
109 109
 
110
-		// In case the service starts with OCA\ we try to find the service in
111
-		// the apps container first.
112
-		if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
113
-			$segments = explode('\\', $name);
114
-			try {
115
-				$appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]);
116
-				return $appContainer->queryNoFallback($name);
117
-			} catch (QueryException $e) {
118
-				// Didn't find the service or the respective app container,
119
-				// ignore it and fall back to the core container.
120
-			}
121
-		} else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) {
122
-			$segments = explode('\\', $name);
123
-			try {
124
-				$appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]);
125
-				return $appContainer->queryNoFallback($name);
126
-			} catch (QueryException $e) {
127
-				// Didn't find the service or the respective app container,
128
-				// ignore it and fall back to the core container.
129
-			}
130
-		}
110
+        // In case the service starts with OCA\ we try to find the service in
111
+        // the apps container first.
112
+        if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
113
+            $segments = explode('\\', $name);
114
+            try {
115
+                $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]);
116
+                return $appContainer->queryNoFallback($name);
117
+            } catch (QueryException $e) {
118
+                // Didn't find the service or the respective app container,
119
+                // ignore it and fall back to the core container.
120
+            }
121
+        } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) {
122
+            $segments = explode('\\', $name);
123
+            try {
124
+                $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]);
125
+                return $appContainer->queryNoFallback($name);
126
+            } catch (QueryException $e) {
127
+                // Didn't find the service or the respective app container,
128
+                // ignore it and fall back to the core container.
129
+            }
130
+        }
131 131
 
132
-		return parent::query($name);
133
-	}
132
+        return parent::query($name);
133
+    }
134 134
 }
Please login to merge, or discard this patch.
lib/private/GlobalScale/Config.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -27,45 +27,45 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/public/GlobalScale/IConfig.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,20 +32,20 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/public/Encryption/IEncryptionModule.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -35,161 +35,161 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Encryption/Update.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -33,162 +33,162 @@
 block discarded – undo
33 33
  */
34 34
 class Update {
35 35
 
36
-	/** @var \OC\Files\View */
37
-	protected $view;
38
-
39
-	/** @var \OC\Encryption\Util */
40
-	protected $util;
41
-
42
-	 /** @var \OC\Files\Mount\Manager */
43
-	protected $mountManager;
44
-
45
-	/** @var \OC\Encryption\Manager */
46
-	protected $encryptionManager;
47
-
48
-	/** @var string */
49
-	protected $uid;
50
-
51
-	/** @var \OC\Encryption\File */
52
-	protected $file;
53
-
54
-	/**
55
-	 *
56
-	 * @param \OC\Files\View $view
57
-	 * @param \OC\Encryption\Util $util
58
-	 * @param \OC\Files\Mount\Manager $mountManager
59
-	 * @param \OC\Encryption\Manager $encryptionManager
60
-	 * @param \OC\Encryption\File $file
61
-	 * @param string $uid
62
-	 */
63
-	public function __construct(
64
-			View $view,
65
-			Util $util,
66
-			Mount\Manager $mountManager,
67
-			Manager $encryptionManager,
68
-			File $file,
69
-			$uid
70
-		) {
71
-
72
-		$this->view = $view;
73
-		$this->util = $util;
74
-		$this->mountManager = $mountManager;
75
-		$this->encryptionManager = $encryptionManager;
76
-		$this->file = $file;
77
-		$this->uid = $uid;
78
-	}
79
-
80
-	/**
81
-	 * hook after file was shared
82
-	 *
83
-	 * @param array $params
84
-	 */
85
-	public function postShared($params) {
86
-		if ($this->encryptionManager->isEnabled()) {
87
-			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
88
-				$path = Filesystem::getPath($params['fileSource']);
89
-				list($owner, $ownerPath) = $this->getOwnerPath($path);
90
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
91
-				$this->update($absPath);
92
-			}
93
-		}
94
-	}
95
-
96
-	/**
97
-	 * hook after file was unshared
98
-	 *
99
-	 * @param array $params
100
-	 */
101
-	public function postUnshared($params) {
102
-		if ($this->encryptionManager->isEnabled()) {
103
-			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
104
-				$path = Filesystem::getPath($params['fileSource']);
105
-				list($owner, $ownerPath) = $this->getOwnerPath($path);
106
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
107
-				$this->update($absPath);
108
-			}
109
-		}
110
-	}
111
-
112
-	/**
113
-	 * inform encryption module that a file was restored from the trash bin,
114
-	 * e.g. to update the encryption keys
115
-	 *
116
-	 * @param array $params
117
-	 */
118
-	public function postRestore($params) {
119
-		if ($this->encryptionManager->isEnabled()) {
120
-			$path = Filesystem::normalizePath('/' . $this->uid . '/files/' . $params['filePath']);
121
-			$this->update($path);
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * inform encryption module that a file was renamed,
127
-	 * e.g. to update the encryption keys
128
-	 *
129
-	 * @param array $params
130
-	 */
131
-	public function postRename($params) {
132
-		$source = $params['oldpath'];
133
-		$target = $params['newpath'];
134
-		if(
135
-			$this->encryptionManager->isEnabled() &&
136
-			dirname($source) !== dirname($target)
137
-		) {
138
-				list($owner, $ownerPath) = $this->getOwnerPath($target);
139
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
140
-				$this->update($absPath);
141
-		}
142
-	}
143
-
144
-	/**
145
-	 * get owner and path relative to data/<owner>/files
146
-	 *
147
-	 * @param string $path path to file for current user
148
-	 * @return array ['owner' => $owner, 'path' => $path]
149
-	 * @throw \InvalidArgumentException
150
-	 */
151
-	protected function getOwnerPath($path) {
152
-		$info = Filesystem::getFileInfo($path);
153
-		$owner = Filesystem::getOwner($path);
154
-		$view = new View('/' . $owner . '/files');
155
-		$path = $view->getPath($info->getId());
156
-		if ($path === null) {
157
-			throw new \InvalidArgumentException('No file found for ' . $info->getId());
158
-		}
159
-
160
-		return array($owner, $path);
161
-	}
162
-
163
-	/**
164
-	 * notify encryption module about added/removed users from a file/folder
165
-	 *
166
-	 * @param string $path relative to data/
167
-	 * @throws Exceptions\ModuleDoesNotExistsException
168
-	 */
169
-	public function update($path) {
170
-
171
-		$encryptionModule = $this->encryptionManager->getEncryptionModule();
172
-
173
-		// if the encryption module doesn't encrypt the files on a per-user basis
174
-		// we have nothing to do here.
175
-		if ($encryptionModule->needDetailedAccessList() === false) {
176
-			return;
177
-		}
178
-
179
-		// if a folder was shared, get a list of all (sub-)folders
180
-		if ($this->view->is_dir($path)) {
181
-			$allFiles = $this->util->getAllFiles($path);
182
-		} else {
183
-			$allFiles = array($path);
184
-		}
185
-
186
-
187
-
188
-		foreach ($allFiles as $file) {
189
-			$usersSharing = $this->file->getAccessList($file);
190
-			$encryptionModule->update($file, $this->uid, $usersSharing);
191
-		}
192
-	}
36
+    /** @var \OC\Files\View */
37
+    protected $view;
38
+
39
+    /** @var \OC\Encryption\Util */
40
+    protected $util;
41
+
42
+        /** @var \OC\Files\Mount\Manager */
43
+    protected $mountManager;
44
+
45
+    /** @var \OC\Encryption\Manager */
46
+    protected $encryptionManager;
47
+
48
+    /** @var string */
49
+    protected $uid;
50
+
51
+    /** @var \OC\Encryption\File */
52
+    protected $file;
53
+
54
+    /**
55
+     *
56
+     * @param \OC\Files\View $view
57
+     * @param \OC\Encryption\Util $util
58
+     * @param \OC\Files\Mount\Manager $mountManager
59
+     * @param \OC\Encryption\Manager $encryptionManager
60
+     * @param \OC\Encryption\File $file
61
+     * @param string $uid
62
+     */
63
+    public function __construct(
64
+            View $view,
65
+            Util $util,
66
+            Mount\Manager $mountManager,
67
+            Manager $encryptionManager,
68
+            File $file,
69
+            $uid
70
+        ) {
71
+
72
+        $this->view = $view;
73
+        $this->util = $util;
74
+        $this->mountManager = $mountManager;
75
+        $this->encryptionManager = $encryptionManager;
76
+        $this->file = $file;
77
+        $this->uid = $uid;
78
+    }
79
+
80
+    /**
81
+     * hook after file was shared
82
+     *
83
+     * @param array $params
84
+     */
85
+    public function postShared($params) {
86
+        if ($this->encryptionManager->isEnabled()) {
87
+            if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
88
+                $path = Filesystem::getPath($params['fileSource']);
89
+                list($owner, $ownerPath) = $this->getOwnerPath($path);
90
+                $absPath = '/' . $owner . '/files/' . $ownerPath;
91
+                $this->update($absPath);
92
+            }
93
+        }
94
+    }
95
+
96
+    /**
97
+     * hook after file was unshared
98
+     *
99
+     * @param array $params
100
+     */
101
+    public function postUnshared($params) {
102
+        if ($this->encryptionManager->isEnabled()) {
103
+            if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
104
+                $path = Filesystem::getPath($params['fileSource']);
105
+                list($owner, $ownerPath) = $this->getOwnerPath($path);
106
+                $absPath = '/' . $owner . '/files/' . $ownerPath;
107
+                $this->update($absPath);
108
+            }
109
+        }
110
+    }
111
+
112
+    /**
113
+     * inform encryption module that a file was restored from the trash bin,
114
+     * e.g. to update the encryption keys
115
+     *
116
+     * @param array $params
117
+     */
118
+    public function postRestore($params) {
119
+        if ($this->encryptionManager->isEnabled()) {
120
+            $path = Filesystem::normalizePath('/' . $this->uid . '/files/' . $params['filePath']);
121
+            $this->update($path);
122
+        }
123
+    }
124
+
125
+    /**
126
+     * inform encryption module that a file was renamed,
127
+     * e.g. to update the encryption keys
128
+     *
129
+     * @param array $params
130
+     */
131
+    public function postRename($params) {
132
+        $source = $params['oldpath'];
133
+        $target = $params['newpath'];
134
+        if(
135
+            $this->encryptionManager->isEnabled() &&
136
+            dirname($source) !== dirname($target)
137
+        ) {
138
+                list($owner, $ownerPath) = $this->getOwnerPath($target);
139
+                $absPath = '/' . $owner . '/files/' . $ownerPath;
140
+                $this->update($absPath);
141
+        }
142
+    }
143
+
144
+    /**
145
+     * get owner and path relative to data/<owner>/files
146
+     *
147
+     * @param string $path path to file for current user
148
+     * @return array ['owner' => $owner, 'path' => $path]
149
+     * @throw \InvalidArgumentException
150
+     */
151
+    protected function getOwnerPath($path) {
152
+        $info = Filesystem::getFileInfo($path);
153
+        $owner = Filesystem::getOwner($path);
154
+        $view = new View('/' . $owner . '/files');
155
+        $path = $view->getPath($info->getId());
156
+        if ($path === null) {
157
+            throw new \InvalidArgumentException('No file found for ' . $info->getId());
158
+        }
159
+
160
+        return array($owner, $path);
161
+    }
162
+
163
+    /**
164
+     * notify encryption module about added/removed users from a file/folder
165
+     *
166
+     * @param string $path relative to data/
167
+     * @throws Exceptions\ModuleDoesNotExistsException
168
+     */
169
+    public function update($path) {
170
+
171
+        $encryptionModule = $this->encryptionManager->getEncryptionModule();
172
+
173
+        // if the encryption module doesn't encrypt the files on a per-user basis
174
+        // we have nothing to do here.
175
+        if ($encryptionModule->needDetailedAccessList() === false) {
176
+            return;
177
+        }
178
+
179
+        // if a folder was shared, get a list of all (sub-)folders
180
+        if ($this->view->is_dir($path)) {
181
+            $allFiles = $this->util->getAllFiles($path);
182
+        } else {
183
+            $allFiles = array($path);
184
+        }
185
+
186
+
187
+
188
+        foreach ($allFiles as $file) {
189
+            $usersSharing = $this->file->getAccessList($file);
190
+            $encryptionModule->update($file, $this->uid, $usersSharing);
191
+        }
192
+    }
193 193
 
194 194
 }
Please login to merge, or discard this patch.