Completed
Push — master ( 8f38ad...4035d6 )
by Joas
13:12 queued 06:02
created

LockdownManager::setToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (c) 2016, Robin Appelman <[email protected]>
5
 *
6
 * This code is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License, version 3,
8
 * as published by the Free Software Foundation.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License, version 3,
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
17
 *
18
 */
19
20
namespace OC\Lockdown;
21
22
use OC\Authentication\Token\IToken;
23
use OCP\Lockdown\ILockdownManager;
24
25
class LockdownManager implements ILockdownManager {
26
	private $enabled = false;
27
28
	/** @var array|null */
29
	private $scope;
30
31
	public function enable() {
32
		$this->enabled = true;
33
	}
34
35
	public function setToken(IToken $token) {
36
		$this->scope = $token->getScopeAsArray();
37
		$this->enable();
38
	}
39
40
	public function canAccessFilesystem() {
41
		if (!$this->enabled) {
42
			return true;
43
		}
44
		return !$this->scope || $this->scope['filesystem'];
45
	}
46
}
47