Passed
Push — master ( b5e9f7...9ff7f5 )
by Georg
10:36 queued 10s
created
lib/public/Encryption/Keys/IStorage.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -33,151 +33,151 @@
 block discarded – undo
33 33
  */
34 34
 interface IStorage {
35 35
 
36
-	/**
37
-	 * get user specific key
38
-	 *
39
-	 * @param string $uid ID if the user for whom we want the key
40
-	 * @param string $keyId id of the key
41
-	 * @param string $encryptionModuleId
42
-	 *
43
-	 * @return mixed key
44
-	 * @since 8.1.0
45
-	 */
46
-	public function getUserKey($uid, $keyId, $encryptionModuleId);
36
+    /**
37
+     * get user specific key
38
+     *
39
+     * @param string $uid ID if the user for whom we want the key
40
+     * @param string $keyId id of the key
41
+     * @param string $encryptionModuleId
42
+     *
43
+     * @return mixed key
44
+     * @since 8.1.0
45
+     */
46
+    public function getUserKey($uid, $keyId, $encryptionModuleId);
47 47
 
48
-	/**
49
-	 * get file specific key
50
-	 *
51
-	 * @param string $path path to file
52
-	 * @param string $keyId id of the key
53
-	 * @param string $encryptionModuleId
54
-	 *
55
-	 * @return mixed key
56
-	 * @since 8.1.0
57
-	 */
58
-	public function getFileKey($path, $keyId, $encryptionModuleId);
48
+    /**
49
+     * get file specific key
50
+     *
51
+     * @param string $path path to file
52
+     * @param string $keyId id of the key
53
+     * @param string $encryptionModuleId
54
+     *
55
+     * @return mixed key
56
+     * @since 8.1.0
57
+     */
58
+    public function getFileKey($path, $keyId, $encryptionModuleId);
59 59
 
60
-	/**
61
-	 * get system-wide encryption keys not related to a specific user,
62
-	 * e.g something like a key for public link shares
63
-	 *
64
-	 * @param string $keyId id of the key
65
-	 * @param string $encryptionModuleId
66
-	 *
67
-	 * @return mixed key
68
-	 * @since 8.1.0
69
-	 */
70
-	public function getSystemUserKey($keyId, $encryptionModuleId);
60
+    /**
61
+     * get system-wide encryption keys not related to a specific user,
62
+     * e.g something like a key for public link shares
63
+     *
64
+     * @param string $keyId id of the key
65
+     * @param string $encryptionModuleId
66
+     *
67
+     * @return mixed key
68
+     * @since 8.1.0
69
+     */
70
+    public function getSystemUserKey($keyId, $encryptionModuleId);
71 71
 
72
-	/**
73
-	 * set user specific key
74
-	 *
75
-	 * @param string $uid ID if the user for whom we want the key
76
-	 * @param string $keyId id of the key
77
-	 * @param mixed $key
78
-	 * @param string $encryptionModuleId
79
-	 * @since 8.1.0
80
-	 */
81
-	public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
72
+    /**
73
+     * set user specific key
74
+     *
75
+     * @param string $uid ID if the user for whom we want the key
76
+     * @param string $keyId id of the key
77
+     * @param mixed $key
78
+     * @param string $encryptionModuleId
79
+     * @since 8.1.0
80
+     */
81
+    public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
82 82
 
83
-	/**
84
-	 * set file specific key
85
-	 *
86
-	 * @param string $path path to file
87
-	 * @param string $keyId id of the key
88
-	 * @param mixed $key
89
-	 * @param string $encryptionModuleId
90
-	 * @since 8.1.0
91
-	 */
92
-	public function setFileKey($path, $keyId, $key, $encryptionModuleId);
83
+    /**
84
+     * set file specific key
85
+     *
86
+     * @param string $path path to file
87
+     * @param string $keyId id of the key
88
+     * @param mixed $key
89
+     * @param string $encryptionModuleId
90
+     * @since 8.1.0
91
+     */
92
+    public function setFileKey($path, $keyId, $key, $encryptionModuleId);
93 93
 
94
-	/**
95
-	 * set system-wide encryption keys not related to a specific user,
96
-	 * e.g something like a key for public link shares
97
-	 *
98
-	 * @param string $keyId id of the key
99
-	 * @param mixed $key
100
-	 * @param string $encryptionModuleId
101
-	 *
102
-	 * @return mixed key
103
-	 * @since 8.1.0
104
-	 */
105
-	public function setSystemUserKey($keyId, $key, $encryptionModuleId);
94
+    /**
95
+     * set system-wide encryption keys not related to a specific user,
96
+     * e.g something like a key for public link shares
97
+     *
98
+     * @param string $keyId id of the key
99
+     * @param mixed $key
100
+     * @param string $encryptionModuleId
101
+     *
102
+     * @return mixed key
103
+     * @since 8.1.0
104
+     */
105
+    public function setSystemUserKey($keyId, $key, $encryptionModuleId);
106 106
 
107
-	/**
108
-	 * delete user specific key
109
-	 *
110
-	 * @param string $uid ID if the user for whom we want to delete the key
111
-	 * @param string $keyId id of the key
112
-	 * @param string $encryptionModuleId
113
-	 *
114
-	 * @return boolean False when the key could not be deleted
115
-	 * @since 8.1.0
116
-	 */
117
-	public function deleteUserKey($uid, $keyId, $encryptionModuleId);
107
+    /**
108
+     * delete user specific key
109
+     *
110
+     * @param string $uid ID if the user for whom we want to delete the key
111
+     * @param string $keyId id of the key
112
+     * @param string $encryptionModuleId
113
+     *
114
+     * @return boolean False when the key could not be deleted
115
+     * @since 8.1.0
116
+     */
117
+    public function deleteUserKey($uid, $keyId, $encryptionModuleId);
118 118
 
119
-	/**
120
-	 * delete file specific key
121
-	 *
122
-	 * @param string $path path to file
123
-	 * @param string $keyId id of the key
124
-	 * @param string $encryptionModuleId
125
-	 *
126
-	 * @return boolean False when the key could not be deleted
127
-	 * @since 8.1.0
128
-	 */
129
-	public function deleteFileKey($path, $keyId, $encryptionModuleId);
119
+    /**
120
+     * delete file specific key
121
+     *
122
+     * @param string $path path to file
123
+     * @param string $keyId id of the key
124
+     * @param string $encryptionModuleId
125
+     *
126
+     * @return boolean False when the key could not be deleted
127
+     * @since 8.1.0
128
+     */
129
+    public function deleteFileKey($path, $keyId, $encryptionModuleId);
130 130
 
131
-	/**
132
-	 * delete all file keys for a given file
133
-	 *
134
-	 * @param string $path to the file
135
-	 *
136
-	 * @return boolean False when the keys could not be deleted
137
-	 * @since 8.1.0
138
-	 */
139
-	public function deleteAllFileKeys($path);
131
+    /**
132
+     * delete all file keys for a given file
133
+     *
134
+     * @param string $path to the file
135
+     *
136
+     * @return boolean False when the keys could not be deleted
137
+     * @since 8.1.0
138
+     */
139
+    public function deleteAllFileKeys($path);
140 140
 
141
-	/**
142
-	 * delete system-wide encryption keys not related to a specific user,
143
-	 * e.g something like a key for public link shares
144
-	 *
145
-	 * @param string $keyId id of the key
146
-	 * @param string $encryptionModuleId
147
-	 *
148
-	 * @return boolean False when the key could not be deleted
149
-	 * @since 8.1.0
150
-	 */
151
-	public function deleteSystemUserKey($keyId, $encryptionModuleId);
141
+    /**
142
+     * delete system-wide encryption keys not related to a specific user,
143
+     * e.g something like a key for public link shares
144
+     *
145
+     * @param string $keyId id of the key
146
+     * @param string $encryptionModuleId
147
+     *
148
+     * @return boolean False when the key could not be deleted
149
+     * @since 8.1.0
150
+     */
151
+    public function deleteSystemUserKey($keyId, $encryptionModuleId);
152 152
 
153
-	/**
154
-	 * copy keys if a file was renamed
155
-	 *
156
-	 * @param string $source
157
-	 * @param string $target
158
-	 * @return boolean
159
-	 * @since 8.1.0
160
-	 */
161
-	public function renameKeys($source, $target);
153
+    /**
154
+     * copy keys if a file was renamed
155
+     *
156
+     * @param string $source
157
+     * @param string $target
158
+     * @return boolean
159
+     * @since 8.1.0
160
+     */
161
+    public function renameKeys($source, $target);
162 162
 
163
-	/**
164
-	 * move keys if a file was renamed
165
-	 *
166
-	 * @param string $source
167
-	 * @param string $target
168
-	 * @return boolean
169
-	 * @since 8.1.0
170
-	 */
171
-	public function copyKeys($source, $target);
163
+    /**
164
+     * move keys if a file was renamed
165
+     *
166
+     * @param string $source
167
+     * @param string $target
168
+     * @return boolean
169
+     * @since 8.1.0
170
+     */
171
+    public function copyKeys($source, $target);
172 172
 
173
-	/**
174
-	 * backup keys of a given encryption module
175
-	 *
176
-	 * @param string $encryptionModuleId
177
-	 * @param string $purpose
178
-	 * @param string $uid
179
-	 * @return bool
180
-	 * @since 12.0.0
181
-	 */
182
-	public function backupUserKeys($encryptionModuleId, $purpose, $uid);
173
+    /**
174
+     * backup keys of a given encryption module
175
+     *
176
+     * @param string $encryptionModuleId
177
+     * @param string $purpose
178
+     * @param string $uid
179
+     * @return bool
180
+     * @since 12.0.0
181
+     */
182
+    public function backupUserKeys($encryptionModuleId, $purpose, $uid);
183 183
 }
Please login to merge, or discard this patch.
lib/private/Authentication/LoginCredentials/Credentials.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,45 +28,45 @@
 block discarded – undo
28 28
 
29 29
 class Credentials implements ICredentials {
30 30
 
31
-	/** @var string */
32
-	private $uid;
31
+    /** @var string */
32
+    private $uid;
33 33
 
34
-	/** @var string */
35
-	private $loginName;
34
+    /** @var string */
35
+    private $loginName;
36 36
 
37
-	/** @var string */
38
-	private $password;
37
+    /** @var string */
38
+    private $password;
39 39
 
40
-	/**
41
-	 * @param string $uid
42
-	 * @param string $loginName
43
-	 * @param string $password
44
-	 */
45
-	public function __construct($uid, $loginName, $password) {
46
-		$this->uid = $uid;
47
-		$this->loginName = $loginName;
48
-		$this->password = $password;
49
-	}
40
+    /**
41
+     * @param string $uid
42
+     * @param string $loginName
43
+     * @param string $password
44
+     */
45
+    public function __construct($uid, $loginName, $password) {
46
+        $this->uid = $uid;
47
+        $this->loginName = $loginName;
48
+        $this->password = $password;
49
+    }
50 50
 
51
-	/**
52
-	 * @return string
53
-	 */
54
-	public function getUID() {
55
-		return $this->uid;
56
-	}
51
+    /**
52
+     * @return string
53
+     */
54
+    public function getUID() {
55
+        return $this->uid;
56
+    }
57 57
 
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getLoginName() {
62
-		return $this->loginName;
63
-	}
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getLoginName() {
62
+        return $this->loginName;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	public function getPassword() {
69
-		return $this->password;
70
-	}
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getPassword() {
69
+        return $this->password;
70
+    }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/DefaultTokenMapper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
 		$data = $result->fetchAll();
130 130
 		$result->closeCursor();
131 131
 
132
-		$entities = array_map(function ($row) {
132
+		$entities = array_map(function($row) {
133 133
 			return DefaultToken::fromRow($row);
134 134
 		}, $data);
135 135
 
Please login to merge, or discard this patch.
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -36,135 +36,135 @@
 block discarded – undo
36 36
 use OCP\IDBConnection;
37 37
 
38 38
 class DefaultTokenMapper extends QBMapper {
39
-	public function __construct(IDBConnection $db) {
40
-		parent::__construct($db, 'authtoken');
41
-	}
42
-
43
-	/**
44
-	 * Invalidate (delete) a given token
45
-	 *
46
-	 * @param string $token
47
-	 */
48
-	public function invalidate(string $token) {
49
-		/* @var $qb IQueryBuilder */
50
-		$qb = $this->db->getQueryBuilder();
51
-		$qb->delete('authtoken')
52
-			->where($qb->expr()->eq('token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR)))
53
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
54
-			->execute();
55
-	}
56
-
57
-	/**
58
-	 * @param int $olderThan
59
-	 * @param int $remember
60
-	 */
61
-	public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) {
62
-		/* @var $qb IQueryBuilder */
63
-		$qb = $this->db->getQueryBuilder();
64
-		$qb->delete('authtoken')
65
-			->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT)))
66
-			->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT)))
67
-			->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT)))
68
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
69
-			->execute();
70
-	}
71
-
72
-	/**
73
-	 * Get the user UID for the given token
74
-	 *
75
-	 * @param string $token
76
-	 * @throws DoesNotExistException
77
-	 * @return DefaultToken
78
-	 */
79
-	public function getToken(string $token): DefaultToken {
80
-		/* @var $qb IQueryBuilder */
81
-		$qb = $this->db->getQueryBuilder();
82
-		$result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
83
-			->from('authtoken')
84
-			->where($qb->expr()->eq('token', $qb->createNamedParameter($token)))
85
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
86
-			->execute();
87
-
88
-		$data = $result->fetch();
89
-		$result->closeCursor();
90
-		if ($data === false) {
91
-			throw new DoesNotExistException('token does not exist');
92
-		}
93
-		return DefaultToken::fromRow($data);
94
-	}
95
-
96
-	/**
97
-	 * Get the token for $id
98
-	 *
99
-	 * @param int $id
100
-	 * @throws DoesNotExistException
101
-	 * @return DefaultToken
102
-	 */
103
-	public function getTokenById(int $id): DefaultToken {
104
-		/* @var $qb IQueryBuilder */
105
-		$qb = $this->db->getQueryBuilder();
106
-		$result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
107
-			->from('authtoken')
108
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
109
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
110
-			->execute();
111
-
112
-		$data = $result->fetch();
113
-		$result->closeCursor();
114
-		if ($data === false) {
115
-			throw new DoesNotExistException('token does not exist');
116
-		}
117
-		return DefaultToken::fromRow($data);
118
-	}
119
-
120
-	/**
121
-	 * Get all tokens of a user
122
-	 *
123
-	 * The provider may limit the number of result rows in case of an abuse
124
-	 * where a high number of (session) tokens is generated
125
-	 *
126
-	 * @param string $uid
127
-	 * @return DefaultToken[]
128
-	 */
129
-	public function getTokenByUser(string $uid): array {
130
-		/* @var $qb IQueryBuilder */
131
-		$qb = $this->db->getQueryBuilder();
132
-		$qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
133
-			->from('authtoken')
134
-			->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
135
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
136
-			->setMaxResults(1000);
137
-		$result = $qb->execute();
138
-		$data = $result->fetchAll();
139
-		$result->closeCursor();
140
-
141
-		$entities = array_map(function ($row) {
142
-			return DefaultToken::fromRow($row);
143
-		}, $data);
144
-
145
-		return $entities;
146
-	}
147
-
148
-	public function deleteById(string $uid, int $id) {
149
-		/* @var $qb IQueryBuilder */
150
-		$qb = $this->db->getQueryBuilder();
151
-		$qb->delete('authtoken')
152
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
153
-			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
154
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)));
155
-		$qb->execute();
156
-	}
157
-
158
-	/**
159
-	 * delete all auth token which belong to a specific client if the client was deleted
160
-	 *
161
-	 * @param string $name
162
-	 */
163
-	public function deleteByName(string $name) {
164
-		$qb = $this->db->getQueryBuilder();
165
-		$qb->delete('authtoken')
166
-			->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR))
167
-			->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)));
168
-		$qb->execute();
169
-	}
39
+    public function __construct(IDBConnection $db) {
40
+        parent::__construct($db, 'authtoken');
41
+    }
42
+
43
+    /**
44
+     * Invalidate (delete) a given token
45
+     *
46
+     * @param string $token
47
+     */
48
+    public function invalidate(string $token) {
49
+        /* @var $qb IQueryBuilder */
50
+        $qb = $this->db->getQueryBuilder();
51
+        $qb->delete('authtoken')
52
+            ->where($qb->expr()->eq('token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR)))
53
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
54
+            ->execute();
55
+    }
56
+
57
+    /**
58
+     * @param int $olderThan
59
+     * @param int $remember
60
+     */
61
+    public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) {
62
+        /* @var $qb IQueryBuilder */
63
+        $qb = $this->db->getQueryBuilder();
64
+        $qb->delete('authtoken')
65
+            ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT)))
66
+            ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT)))
67
+            ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT)))
68
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
69
+            ->execute();
70
+    }
71
+
72
+    /**
73
+     * Get the user UID for the given token
74
+     *
75
+     * @param string $token
76
+     * @throws DoesNotExistException
77
+     * @return DefaultToken
78
+     */
79
+    public function getToken(string $token): DefaultToken {
80
+        /* @var $qb IQueryBuilder */
81
+        $qb = $this->db->getQueryBuilder();
82
+        $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
83
+            ->from('authtoken')
84
+            ->where($qb->expr()->eq('token', $qb->createNamedParameter($token)))
85
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
86
+            ->execute();
87
+
88
+        $data = $result->fetch();
89
+        $result->closeCursor();
90
+        if ($data === false) {
91
+            throw new DoesNotExistException('token does not exist');
92
+        }
93
+        return DefaultToken::fromRow($data);
94
+    }
95
+
96
+    /**
97
+     * Get the token for $id
98
+     *
99
+     * @param int $id
100
+     * @throws DoesNotExistException
101
+     * @return DefaultToken
102
+     */
103
+    public function getTokenById(int $id): DefaultToken {
104
+        /* @var $qb IQueryBuilder */
105
+        $qb = $this->db->getQueryBuilder();
106
+        $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
107
+            ->from('authtoken')
108
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
109
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
110
+            ->execute();
111
+
112
+        $data = $result->fetch();
113
+        $result->closeCursor();
114
+        if ($data === false) {
115
+            throw new DoesNotExistException('token does not exist');
116
+        }
117
+        return DefaultToken::fromRow($data);
118
+    }
119
+
120
+    /**
121
+     * Get all tokens of a user
122
+     *
123
+     * The provider may limit the number of result rows in case of an abuse
124
+     * where a high number of (session) tokens is generated
125
+     *
126
+     * @param string $uid
127
+     * @return DefaultToken[]
128
+     */
129
+    public function getTokenByUser(string $uid): array {
130
+        /* @var $qb IQueryBuilder */
131
+        $qb = $this->db->getQueryBuilder();
132
+        $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version')
133
+            ->from('authtoken')
134
+            ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
135
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)))
136
+            ->setMaxResults(1000);
137
+        $result = $qb->execute();
138
+        $data = $result->fetchAll();
139
+        $result->closeCursor();
140
+
141
+        $entities = array_map(function ($row) {
142
+            return DefaultToken::fromRow($row);
143
+        }, $data);
144
+
145
+        return $entities;
146
+    }
147
+
148
+    public function deleteById(string $uid, int $id) {
149
+        /* @var $qb IQueryBuilder */
150
+        $qb = $this->db->getQueryBuilder();
151
+        $qb->delete('authtoken')
152
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
153
+            ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
154
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)));
155
+        $qb->execute();
156
+    }
157
+
158
+    /**
159
+     * delete all auth token which belong to a specific client if the client was deleted
160
+     *
161
+     * @param string $name
162
+     */
163
+    public function deleteByName(string $name) {
164
+        $qb = $this->db->getQueryBuilder();
165
+        $qb->delete('authtoken')
166
+            ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR))
167
+            ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT)));
168
+        $qb->execute();
169
+    }
170 170
 }
Please login to merge, or discard this patch.
lib/private/Console/TimestampFormatter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,6 +103,6 @@
 block discarded – undo
103 103
 		$time = new \DateTime('now', $timeZone);
104 104
 		$timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
105 105
 
106
-		return $timestampInfo . ' ' . $this->formatter->format($message);
106
+		return $timestampInfo.' '.$this->formatter->format($message);
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -28,84 +28,84 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface;
29 29
 
30 30
 class TimestampFormatter implements OutputFormatterInterface {
31
-	/** @var IConfig */
32
-	protected $config;
31
+    /** @var IConfig */
32
+    protected $config;
33 33
 
34
-	/** @var OutputFormatterInterface */
35
-	protected $formatter;
34
+    /** @var OutputFormatterInterface */
35
+    protected $formatter;
36 36
 
37
-	/**
38
-	 * @param IConfig $config
39
-	 * @param OutputFormatterInterface $formatter
40
-	 */
41
-	public function __construct(IConfig $config, OutputFormatterInterface $formatter) {
42
-		$this->config = $config;
43
-		$this->formatter = $formatter;
44
-	}
37
+    /**
38
+     * @param IConfig $config
39
+     * @param OutputFormatterInterface $formatter
40
+     */
41
+    public function __construct(IConfig $config, OutputFormatterInterface $formatter) {
42
+        $this->config = $config;
43
+        $this->formatter = $formatter;
44
+    }
45 45
 
46
-	/**
47
-	 * Sets the decorated flag.
48
-	 *
49
-	 * @param bool $decorated Whether to decorate the messages or not
50
-	 */
51
-	public function setDecorated($decorated) {
52
-		$this->formatter->setDecorated($decorated);
53
-	}
46
+    /**
47
+     * Sets the decorated flag.
48
+     *
49
+     * @param bool $decorated Whether to decorate the messages or not
50
+     */
51
+    public function setDecorated($decorated) {
52
+        $this->formatter->setDecorated($decorated);
53
+    }
54 54
 
55
-	/**
56
-	 * Gets the decorated flag.
57
-	 *
58
-	 * @return bool true if the output will decorate messages, false otherwise
59
-	 */
60
-	public function isDecorated() {
61
-		return $this->formatter->isDecorated();
62
-	}
55
+    /**
56
+     * Gets the decorated flag.
57
+     *
58
+     * @return bool true if the output will decorate messages, false otherwise
59
+     */
60
+    public function isDecorated() {
61
+        return $this->formatter->isDecorated();
62
+    }
63 63
 
64
-	/**
65
-	 * Sets a new style.
66
-	 *
67
-	 * @param string $name The style name
68
-	 * @param OutputFormatterStyleInterface $style The style instance
69
-	 */
70
-	public function setStyle($name, OutputFormatterStyleInterface $style) {
71
-		$this->formatter->setStyle($name, $style);
72
-	}
64
+    /**
65
+     * Sets a new style.
66
+     *
67
+     * @param string $name The style name
68
+     * @param OutputFormatterStyleInterface $style The style instance
69
+     */
70
+    public function setStyle($name, OutputFormatterStyleInterface $style) {
71
+        $this->formatter->setStyle($name, $style);
72
+    }
73 73
 
74
-	/**
75
-	 * Checks if output formatter has style with specified name.
76
-	 *
77
-	 * @param string $name
78
-	 * @return bool
79
-	 */
80
-	public function hasStyle($name) {
81
-		return $this->formatter->hasStyle($name);
82
-	}
74
+    /**
75
+     * Checks if output formatter has style with specified name.
76
+     *
77
+     * @param string $name
78
+     * @return bool
79
+     */
80
+    public function hasStyle($name) {
81
+        return $this->formatter->hasStyle($name);
82
+    }
83 83
 
84
-	/**
85
-	 * Gets style options from style with specified name.
86
-	 *
87
-	 * @param string $name
88
-	 * @return OutputFormatterStyleInterface
89
-	 * @throws \InvalidArgumentException When style isn't defined
90
-	 */
91
-	public function getStyle($name) {
92
-		return $this->formatter->getStyle($name);
93
-	}
84
+    /**
85
+     * Gets style options from style with specified name.
86
+     *
87
+     * @param string $name
88
+     * @return OutputFormatterStyleInterface
89
+     * @throws \InvalidArgumentException When style isn't defined
90
+     */
91
+    public function getStyle($name) {
92
+        return $this->formatter->getStyle($name);
93
+    }
94 94
 
95
-	/**
96
-	 * Formats a message according to the given styles.
97
-	 *
98
-	 * @param string $message The message to style
99
-	 * @return string The styled message, prepended with a timestamp using the
100
-	 * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
101
-	 */
102
-	public function format($message) {
103
-		$timeZone = $this->config->getSystemValue('logtimezone', 'UTC');
104
-		$timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null;
95
+    /**
96
+     * Formats a message according to the given styles.
97
+     *
98
+     * @param string $message The message to style
99
+     * @return string The styled message, prepended with a timestamp using the
100
+     * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
101
+     */
102
+    public function format($message) {
103
+        $timeZone = $this->config->getSystemValue('logtimezone', 'UTC');
104
+        $timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null;
105 105
 
106
-		$time = new \DateTime('now', $timeZone);
107
-		$timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
106
+        $time = new \DateTime('now', $timeZone);
107
+        $timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
108 108
 
109
-		return $timestampInfo . ' ' . $this->formatter->format($message);
110
-	}
109
+        return $timestampInfo . ' ' . $this->formatter->format($message);
110
+    }
111 111
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/Response.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@
 block discarded – undo
54 54
 	 */
55 55
 	public function getBody() {
56 56
 		return $this->stream ?
57
-			$this->response->getBody()->detach():
58
-			$this->response->getBody()->getContents();
57
+			$this->response->getBody()->detach() : $this->response->getBody()->getContents();
59 58
 	}
60 59
 
61 60
 	/**
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -33,57 +33,57 @@
 block discarded – undo
33 33
  * @package OC\Http
34 34
  */
35 35
 class Response implements IResponse {
36
-	/** @var ResponseInterface */
37
-	private $response;
36
+    /** @var ResponseInterface */
37
+    private $response;
38 38
 
39
-	/**
40
-	 * @var bool
41
-	 */
42
-	private $stream;
39
+    /**
40
+     * @var bool
41
+     */
42
+    private $stream;
43 43
 
44
-	/**
45
-	 * @param ResponseInterface $response
46
-	 * @param bool $stream
47
-	 */
48
-	public function __construct(ResponseInterface $response, $stream = false) {
49
-		$this->response = $response;
50
-		$this->stream = $stream;
51
-	}
44
+    /**
45
+     * @param ResponseInterface $response
46
+     * @param bool $stream
47
+     */
48
+    public function __construct(ResponseInterface $response, $stream = false) {
49
+        $this->response = $response;
50
+        $this->stream = $stream;
51
+    }
52 52
 
53
-	/**
54
-	 * @return string|resource
55
-	 */
56
-	public function getBody() {
57
-		return $this->stream ?
58
-			$this->response->getBody()->detach():
59
-			$this->response->getBody()->getContents();
60
-	}
53
+    /**
54
+     * @return string|resource
55
+     */
56
+    public function getBody() {
57
+        return $this->stream ?
58
+            $this->response->getBody()->detach():
59
+            $this->response->getBody()->getContents();
60
+    }
61 61
 
62
-	/**
63
-	 * @return int
64
-	 */
65
-	public function getStatusCode(): int {
66
-		return $this->response->getStatusCode();
67
-	}
62
+    /**
63
+     * @return int
64
+     */
65
+    public function getStatusCode(): int {
66
+        return $this->response->getStatusCode();
67
+    }
68 68
 
69
-	/**
70
-	 * @param string $key
71
-	 * @return string
72
-	 */
73
-	public function getHeader(string $key): string {
74
-		$headers = $this->response->getHeader($key);
69
+    /**
70
+     * @param string $key
71
+     * @return string
72
+     */
73
+    public function getHeader(string $key): string {
74
+        $headers = $this->response->getHeader($key);
75 75
 
76
-		if (count($headers) === 0) {
77
-			return '';
78
-		}
76
+        if (count($headers) === 0) {
77
+            return '';
78
+        }
79 79
 
80
-		return $headers[0];
81
-	}
80
+        return $headers[0];
81
+    }
82 82
 
83
-	/**
84
-	 * @return array
85
-	 */
86
-	public function getHeaders(): array {
87
-		return $this->response->getHeaders();
88
-	}
83
+    /**
84
+     * @return array
85
+     */
86
+    public function getHeaders(): array {
87
+        return $this->response->getHeaders();
88
+    }
89 89
 }
Please login to merge, or discard this patch.
lib/private/HintException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 	 * @return string
62 62
 	 */
63 63
 	public function __toString() {
64
-		return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
64
+		return __CLASS__.": [{$this->code}]: {$this->message} ({$this->hint})\n";
65 65
 	}
66 66
 
67 67
 	/**
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -34,46 +34,46 @@
 block discarded – undo
34 34
  * @package OC
35 35
  */
36 36
 class HintException extends \Exception {
37
-	private $hint;
37
+    private $hint;
38 38
 
39
-	/**
40
-	 * HintException constructor.
41
-	 *
42
-	 * @param string $message  The error message. It will be not revealed to the
43
-	 *                         the user (unless the hint is empty) and thus
44
-	 *                         should be not translated.
45
-	 * @param string $hint     A useful message that is presented to the end
46
-	 *                         user. It should be translated, but must not
47
-	 *                         contain sensitive data.
48
-	 * @param int $code
49
-	 * @param \Exception|null $previous
50
-	 */
51
-	public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
52
-		$this->hint = $hint;
53
-		parent::__construct($message, $code, $previous);
54
-	}
39
+    /**
40
+     * HintException constructor.
41
+     *
42
+     * @param string $message  The error message. It will be not revealed to the
43
+     *                         the user (unless the hint is empty) and thus
44
+     *                         should be not translated.
45
+     * @param string $hint     A useful message that is presented to the end
46
+     *                         user. It should be translated, but must not
47
+     *                         contain sensitive data.
48
+     * @param int $code
49
+     * @param \Exception|null $previous
50
+     */
51
+    public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
52
+        $this->hint = $hint;
53
+        parent::__construct($message, $code, $previous);
54
+    }
55 55
 
56
-	/**
57
-	 * Returns a string representation of this Exception that includes the error
58
-	 * code, the message and the hint.
59
-	 *
60
-	 * @return string
61
-	 */
62
-	public function __toString() {
63
-		return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
64
-	}
56
+    /**
57
+     * Returns a string representation of this Exception that includes the error
58
+     * code, the message and the hint.
59
+     *
60
+     * @return string
61
+     */
62
+    public function __toString() {
63
+        return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
64
+    }
65 65
 
66
-	/**
67
-	 * Returns the hint with the intention to be presented to the end user. If
68
-	 * an empty hint was specified upon instatiation, the message is returned
69
-	 * instead.
70
-	 *
71
-	 * @return string
72
-	 */
73
-	public function getHint() {
74
-		if (empty($this->hint)) {
75
-			return $this->message;
76
-		}
77
-		return $this->hint;
78
-	}
66
+    /**
67
+     * Returns the hint with the intention to be presented to the end user. If
68
+     * an empty hint was specified upon instatiation, the message is returned
69
+     * instead.
70
+     *
71
+     * @return string
72
+     */
73
+    public function getHint() {
74
+        if (empty($this->hint)) {
75
+            return $this->message;
76
+        }
77
+        return $this->hint;
78
+    }
79 79
 }
Please login to merge, or discard this patch.
lib/private/Diagnostics/Event.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -26,79 +26,79 @@
 block discarded – undo
26 26
 use OCP\Diagnostics\IEvent;
27 27
 
28 28
 class Event implements IEvent {
29
-	/**
30
-	 * @var string
31
-	 */
32
-	protected $id;
29
+    /**
30
+     * @var string
31
+     */
32
+    protected $id;
33 33
 
34
-	/**
35
-	 * @var float
36
-	 */
37
-	protected $start;
34
+    /**
35
+     * @var float
36
+     */
37
+    protected $start;
38 38
 
39
-	/**
40
-	 * @var float
41
-	 */
42
-	protected $end;
39
+    /**
40
+     * @var float
41
+     */
42
+    protected $end;
43 43
 
44
-	/**
45
-	 * @var string
46
-	 */
47
-	protected $description;
44
+    /**
45
+     * @var string
46
+     */
47
+    protected $description;
48 48
 
49
-	/**
50
-	 * @param string $id
51
-	 * @param string $description
52
-	 * @param float $start
53
-	 */
54
-	public function __construct($id, $description, $start) {
55
-		$this->id = $id;
56
-		$this->description = $description;
57
-		$this->start = $start;
58
-	}
49
+    /**
50
+     * @param string $id
51
+     * @param string $description
52
+     * @param float $start
53
+     */
54
+    public function __construct($id, $description, $start) {
55
+        $this->id = $id;
56
+        $this->description = $description;
57
+        $this->start = $start;
58
+    }
59 59
 
60
-	/**
61
-	 * @param float $time
62
-	 */
63
-	public function end($time) {
64
-		$this->end = $time;
65
-	}
60
+    /**
61
+     * @param float $time
62
+     */
63
+    public function end($time) {
64
+        $this->end = $time;
65
+    }
66 66
 
67
-	/**
68
-	 * @return float
69
-	 */
70
-	public function getStart() {
71
-		return $this->start;
72
-	}
67
+    /**
68
+     * @return float
69
+     */
70
+    public function getStart() {
71
+        return $this->start;
72
+    }
73 73
 
74
-	/**
75
-	 * @return string
76
-	 */
77
-	public function getId() {
78
-		return $this->id;
79
-	}
74
+    /**
75
+     * @return string
76
+     */
77
+    public function getId() {
78
+        return $this->id;
79
+    }
80 80
 
81
-	/**
82
-	 * @return string
83
-	 */
84
-	public function getDescription() {
85
-		return $this->description;
86
-	}
81
+    /**
82
+     * @return string
83
+     */
84
+    public function getDescription() {
85
+        return $this->description;
86
+    }
87 87
 
88
-	/**
89
-	 * @return float
90
-	 */
91
-	public function getEnd() {
92
-		return $this->end;
93
-	}
88
+    /**
89
+     * @return float
90
+     */
91
+    public function getEnd() {
92
+        return $this->end;
93
+    }
94 94
 
95
-	/**
96
-	 * @return float
97
-	 */
98
-	public function getDuration() {
99
-		if (!$this->end) {
100
-			$this->end = microtime(true);
101
-		}
102
-		return $this->end - $this->start;
103
-	}
95
+    /**
96
+     * @return float
97
+     */
98
+    public function getDuration() {
99
+        if (!$this->end) {
100
+            $this->end = microtime(true);
101
+        }
102
+        return $this->end - $this->start;
103
+    }
104 104
 }
Please login to merge, or discard this patch.
lib/private/NaturalSort_DefaultCollator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
 namespace OC;
26 26
 
27 27
 class NaturalSort_DefaultCollator {
28
-	public function compare($a, $b) {
29
-		$result = strcasecmp($a, $b);
30
-		if ($result === 0) {
31
-			if ($a === $b) {
32
-				return 0;
33
-			}
34
-			return ($a > $b) ? -1 : 1;
35
-		}
36
-		return ($result < 0) ? -1 : 1;
37
-	}
28
+    public function compare($a, $b) {
29
+        $result = strcasecmp($a, $b);
30
+        if ($result === 0) {
31
+            if ($a === $b) {
32
+                return 0;
33
+            }
34
+            return ($a > $b) ? -1 : 1;
35
+        }
36
+        return ($result < 0) ? -1 : 1;
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/Migration/BackgroundRepair.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function execute($jobList, ILogger $logger = null) {
59 59
 		// add an interval of 15 mins
60
-		$this->setInterval(15*60);
60
+		$this->setInterval(15 * 60);
61 61
 
62 62
 		$this->jobList = $jobList;
63 63
 		$this->logger = $logger;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		try {
91 91
 			$repair->addStep($step);
92 92
 		} catch (\Exception $ex) {
93
-			$this->logger->logException($ex,[
93
+			$this->logger->logException($ex, [
94 94
 				'app' => 'migration'
95 95
 			]);
96 96
 
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -39,82 +39,82 @@
 block discarded – undo
39 39
  */
40 40
 class BackgroundRepair extends TimedJob {
41 41
 
42
-	/** @var IJobList */
43
-	private $jobList;
44
-
45
-	/** @var ILogger */
46
-	private $logger;
47
-
48
-	/** @var EventDispatcherInterface */
49
-	private $dispatcher;
50
-
51
-	public function __construct(EventDispatcherInterface $dispatcher) {
52
-		$this->dispatcher = $dispatcher;
53
-	}
54
-
55
-	/**
56
-	 * run the job, then remove it from the job list
57
-	 *
58
-	 * @param JobList $jobList
59
-	 * @param ILogger|null $logger
60
-	 */
61
-	public function execute($jobList, ILogger $logger = null) {
62
-		// add an interval of 15 mins
63
-		$this->setInterval(15*60);
64
-
65
-		$this->jobList = $jobList;
66
-		$this->logger = $logger;
67
-		parent::execute($jobList, $logger);
68
-	}
69
-
70
-	/**
71
-	 * @param array $argument
72
-	 * @throws \Exception
73
-	 * @throws \OC\NeedsUpdateException
74
-	 */
75
-	protected function run($argument) {
76
-		if (!isset($argument['app']) || !isset($argument['step'])) {
77
-			// remove the job - we can never execute it
78
-			$this->jobList->remove($this, $this->argument);
79
-			return;
80
-		}
81
-		$app = $argument['app'];
82
-
83
-		try {
84
-			$this->loadApp($app);
85
-		} catch (NeedsUpdateException $ex) {
86
-			// as long as the app is not yet done with it's offline migration
87
-			// we better not start with the live migration
88
-			return;
89
-		}
90
-
91
-		$step = $argument['step'];
92
-		$repair = new Repair([], $this->dispatcher);
93
-		try {
94
-			$repair->addStep($step);
95
-		} catch (\Exception $ex) {
96
-			$this->logger->logException($ex,[
97
-				'app' => 'migration'
98
-			]);
99
-
100
-			// remove the job - we can never execute it
101
-			$this->jobList->remove($this, $this->argument);
102
-			return;
103
-		}
104
-
105
-		// execute the repair step
106
-		$repair->run();
107
-
108
-		// remove the job once executed successfully
109
-		$this->jobList->remove($this, $this->argument);
110
-	}
111
-
112
-	/**
113
-	 * @codeCoverageIgnore
114
-	 * @param $app
115
-	 * @throws NeedsUpdateException
116
-	 */
117
-	protected function loadApp($app) {
118
-		OC_App::loadApp($app);
119
-	}
42
+    /** @var IJobList */
43
+    private $jobList;
44
+
45
+    /** @var ILogger */
46
+    private $logger;
47
+
48
+    /** @var EventDispatcherInterface */
49
+    private $dispatcher;
50
+
51
+    public function __construct(EventDispatcherInterface $dispatcher) {
52
+        $this->dispatcher = $dispatcher;
53
+    }
54
+
55
+    /**
56
+     * run the job, then remove it from the job list
57
+     *
58
+     * @param JobList $jobList
59
+     * @param ILogger|null $logger
60
+     */
61
+    public function execute($jobList, ILogger $logger = null) {
62
+        // add an interval of 15 mins
63
+        $this->setInterval(15*60);
64
+
65
+        $this->jobList = $jobList;
66
+        $this->logger = $logger;
67
+        parent::execute($jobList, $logger);
68
+    }
69
+
70
+    /**
71
+     * @param array $argument
72
+     * @throws \Exception
73
+     * @throws \OC\NeedsUpdateException
74
+     */
75
+    protected function run($argument) {
76
+        if (!isset($argument['app']) || !isset($argument['step'])) {
77
+            // remove the job - we can never execute it
78
+            $this->jobList->remove($this, $this->argument);
79
+            return;
80
+        }
81
+        $app = $argument['app'];
82
+
83
+        try {
84
+            $this->loadApp($app);
85
+        } catch (NeedsUpdateException $ex) {
86
+            // as long as the app is not yet done with it's offline migration
87
+            // we better not start with the live migration
88
+            return;
89
+        }
90
+
91
+        $step = $argument['step'];
92
+        $repair = new Repair([], $this->dispatcher);
93
+        try {
94
+            $repair->addStep($step);
95
+        } catch (\Exception $ex) {
96
+            $this->logger->logException($ex,[
97
+                'app' => 'migration'
98
+            ]);
99
+
100
+            // remove the job - we can never execute it
101
+            $this->jobList->remove($this, $this->argument);
102
+            return;
103
+        }
104
+
105
+        // execute the repair step
106
+        $repair->run();
107
+
108
+        // remove the job once executed successfully
109
+        $this->jobList->remove($this, $this->argument);
110
+    }
111
+
112
+    /**
113
+     * @codeCoverageIgnore
114
+     * @param $app
115
+     * @throws NeedsUpdateException
116
+     */
117
+    protected function loadApp($app) {
118
+        OC_App::loadApp($app);
119
+    }
120 120
 }
Please login to merge, or discard this patch.