Completed
Push — master ( c32a94...a966d5 )
by Joas
17:48
created
lib/private/Activity/LegacyFilter.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -26,83 +26,83 @@
 block discarded – undo
26 26
 
27 27
 class LegacyFilter implements IFilter {
28 28
 
29
-	/** @var IManager */
30
-	protected $manager;
31
-	/** @var string */
32
-	protected $identifier;
33
-	/** @var string */
34
-	protected $name;
35
-	/** @var bool */
36
-	protected $isTopFilter;
29
+    /** @var IManager */
30
+    protected $manager;
31
+    /** @var string */
32
+    protected $identifier;
33
+    /** @var string */
34
+    protected $name;
35
+    /** @var bool */
36
+    protected $isTopFilter;
37 37
 
38
-	/**
39
-	 * LegacySetting constructor.
40
-	 *
41
-	 * @param IManager $manager
42
-	 * @param string $identifier
43
-	 * @param string $name
44
-	 * @param bool $isTopFilter
45
-	 */
46
-	public function __construct(IManager $manager,
47
-								$identifier,
48
-								$name,
49
-								$isTopFilter) {
50
-		$this->manager = $manager;
51
-		$this->identifier = $identifier;
52
-		$this->name = $name;
53
-		$this->isTopFilter = $isTopFilter;
54
-	}
38
+    /**
39
+     * LegacySetting constructor.
40
+     *
41
+     * @param IManager $manager
42
+     * @param string $identifier
43
+     * @param string $name
44
+     * @param bool $isTopFilter
45
+     */
46
+    public function __construct(IManager $manager,
47
+                                $identifier,
48
+                                $name,
49
+                                $isTopFilter) {
50
+        $this->manager = $manager;
51
+        $this->identifier = $identifier;
52
+        $this->name = $name;
53
+        $this->isTopFilter = $isTopFilter;
54
+    }
55 55
 
56
-	/**
57
-	 * @return string Lowercase a-z and underscore only identifier
58
-	 * @since 11.0.0
59
-	 */
60
-	public function getIdentifier() {
61
-		return $this->identifier;
62
-	}
56
+    /**
57
+     * @return string Lowercase a-z and underscore only identifier
58
+     * @since 11.0.0
59
+     */
60
+    public function getIdentifier() {
61
+        return $this->identifier;
62
+    }
63 63
 
64
-	/**
65
-	 * @return string A translated string
66
-	 * @since 11.0.0
67
-	 */
68
-	public function getName() {
69
-		return $this->name;
70
-	}
64
+    /**
65
+     * @return string A translated string
66
+     * @since 11.0.0
67
+     */
68
+    public function getName() {
69
+        return $this->name;
70
+    }
71 71
 
72
-	/**
73
-	 * @return int whether the filter should be rather on the top or bottom of
74
-	 * the admin section. The filters are arranged in ascending order of the
75
-	 * priority values. It is required to return a value between 0 and 100.
76
-	 * @since 11.0.0
77
-	 */
78
-	public function getPriority() {
79
-		return $this->isTopFilter ? 40 : 50;
80
-	}
72
+    /**
73
+     * @return int whether the filter should be rather on the top or bottom of
74
+     * the admin section. The filters are arranged in ascending order of the
75
+     * priority values. It is required to return a value between 0 and 100.
76
+     * @since 11.0.0
77
+     */
78
+    public function getPriority() {
79
+        return $this->isTopFilter ? 40 : 50;
80
+    }
81 81
 
82
-	/**
83
-	 * @return string Full URL to an icon, empty string when none is given
84
-	 * @since 11.0.0
85
-	 */
86
-	public function getIcon() {
87
-		// Old API was CSS class, so we can not use this...
88
-		return '';
89
-	}
82
+    /**
83
+     * @return string Full URL to an icon, empty string when none is given
84
+     * @since 11.0.0
85
+     */
86
+    public function getIcon() {
87
+        // Old API was CSS class, so we can not use this...
88
+        return '';
89
+    }
90 90
 
91
-	/**
92
-	 * @param string[] $types
93
-	 * @return string[] An array of allowed apps from which activities should be displayed
94
-	 * @since 11.0.0
95
-	 */
96
-	public function filterTypes(array $types) {
97
-		return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
98
-	}
91
+    /**
92
+     * @param string[] $types
93
+     * @return string[] An array of allowed apps from which activities should be displayed
94
+     * @since 11.0.0
95
+     */
96
+    public function filterTypes(array $types) {
97
+        return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
98
+    }
99 99
 
100
-	/**
101
-	 * @return string[] An array of allowed apps from which activities should be displayed
102
-	 * @since 11.0.0
103
-	 */
104
-	public function allowedApps() {
105
-		return [];
106
-	}
100
+    /**
101
+     * @return string[] An array of allowed apps from which activities should be displayed
102
+     * @since 11.0.0
103
+     */
104
+    public function allowedApps() {
105
+        return [];
106
+    }
107 107
 }
108 108
 
Please login to merge, or discard this patch.
lib/private/Activity/LegacySetting.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -25,99 +25,99 @@
 block discarded – undo
25 25
 
26 26
 class LegacySetting implements ISetting {
27 27
 
28
-	/** @var string */
29
-	protected $identifier;
30
-	/** @var string */
31
-	protected $name;
32
-	/** @var bool */
33
-	protected $canChangeStream;
34
-	/** @var bool */
35
-	protected $isDefaultEnabledStream;
36
-	/** @var bool */
37
-	protected $canChangeMail;
38
-	/** @var bool */
39
-	protected $isDefaultEnabledMail;
28
+    /** @var string */
29
+    protected $identifier;
30
+    /** @var string */
31
+    protected $name;
32
+    /** @var bool */
33
+    protected $canChangeStream;
34
+    /** @var bool */
35
+    protected $isDefaultEnabledStream;
36
+    /** @var bool */
37
+    protected $canChangeMail;
38
+    /** @var bool */
39
+    protected $isDefaultEnabledMail;
40 40
 
41
-	/**
42
-	 * LegacySetting constructor.
43
-	 *
44
-	 * @param string $identifier
45
-	 * @param string $name
46
-	 * @param bool $canChangeStream
47
-	 * @param bool $isDefaultEnabledStream
48
-	 * @param bool $canChangeMail
49
-	 * @param bool $isDefaultEnabledMail
50
-	 */
51
-	public function __construct($identifier,
52
-								$name,
53
-								$canChangeStream,
54
-								$isDefaultEnabledStream,
55
-								$canChangeMail,
56
-								$isDefaultEnabledMail) {
57
-		$this->identifier = $identifier;
58
-		$this->name = $name;
59
-		$this->canChangeStream = $canChangeStream;
60
-		$this->isDefaultEnabledStream = $isDefaultEnabledStream;
61
-		$this->canChangeMail = $canChangeMail;
62
-		$this->isDefaultEnabledMail = $isDefaultEnabledMail;
63
-	}
41
+    /**
42
+     * LegacySetting constructor.
43
+     *
44
+     * @param string $identifier
45
+     * @param string $name
46
+     * @param bool $canChangeStream
47
+     * @param bool $isDefaultEnabledStream
48
+     * @param bool $canChangeMail
49
+     * @param bool $isDefaultEnabledMail
50
+     */
51
+    public function __construct($identifier,
52
+                                $name,
53
+                                $canChangeStream,
54
+                                $isDefaultEnabledStream,
55
+                                $canChangeMail,
56
+                                $isDefaultEnabledMail) {
57
+        $this->identifier = $identifier;
58
+        $this->name = $name;
59
+        $this->canChangeStream = $canChangeStream;
60
+        $this->isDefaultEnabledStream = $isDefaultEnabledStream;
61
+        $this->canChangeMail = $canChangeMail;
62
+        $this->isDefaultEnabledMail = $isDefaultEnabledMail;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string Lowercase a-z and underscore only identifier
67
-	 * @since 11.0.0
68
-	 */
69
-	public function getIdentifier() {
70
-		return $this->identifier;
71
-	}
65
+    /**
66
+     * @return string Lowercase a-z and underscore only identifier
67
+     * @since 11.0.0
68
+     */
69
+    public function getIdentifier() {
70
+        return $this->identifier;
71
+    }
72 72
 
73
-	/**
74
-	 * @return string A translated string
75
-	 * @since 11.0.0
76
-	 */
77
-	public function getName() {
78
-		return $this->name;
79
-	}
73
+    /**
74
+     * @return string A translated string
75
+     * @since 11.0.0
76
+     */
77
+    public function getName() {
78
+        return $this->name;
79
+    }
80 80
 
81
-	/**
82
-	 * @return int whether the filter should be rather on the top or bottom of
83
-	 * the admin section. The filters are arranged in ascending order of the
84
-	 * priority values. It is required to return a value between 0 and 100.
85
-	 * @since 11.0.0
86
-	 */
87
-	public function getPriority() {
88
-		return 70;
89
-	}
81
+    /**
82
+     * @return int whether the filter should be rather on the top or bottom of
83
+     * the admin section. The filters are arranged in ascending order of the
84
+     * priority values. It is required to return a value between 0 and 100.
85
+     * @since 11.0.0
86
+     */
87
+    public function getPriority() {
88
+        return 70;
89
+    }
90 90
 
91
-	/**
92
-	 * @return bool True when the option can be changed for the stream
93
-	 * @since 11.0.0
94
-	 */
95
-	public function canChangeStream() {
96
-		return $this->canChangeStream;
97
-	}
91
+    /**
92
+     * @return bool True when the option can be changed for the stream
93
+     * @since 11.0.0
94
+     */
95
+    public function canChangeStream() {
96
+        return $this->canChangeStream;
97
+    }
98 98
 
99
-	/**
100
-	 * @return bool True when the option can be changed for the stream
101
-	 * @since 11.0.0
102
-	 */
103
-	public function isDefaultEnabledStream() {
104
-		return $this->isDefaultEnabledStream;
105
-	}
99
+    /**
100
+     * @return bool True when the option can be changed for the stream
101
+     * @since 11.0.0
102
+     */
103
+    public function isDefaultEnabledStream() {
104
+        return $this->isDefaultEnabledStream;
105
+    }
106 106
 
107
-	/**
108
-	 * @return bool True when the option can be changed for the mail
109
-	 * @since 11.0.0
110
-	 */
111
-	public function canChangeMail() {
112
-		return $this->canChangeMail;
113
-	}
107
+    /**
108
+     * @return bool True when the option can be changed for the mail
109
+     * @since 11.0.0
110
+     */
111
+    public function canChangeMail() {
112
+        return $this->canChangeMail;
113
+    }
114 114
 
115
-	/**
116
-	 * @return bool True when the option can be changed for the stream
117
-	 * @since 11.0.0
118
-	 */
119
-	public function isDefaultEnabledMail() {
120
-		return $this->isDefaultEnabledMail;
121
-	}
115
+    /**
116
+     * @return bool True when the option can be changed for the stream
117
+     * @since 11.0.0
118
+     */
119
+    public function isDefaultEnabledMail() {
120
+        return $this->isDefaultEnabledMail;
121
+    }
122 122
 }
123 123
 
Please login to merge, or discard this patch.
lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,52 +29,52 @@
 block discarded – undo
29 29
  * @package OC\Security\CSP
30 30
  */
31 31
 class ContentSecurityPolicyNonceManager {
32
-	/** @var CsrfTokenManager */
33
-	private $csrfTokenManager;
34
-	/** @var IRequest */
35
-	private $request;
36
-	/** @var string */
37
-	private $nonce = '';
32
+    /** @var CsrfTokenManager */
33
+    private $csrfTokenManager;
34
+    /** @var IRequest */
35
+    private $request;
36
+    /** @var string */
37
+    private $nonce = '';
38 38
 
39
-	/**
40
-	 * @param CsrfTokenManager $csrfTokenManager
41
-	 * @param IRequest $request
42
-	 */
43
-	public function __construct(CsrfTokenManager $csrfTokenManager,
44
-								IRequest $request) {
45
-		$this->csrfTokenManager = $csrfTokenManager;
46
-		$this->request = $request;
47
-	}
39
+    /**
40
+     * @param CsrfTokenManager $csrfTokenManager
41
+     * @param IRequest $request
42
+     */
43
+    public function __construct(CsrfTokenManager $csrfTokenManager,
44
+                                IRequest $request) {
45
+        $this->csrfTokenManager = $csrfTokenManager;
46
+        $this->request = $request;
47
+    }
48 48
 
49
-	/**
50
-	 * Returns the current CSP nounce
51
-	 *
52
-	 * @return string
53
-	 */
54
-	public function getNonce() {
55
-		if($this->nonce === '') {
56
-			$this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue());
57
-		}
49
+    /**
50
+     * Returns the current CSP nounce
51
+     *
52
+     * @return string
53
+     */
54
+    public function getNonce() {
55
+        if($this->nonce === '') {
56
+            $this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue());
57
+        }
58 58
 
59
-		return $this->nonce;
60
-	}
59
+        return $this->nonce;
60
+    }
61 61
 
62
-	/**
63
-	 * Check if the browser supports CSP v3
64
-	 *
65
-	 * @return bool
66
-	 */
67
-	public function browserSupportsCspV3() {
68
-		$browserWhitelist = [
69
-			Request::USER_AGENT_CHROME,
70
-			// Firefox 45+
71
-			'/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/(4[5-9]|[5-9][0-9])\.[0-9.]+$/',
72
-		];
62
+    /**
63
+     * Check if the browser supports CSP v3
64
+     *
65
+     * @return bool
66
+     */
67
+    public function browserSupportsCspV3() {
68
+        $browserWhitelist = [
69
+            Request::USER_AGENT_CHROME,
70
+            // Firefox 45+
71
+            '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/(4[5-9]|[5-9][0-9])\.[0-9.]+$/',
72
+        ];
73 73
 
74
-		if($this->request->isUserAgent($browserWhitelist)) {
75
-			return true;
76
-		}
74
+        if($this->request->isUserAgent($browserWhitelist)) {
75
+            return true;
76
+        }
77 77
 
78
-		return false;
79
-	}
78
+        return false;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
lib/private/Security/CSP/ContentSecurityPolicyManager.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,48 +27,48 @@
 block discarded – undo
27 27
 use OCP\Security\IContentSecurityPolicyManager;
28 28
 
29 29
 class ContentSecurityPolicyManager implements IContentSecurityPolicyManager {
30
-	/** @var ContentSecurityPolicy[] */
31
-	private $policies = [];
30
+    /** @var ContentSecurityPolicy[] */
31
+    private $policies = [];
32 32
 
33
-	/** {@inheritdoc} */
34
-	public function addDefaultPolicy(EmptyContentSecurityPolicy $policy) {
35
-		$this->policies[] = $policy;
36
-	}
33
+    /** {@inheritdoc} */
34
+    public function addDefaultPolicy(EmptyContentSecurityPolicy $policy) {
35
+        $this->policies[] = $policy;
36
+    }
37 37
 
38
-	/**
39
-	 * Get the configured default policy. This is not in the public namespace
40
-	 * as it is only supposed to be used by core itself.
41
-	 *
42
-	 * @return ContentSecurityPolicy
43
-	 */
44
-	public function getDefaultPolicy() {
45
-		$defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
46
-		foreach($this->policies as $policy) {
47
-			$defaultPolicy = $this->mergePolicies($defaultPolicy, $policy);
48
-		}
49
-		return $defaultPolicy;
50
-	}
38
+    /**
39
+     * Get the configured default policy. This is not in the public namespace
40
+     * as it is only supposed to be used by core itself.
41
+     *
42
+     * @return ContentSecurityPolicy
43
+     */
44
+    public function getDefaultPolicy() {
45
+        $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
46
+        foreach($this->policies as $policy) {
47
+            $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy);
48
+        }
49
+        return $defaultPolicy;
50
+    }
51 51
 
52
-	/**
53
-	 * Merges the first given policy with the second one
54
-	 *
55
-	 * @param ContentSecurityPolicy $defaultPolicy
56
-	 * @param EmptyContentSecurityPolicy $originalPolicy
57
-	 * @return ContentSecurityPolicy
58
-	 */
59
-	public function mergePolicies(ContentSecurityPolicy $defaultPolicy,
60
-								  EmptyContentSecurityPolicy $originalPolicy) {
61
-		foreach((object)(array)$originalPolicy as $name => $value) {
62
-			$setter = 'set'.ucfirst($name);
63
-			if(is_array($value)) {
64
-				$getter = 'get'.ucfirst($name);
65
-				$currentValues = is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : [];
66
-				$defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value))));
67
-			} elseif (is_bool($value)) {
68
-				$defaultPolicy->$setter($value);
69
-			}
70
-		}
52
+    /**
53
+     * Merges the first given policy with the second one
54
+     *
55
+     * @param ContentSecurityPolicy $defaultPolicy
56
+     * @param EmptyContentSecurityPolicy $originalPolicy
57
+     * @return ContentSecurityPolicy
58
+     */
59
+    public function mergePolicies(ContentSecurityPolicy $defaultPolicy,
60
+                                    EmptyContentSecurityPolicy $originalPolicy) {
61
+        foreach((object)(array)$originalPolicy as $name => $value) {
62
+            $setter = 'set'.ucfirst($name);
63
+            if(is_array($value)) {
64
+                $getter = 'get'.ucfirst($name);
65
+                $currentValues = is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : [];
66
+                $defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value))));
67
+            } elseif (is_bool($value)) {
68
+                $defaultPolicy->$setter($value);
69
+            }
70
+        }
71 71
 
72
-		return $defaultPolicy;
73
-	}
72
+        return $defaultPolicy;
73
+    }
74 74
 }
Please login to merge, or discard this patch.
lib/private/Security/CredentialsManager.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -34,93 +34,93 @@
 block discarded – undo
34 34
  */
35 35
 class CredentialsManager implements ICredentialsManager {
36 36
 
37
-	const DB_TABLE = 'credentials';
37
+    const DB_TABLE = 'credentials';
38 38
 
39
-	/** @var ICrypto */
40
-	protected $crypto;
39
+    /** @var ICrypto */
40
+    protected $crypto;
41 41
 
42
-	/** @var IDBConnection */
43
-	protected $dbConnection;
42
+    /** @var IDBConnection */
43
+    protected $dbConnection;
44 44
 
45
-	/**
46
-	 * @param ICrypto $crypto
47
-	 * @param IDBConnection $dbConnection
48
-	 */
49
-	public function __construct(ICrypto $crypto, IDBConnection $dbConnection) {
50
-		$this->crypto = $crypto;
51
-		$this->dbConnection = $dbConnection;
52
-	}
45
+    /**
46
+     * @param ICrypto $crypto
47
+     * @param IDBConnection $dbConnection
48
+     */
49
+    public function __construct(ICrypto $crypto, IDBConnection $dbConnection) {
50
+        $this->crypto = $crypto;
51
+        $this->dbConnection = $dbConnection;
52
+    }
53 53
 
54
-	/**
55
-	 * Store a set of credentials
56
-	 *
57
-	 * @param string|null $userId Null for system-wide credentials
58
-	 * @param string $identifier
59
-	 * @param mixed $credentials
60
-	 */
61
-	public function store($userId, $identifier, $credentials) {
62
-		$value = $this->crypto->encrypt(json_encode($credentials));
54
+    /**
55
+     * Store a set of credentials
56
+     *
57
+     * @param string|null $userId Null for system-wide credentials
58
+     * @param string $identifier
59
+     * @param mixed $credentials
60
+     */
61
+    public function store($userId, $identifier, $credentials) {
62
+        $value = $this->crypto->encrypt(json_encode($credentials));
63 63
 
64
-		$this->dbConnection->setValues(self::DB_TABLE, [
65
-			'user' => $userId,
66
-			'identifier' => $identifier,
67
-		], [
68
-			'credentials' => $value,
69
-		]);
70
-	}
64
+        $this->dbConnection->setValues(self::DB_TABLE, [
65
+            'user' => $userId,
66
+            'identifier' => $identifier,
67
+        ], [
68
+            'credentials' => $value,
69
+        ]);
70
+    }
71 71
 
72
-	/**
73
-	 * Retrieve a set of credentials
74
-	 *
75
-	 * @param string|null $userId Null for system-wide credentials
76
-	 * @param string $identifier
77
-	 * @return mixed
78
-	 */
79
-	public function retrieve($userId, $identifier) {
80
-		$qb = $this->dbConnection->getQueryBuilder();
81
-		$qb->select('credentials')
82
-			->from(self::DB_TABLE)
83
-			->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
84
-			->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
85
-		;
86
-		$result = $qb->execute()->fetch();
72
+    /**
73
+     * Retrieve a set of credentials
74
+     *
75
+     * @param string|null $userId Null for system-wide credentials
76
+     * @param string $identifier
77
+     * @return mixed
78
+     */
79
+    public function retrieve($userId, $identifier) {
80
+        $qb = $this->dbConnection->getQueryBuilder();
81
+        $qb->select('credentials')
82
+            ->from(self::DB_TABLE)
83
+            ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
84
+            ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
85
+        ;
86
+        $result = $qb->execute()->fetch();
87 87
 
88
-		if (!$result) {
89
-			return null;
90
-		}
91
-		$value = $result['credentials'];
88
+        if (!$result) {
89
+            return null;
90
+        }
91
+        $value = $result['credentials'];
92 92
 
93
-		return json_decode($this->crypto->decrypt($value), true);
94
-	}
93
+        return json_decode($this->crypto->decrypt($value), true);
94
+    }
95 95
 
96
-	/**
97
-	 * Delete a set of credentials
98
-	 *
99
-	 * @param string|null $userId Null for system-wide credentials
100
-	 * @param string $identifier
101
-	 * @return int rows removed
102
-	 */
103
-	public function delete($userId, $identifier) {
104
-		$qb = $this->dbConnection->getQueryBuilder();
105
-		$qb->delete(self::DB_TABLE)
106
-			->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
107
-			->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
108
-		;
109
-		return $qb->execute();
110
-	}
96
+    /**
97
+     * Delete a set of credentials
98
+     *
99
+     * @param string|null $userId Null for system-wide credentials
100
+     * @param string $identifier
101
+     * @return int rows removed
102
+     */
103
+    public function delete($userId, $identifier) {
104
+        $qb = $this->dbConnection->getQueryBuilder();
105
+        $qb->delete(self::DB_TABLE)
106
+            ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
107
+            ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
108
+        ;
109
+        return $qb->execute();
110
+    }
111 111
 
112
-	/**
113
-	 * Erase all credentials stored for a user
114
-	 *
115
-	 * @param string $userId
116
-	 * @return int rows removed
117
-	 */
118
-	public function erase($userId) {
119
-		$qb = $this->dbConnection->getQueryBuilder();
120
-		$qb->delete(self::DB_TABLE)
121
-			->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
122
-		;
123
-		return $qb->execute();
124
-	}
112
+    /**
113
+     * Erase all credentials stored for a user
114
+     *
115
+     * @param string $userId
116
+     * @return int rows removed
117
+     */
118
+    public function erase($userId) {
119
+        $qb = $this->dbConnection->getQueryBuilder();
120
+        $qb->delete(self::DB_TABLE)
121
+            ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
122
+        ;
123
+        return $qb->execute();
124
+    }
125 125
 
126 126
 }
Please login to merge, or discard this patch.
lib/private/Security/CSRF/TokenStorage/SessionStorage.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -30,59 +30,59 @@
 block discarded – undo
30 30
  * @package OC\Security\CSRF\TokenStorage
31 31
  */
32 32
 class SessionStorage {
33
-	/** @var ISession */
34
-	private $session;
33
+    /** @var ISession */
34
+    private $session;
35 35
 
36
-	/**
37
-	 * @param ISession $session
38
-	 */
39
-	public function __construct(ISession $session) {
40
-		$this->session = $session;
41
-	}
36
+    /**
37
+     * @param ISession $session
38
+     */
39
+    public function __construct(ISession $session) {
40
+        $this->session = $session;
41
+    }
42 42
 
43
-	/**
44
-	 * @param ISession $session
45
-	 */
46
-	public function setSession(ISession $session) {
47
-		$this->session = $session;
48
-	}
43
+    /**
44
+     * @param ISession $session
45
+     */
46
+    public function setSession(ISession $session) {
47
+        $this->session = $session;
48
+    }
49 49
 
50
-	/**
51
-	 * Returns the current token or throws an exception if none is found.
52
-	 *
53
-	 * @return string
54
-	 * @throws \Exception
55
-	 */
56
-	public function getToken() {
57
-		$token = $this->session->get('requesttoken');
58
-		if(empty($token)) {
59
-			throw new \Exception('Session does not contain a requesttoken');
60
-		}
50
+    /**
51
+     * Returns the current token or throws an exception if none is found.
52
+     *
53
+     * @return string
54
+     * @throws \Exception
55
+     */
56
+    public function getToken() {
57
+        $token = $this->session->get('requesttoken');
58
+        if(empty($token)) {
59
+            throw new \Exception('Session does not contain a requesttoken');
60
+        }
61 61
 
62
-		return $token;
63
-	}
62
+        return $token;
63
+    }
64 64
 
65
-	/**
66
-	 * Set the valid current token to $value.
67
-	 *
68
-	 * @param string $value
69
-	 */
70
-	public function setToken($value) {
71
-		$this->session->set('requesttoken', $value);
72
-	}
65
+    /**
66
+     * Set the valid current token to $value.
67
+     *
68
+     * @param string $value
69
+     */
70
+    public function setToken($value) {
71
+        $this->session->set('requesttoken', $value);
72
+    }
73 73
 
74
-	/**
75
-	 * Removes the current token.
76
-	 */
77
-	public function removeToken() {
78
-		$this->session->remove('requesttoken');
79
-	}
80
-	/**
81
-	 * Whether the storage has a storage.
82
-	 *
83
-	 * @return bool
84
-	 */
85
-	public function hasToken() {
86
-		return $this->session->exists('requesttoken');
87
-	}
74
+    /**
75
+     * Removes the current token.
76
+     */
77
+    public function removeToken() {
78
+        $this->session->remove('requesttoken');
79
+    }
80
+    /**
81
+     * Whether the storage has a storage.
82
+     *
83
+     * @return bool
84
+     */
85
+    public function hasToken() {
86
+        return $this->session->exists('requesttoken');
87
+    }
88 88
 }
Please login to merge, or discard this patch.
lib/private/Security/CSRF/CsrfTokenManager.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -30,78 +30,78 @@
 block discarded – undo
30 30
  * @package OC\Security\CSRF
31 31
  */
32 32
 class CsrfTokenManager {
33
-	/** @var CsrfTokenGenerator */
34
-	private $tokenGenerator;
35
-	/** @var SessionStorage */
36
-	private $sessionStorage;
37
-	/** @var CsrfToken|null */
38
-	private $csrfToken = null;
33
+    /** @var CsrfTokenGenerator */
34
+    private $tokenGenerator;
35
+    /** @var SessionStorage */
36
+    private $sessionStorage;
37
+    /** @var CsrfToken|null */
38
+    private $csrfToken = null;
39 39
 
40
-	/**
41
-	 * @param CsrfTokenGenerator $tokenGenerator
42
-	 * @param SessionStorage $storageInterface
43
-	 */
44
-	public function __construct(CsrfTokenGenerator $tokenGenerator,
45
-								SessionStorage $storageInterface) {
46
-		$this->tokenGenerator = $tokenGenerator;
47
-		$this->sessionStorage = $storageInterface;
48
-	}
40
+    /**
41
+     * @param CsrfTokenGenerator $tokenGenerator
42
+     * @param SessionStorage $storageInterface
43
+     */
44
+    public function __construct(CsrfTokenGenerator $tokenGenerator,
45
+                                SessionStorage $storageInterface) {
46
+        $this->tokenGenerator = $tokenGenerator;
47
+        $this->sessionStorage = $storageInterface;
48
+    }
49 49
 
50
-	/**
51
-	 * Returns the current CSRF token, if none set it will create a new one.
52
-	 *
53
-	 * @return CsrfToken
54
-	 */
55
-	public function getToken() {
56
-		if(!is_null($this->csrfToken)) {
57
-			return $this->csrfToken;
58
-		}
50
+    /**
51
+     * Returns the current CSRF token, if none set it will create a new one.
52
+     *
53
+     * @return CsrfToken
54
+     */
55
+    public function getToken() {
56
+        if(!is_null($this->csrfToken)) {
57
+            return $this->csrfToken;
58
+        }
59 59
 
60
-		if($this->sessionStorage->hasToken()) {
61
-			$value = $this->sessionStorage->getToken();
62
-		} else {
63
-			$value = $this->tokenGenerator->generateToken();
64
-			$this->sessionStorage->setToken($value);
65
-		}
60
+        if($this->sessionStorage->hasToken()) {
61
+            $value = $this->sessionStorage->getToken();
62
+        } else {
63
+            $value = $this->tokenGenerator->generateToken();
64
+            $this->sessionStorage->setToken($value);
65
+        }
66 66
 
67
-		$this->csrfToken = new CsrfToken($value);
68
-		return $this->csrfToken;
69
-	}
67
+        $this->csrfToken = new CsrfToken($value);
68
+        return $this->csrfToken;
69
+    }
70 70
 
71
-	/**
72
-	 * Invalidates any current token and sets a new one.
73
-	 *
74
-	 * @return CsrfToken
75
-	 */
76
-	public function refreshToken() {
77
-		$value = $this->tokenGenerator->generateToken();
78
-		$this->sessionStorage->setToken($value);
79
-		$this->csrfToken = new CsrfToken($value);
80
-		return $this->csrfToken;
81
-	}
71
+    /**
72
+     * Invalidates any current token and sets a new one.
73
+     *
74
+     * @return CsrfToken
75
+     */
76
+    public function refreshToken() {
77
+        $value = $this->tokenGenerator->generateToken();
78
+        $this->sessionStorage->setToken($value);
79
+        $this->csrfToken = new CsrfToken($value);
80
+        return $this->csrfToken;
81
+    }
82 82
 
83
-	/**
84
-	 * Remove the current token from the storage.
85
-	 */
86
-	public function removeToken() {
87
-		$this->csrfToken = null;
88
-		$this->sessionStorage->removeToken();
89
-	}
83
+    /**
84
+     * Remove the current token from the storage.
85
+     */
86
+    public function removeToken() {
87
+        $this->csrfToken = null;
88
+        $this->sessionStorage->removeToken();
89
+    }
90 90
 
91
-	/**
92
-	 * Verifies whether the provided token is valid.
93
-	 *
94
-	 * @param CsrfToken $token
95
-	 * @return bool
96
-	 */
97
-	public function isTokenValid(CsrfToken $token) {
98
-		if(!$this->sessionStorage->hasToken()) {
99
-			return false;
100
-		}
91
+    /**
92
+     * Verifies whether the provided token is valid.
93
+     *
94
+     * @param CsrfToken $token
95
+     * @return bool
96
+     */
97
+    public function isTokenValid(CsrfToken $token) {
98
+        if(!$this->sessionStorage->hasToken()) {
99
+            return false;
100
+        }
101 101
 
102
-		return hash_equals(
103
-			$this->sessionStorage->getToken(),
104
-			$token->getDecryptedValue()
105
-		);
106
-	}
102
+        return hash_equals(
103
+            $this->sessionStorage->getToken(),
104
+            $token->getDecryptedValue()
105
+        );
106
+    }
107 107
 }
Please login to merge, or discard this patch.
lib/private/Security/CSRF/CsrfTokenGenerator.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@
 block discarded – undo
31 31
  * @package OC\Security\CSRF
32 32
  */
33 33
 class CsrfTokenGenerator {
34
-	/** @var ISecureRandom  */
35
-	private $random;
34
+    /** @var ISecureRandom  */
35
+    private $random;
36 36
 
37
-	/**
38
-	 * @param ISecureRandom $random
39
-	 */
40
-	public function __construct(ISecureRandom $random) {
41
-		$this->random = $random;
42
-	}
37
+    /**
38
+     * @param ISecureRandom $random
39
+     */
40
+    public function __construct(ISecureRandom $random) {
41
+        $this->random = $random;
42
+    }
43 43
 
44
-	/**
45
-	 * Generate a new CSRF token.
46
-	 *
47
-	 * @param int $length Length of the token in characters.
48
-	 * @return string
49
-	 */
50
-	public function generateToken($length = 32) {
51
-		return $this->random->generate($length);
52
-	}
44
+    /**
45
+     * Generate a new CSRF token.
46
+     *
47
+     * @param int $length Length of the token in characters.
48
+     * @return string
49
+     */
50
+    public function generateToken($length = 32) {
51
+        return $this->random->generate($length);
52
+    }
53 53
 }
Please login to merge, or discard this patch.
lib/private/Security/Certificate.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -27,104 +27,104 @@
 block discarded – undo
27 27
 use OCP\ICertificate;
28 28
 
29 29
 class Certificate implements ICertificate {
30
-	protected $name;
31
-
32
-	protected $commonName;
33
-
34
-	protected $organization;
35
-
36
-	protected $serial;
37
-
38
-	protected $issueDate;
39
-
40
-	protected $expireDate;
41
-
42
-	protected $issuerName;
43
-
44
-	protected $issuerOrganization;
45
-
46
-	/**
47
-	 * @param string $data base64 encoded certificate
48
-	 * @param string $name
49
-	 * @throws \Exception If the certificate could not get parsed
50
-	 */
51
-	public function __construct($data, $name) {
52
-		$this->name = $name;
53
-		$gmt = new \DateTimeZone('GMT');
54
-
55
-		// If string starts with "file://" ignore the certificate
56
-		$query = 'file://';
57
-		if(strtolower(substr($data, 0, strlen($query))) === $query) {
58
-			throw new \Exception('Certificate could not get parsed.');
59
-		}
60
-
61
-		$info = openssl_x509_parse($data);
62
-		if(!is_array($info)) {
63
-			throw new \Exception('Certificate could not get parsed.');
64
-		}
65
-
66
-		$this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null;
67
-		$this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null;
68
-		$this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt);
69
-		$this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt);
70
-		$this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null;
71
-		$this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null;
72
-	}
73
-
74
-	/**
75
-	 * @return string
76
-	 */
77
-	public function getName() {
78
-		return $this->name;
79
-	}
80
-
81
-	/**
82
-	 * @return string|null
83
-	 */
84
-	public function getCommonName() {
85
-		return $this->commonName;
86
-	}
87
-
88
-	/**
89
-	 * @return string
90
-	 */
91
-	public function getOrganization() {
92
-		return $this->organization;
93
-	}
94
-
95
-	/**
96
-	 * @return \DateTime
97
-	 */
98
-	public function getIssueDate() {
99
-		return $this->issueDate;
100
-	}
101
-
102
-	/**
103
-	 * @return \DateTime
104
-	 */
105
-	public function getExpireDate() {
106
-		return $this->expireDate;
107
-	}
108
-
109
-	/**
110
-	 * @return bool
111
-	 */
112
-	public function isExpired() {
113
-		$now = new \DateTime();
114
-		return $this->issueDate > $now or $now > $this->expireDate;
115
-	}
116
-
117
-	/**
118
-	 * @return string|null
119
-	 */
120
-	public function getIssuerName() {
121
-		return $this->issuerName;
122
-	}
123
-
124
-	/**
125
-	 * @return string|null
126
-	 */
127
-	public function getIssuerOrganization() {
128
-		return $this->issuerOrganization;
129
-	}
30
+    protected $name;
31
+
32
+    protected $commonName;
33
+
34
+    protected $organization;
35
+
36
+    protected $serial;
37
+
38
+    protected $issueDate;
39
+
40
+    protected $expireDate;
41
+
42
+    protected $issuerName;
43
+
44
+    protected $issuerOrganization;
45
+
46
+    /**
47
+     * @param string $data base64 encoded certificate
48
+     * @param string $name
49
+     * @throws \Exception If the certificate could not get parsed
50
+     */
51
+    public function __construct($data, $name) {
52
+        $this->name = $name;
53
+        $gmt = new \DateTimeZone('GMT');
54
+
55
+        // If string starts with "file://" ignore the certificate
56
+        $query = 'file://';
57
+        if(strtolower(substr($data, 0, strlen($query))) === $query) {
58
+            throw new \Exception('Certificate could not get parsed.');
59
+        }
60
+
61
+        $info = openssl_x509_parse($data);
62
+        if(!is_array($info)) {
63
+            throw new \Exception('Certificate could not get parsed.');
64
+        }
65
+
66
+        $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null;
67
+        $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null;
68
+        $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt);
69
+        $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt);
70
+        $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null;
71
+        $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null;
72
+    }
73
+
74
+    /**
75
+     * @return string
76
+     */
77
+    public function getName() {
78
+        return $this->name;
79
+    }
80
+
81
+    /**
82
+     * @return string|null
83
+     */
84
+    public function getCommonName() {
85
+        return $this->commonName;
86
+    }
87
+
88
+    /**
89
+     * @return string
90
+     */
91
+    public function getOrganization() {
92
+        return $this->organization;
93
+    }
94
+
95
+    /**
96
+     * @return \DateTime
97
+     */
98
+    public function getIssueDate() {
99
+        return $this->issueDate;
100
+    }
101
+
102
+    /**
103
+     * @return \DateTime
104
+     */
105
+    public function getExpireDate() {
106
+        return $this->expireDate;
107
+    }
108
+
109
+    /**
110
+     * @return bool
111
+     */
112
+    public function isExpired() {
113
+        $now = new \DateTime();
114
+        return $this->issueDate > $now or $now > $this->expireDate;
115
+    }
116
+
117
+    /**
118
+     * @return string|null
119
+     */
120
+    public function getIssuerName() {
121
+        return $this->issuerName;
122
+    }
123
+
124
+    /**
125
+     * @return string|null
126
+     */
127
+    public function getIssuerOrganization() {
128
+        return $this->issuerOrganization;
129
+    }
130 130
 }
Please login to merge, or discard this patch.