Completed
Pull Request — master (#160)
by Sander
02:40
created
lib/Service/ShareService.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		ShareRequestMapper $shareRequest,
48 48
 		CredentialMapper $credentials,
49 49
 		CredentialRevisionService $revisions,
50
-	    EncryptService $encryptService
50
+		EncryptService $encryptService
51 51
 	) {
52 52
 		$this->sharingACL = $sharingACL;
53 53
 		$this->shareRequest = $shareRequest;
@@ -200,31 +200,31 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 
203
-    /**
204
-     * Deletes a share request by the item ID
205
-     * @param ShareRequest $request
206
-     * @return \PDOStatement
207
-     */
203
+	/**
204
+	 * Deletes a share request by the item ID
205
+	 * @param ShareRequest $request
206
+	 * @return \PDOStatement
207
+	 */
208 208
 	public function cleanItemRequestsForUser(ShareRequest $request) {
209 209
 		return $this->shareRequest->cleanItemRequestsForUser($request->getItemId(), $request->getTargetUserId());
210 210
 	}
211 211
 
212
-    /**
213
-     * Get an share request by id
214
-     * @param $id
215
-     * @return ShareRequest
216
-     */
212
+	/**
213
+	 * Get an share request by id
214
+	 * @param $id
215
+	 * @return ShareRequest
216
+	 */
217 217
 	public function getShareRequestById($id) {
218 218
 		return $this->shareRequest->getShareRequestById($id);
219 219
 	}
220 220
 
221
-    /**
222
-     * Get an share request by $item_guid and $target_vault_guid
223
-     *
224
-     * @param $item_guid
225
-     * @param $target_vault_guid
226
-     * @return ShareRequest
227
-     */
221
+	/**
222
+	 * Get an share request by $item_guid and $target_vault_guid
223
+	 *
224
+	 * @param $item_guid
225
+	 * @param $target_vault_guid
226
+	 * @return ShareRequest
227
+	 */
228 228
 	public function getRequestByGuid($item_guid, $target_vault_guid) {
229 229
 		return $this->shareRequest->getRequestByItemAndVaultGuid($item_guid, $target_vault_guid);
230 230
 	}
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 		return $this->sharingACL->deleteShareACL($ACL);
285 285
 	}
286 286
 
287
-    /**
288
-     * Updates the given ACL entry
289
-     * @param SharingACL $sharingACL
290
-     * @return SharingACL
291
-     */
287
+	/**
288
+	 * Updates the given ACL entry
289
+	 * @param SharingACL $sharingACL
290
+	 * @return SharingACL
291
+	 */
292 292
 	public function updateCredentialACL(SharingACL $sharingACL) {
293 293
 		return $this->sharingACL->updateCredentialACL($sharingACL);
294 294
 	}
@@ -310,6 +310,6 @@  discard block
 block discarded – undo
310 310
 
311 311
 
312 312
 	public function updatePendingShareRequestsForCredential($item_guid, $user_id, $permissions){
313
-	    return $this->shareRequest->updatePendingRequestPermissions($item_guid, $user_id, $permissions);
314
-    }
313
+		return $this->shareRequest->updatePendingRequestPermissions($item_guid, $user_id, $permissions);
314
+	}
315 315
 }
316 316
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/CredentialService.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 class CredentialService {
37 37
 
38 38
 	private $credentialMapper;
39
-    private $sharingACL;
39
+	private $sharingACL;
40 40
 	private $encryptService;
41 41
 	private $server_key;
42 42
 
43 43
 	public function __construct(CredentialMapper $credentialMapper, SharingACLMapper $sharingACL, EncryptService $encryptService) {
44 44
 		$this->credentialMapper = $credentialMapper;
45
-        $this->sharingACL = $sharingACL;
46
-        $this->encryptService = $encryptService;
45
+		$this->sharingACL = $sharingACL;
46
+		$this->encryptService = $encryptService;
47 47
 		$this->server_key = \OC::$server->getConfig()->getSystemValue('passwordsalt', '');
48 48
 	}
49 49
 
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 	 * @throws DoesNotExistException
137 137
 	 */
138 138
 	public function getCredentialById($credential_id, $user_id){
139
-        $credential = $this->credentialMapper->getCredentialById($credential_id);
140
-        if ($credential->getUserId() === $user_id){
141
-            return $credential;
142
-        }
143
-        else {
144
-            $acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
145
-            if ($acl->hasPermission(SharingACL::READ)) {
139
+		$credential = $this->credentialMapper->getCredentialById($credential_id);
140
+		if ($credential->getUserId() === $user_id){
141
+			return $credential;
142
+		}
143
+		else {
144
+			$acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
145
+			if ($acl->hasPermission(SharingACL::READ)) {
146 146
 				return $this->encryptService->decryptCredential($credential);
147 147
 			} else {
148 148
 				throw new DoesNotExistException("Did expect one result but found none when executing");
149 149
 			}
150
-        }
150
+		}
151 151
 	}
152 152
 
153 153
 	/**
@@ -169,5 +169,5 @@  discard block
 block discarded – undo
169 169
 	public function getCredentialByGUID($credential_guid, $user_id = null){
170 170
 		$credential = $this->credentialMapper->getCredentialByGUID($credential_guid);
171 171
 		return $this->encryptService->decryptCredential($credential);
172
-    }
172
+	}
173 173
 }
174 174
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/EncryptService.php 1 patch
Doc Comments   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -212,6 +212,10 @@  discard block
 block discarded – undo
212 212
 		return array($cipherKey, $macKey, $iv);
213 213
 	}
214 214
 
215
+	/**
216
+	 * @param string $a
217
+	 * @param string $b
218
+	 */
215 219
 	protected function hash_equals($a, $b) {
216 220
 		$key = openssl_random_pseudo_bytes(128);
217 221
 		return hash_hmac('sha512', $a, $key) === hash_hmac('sha512', $b, $key);
@@ -249,7 +253,7 @@  discard block
 block discarded – undo
249 253
 	/**
250 254
 	 * Pad the data with a random char chosen by the pad amount.
251 255
 	 *
252
-	 * @param $data
256
+	 * @param string $data
253 257
 	 * @return string
254 258
 	 */
255 259
 	protected function pad($data) {
@@ -265,8 +269,8 @@  discard block
 block discarded – undo
265 269
 	/**
266 270
 	 * Unpad the the data
267 271
 	 *
268
-	 * @param $data
269
-	 * @return bool|string
272
+	 * @param string $data
273
+	 * @return false|string
270 274
 	 */
271 275
 	protected function unpad($data) {
272 276
 		$length = $this->getKeySize();
@@ -283,7 +287,7 @@  discard block
 block discarded – undo
283 287
 	 * Encrypt a credential
284 288
 	 *
285 289
 	 * @param Credential|array $credential the credential to decrypt
286
-	 * @return Credential|array
290
+	 * @return string
287 291
 	 */
288 292
 	public function decryptCredential($credential) {
289 293
 		return $this->handleCredential($credential, 'decrypt');
@@ -304,6 +308,7 @@  discard block
 block discarded – undo
304 308
 	 * Handles the encryption / decryption of a credential
305 309
 	 *
306 310
 	 * @param Credential|array $credential the credential to encrypt
311
+	 * @param string $op
307 312
 	 * @return Credential|array
308 313
 	 * @throws \Exception
309 314
 	 */
@@ -347,7 +352,7 @@  discard block
 block discarded – undo
347 352
 	/**
348 353
 	 * Decrypt a file
349 354
 	 *
350
-	 * @param  File|array $file
355
+	 * @param  File $file
351 356
 	 * @return File|array
352 357
 	 */
353 358
 
@@ -358,7 +363,7 @@  discard block
 block discarded – undo
358 363
 	/**
359 364
 	 * Handles the encryption / decryption of a File
360 365
 	 *
361
-	 * @param File|array $credential the credential to encrypt
366
+	 * @param string $op
362 367
 	 * @return File|array
363 368
 	 * @throws \Exception
364 369
 	 */
Please login to merge, or discard this patch.