@@ -206,6 +206,10 @@ discard block |
||
206 | 206 | return array($cipherKey, $macKey, $iv); |
207 | 207 | } |
208 | 208 | |
209 | + /** |
|
210 | + * @param string $a |
|
211 | + * @param string $b |
|
212 | + */ |
|
209 | 213 | protected function hash_equals($a, $b) { |
210 | 214 | if (function_exists('random_bytes')) { |
211 | 215 | $key = random_bytes(128); |
@@ -247,7 +251,7 @@ discard block |
||
247 | 251 | /** |
248 | 252 | * Pad the data with a random char chosen by the pad amount. |
249 | 253 | * |
250 | - * @param $data |
|
254 | + * @param string $data |
|
251 | 255 | * @return string |
252 | 256 | */ |
253 | 257 | protected function pad($data) { |
@@ -263,8 +267,8 @@ discard block |
||
263 | 267 | /** |
264 | 268 | * Unpad the the data |
265 | 269 | * |
266 | - * @param $data |
|
267 | - * @return bool|string |
|
270 | + * @param string $data |
|
271 | + * @return false|string |
|
268 | 272 | */ |
269 | 273 | protected function unpad($data) { |
270 | 274 | $length = $this->getKeySize(); |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | return new JSONResponse(array('success' => true)); |
114 | 114 | } |
115 | 115 | |
116 | - public function listRequests(){ |
|
116 | + public function listRequests() { |
|
117 | 117 | $requests = $this->deleteVaultRequestService->getDeleteRequests(); |
118 | 118 | $results = array(); |
119 | - foreach($requests as $request){ |
|
119 | + foreach ($requests as $request) { |
|
120 | 120 | $r = $request->jsonSerialize(); |
121 | 121 | $r['displayName'] = Utils::getNameByUid($request->getRequestedBy(), $this->userManager); |
122 | 122 | array_push($results, $r); |
@@ -124,28 +124,28 @@ discard block |
||
124 | 124 | return new JSONResponse($results); |
125 | 125 | } |
126 | 126 | |
127 | - public function acceptRequestDeletion($vault_guid, $requested_by){ |
|
127 | + public function acceptRequestDeletion($vault_guid, $requested_by) { |
|
128 | 128 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
129 | - try{ |
|
129 | + try { |
|
130 | 130 | $vault = $this->vaultService->getByGuid($vault_guid, $requested_by); |
131 | - } catch (\Exception $e){ |
|
131 | + } catch (\Exception $e) { |
|
132 | 132 | //Ignore |
133 | 133 | } |
134 | 134 | |
135 | - if(isset($vault)){ |
|
135 | + if (isset($vault)) { |
|
136 | 136 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $requested_by); |
137 | - foreach($credentials as $credential){ |
|
137 | + foreach ($credentials as $credential) { |
|
138 | 138 | $revisions = $this->revisionService->getRevisions($credential->getId()); |
139 | - foreach($revisions as $revision){ |
|
139 | + foreach ($revisions as $revision) { |
|
140 | 140 | $this->revisionService->deleteRevision($revision['revision_id'], $requested_by); |
141 | 141 | } |
142 | - if($credential instanceof Credential){ |
|
142 | + if ($credential instanceof Credential) { |
|
143 | 143 | $this->credentialService->deleteCredential($credential); |
144 | 144 | } |
145 | 145 | } |
146 | 146 | $this->vaultService->deleteVault($vault_guid, $requested_by); |
147 | 147 | } |
148 | - if($req instanceof DeleteVaultRequest) { |
|
148 | + if ($req instanceof DeleteVaultRequest) { |
|
149 | 149 | $this->deleteVaultRequestService->removeDeleteRequestForVault($req); |
150 | 150 | } |
151 | 151 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function requestDeletion($vault_guid, $reason) { |
159 | 159 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
160 | - if($req){ |
|
160 | + if ($req) { |
|
161 | 161 | return new JSONResponse('Already exists'); |
162 | 162 | } |
163 | 163 | $vault = $this->vaultService->getByGuid($vault_guid, $this->userId); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $result = false; |
183 | 183 | try { |
184 | 184 | $delete_request = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
185 | - } catch (\Exception $exception){ |
|
185 | + } catch (\Exception $exception) { |
|
186 | 186 | // Ignore it |
187 | 187 | } |
188 | 188 |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | return new JSONResponse(array('success' => true)); |
114 | 114 | } |
115 | 115 | |
116 | - public function listRequests(){ |
|
116 | + public function listRequests() { |
|
117 | 117 | $requests = $this->deleteVaultRequestService->getDeleteRequests(); |
118 | 118 | $results = array(); |
119 | - foreach($requests as $request){ |
|
119 | + foreach($requests as $request) { |
|
120 | 120 | $r = $request->jsonSerialize(); |
121 | 121 | $r['displayName'] = Utils::getNameByUid($request->getRequestedBy(), $this->userManager); |
122 | 122 | array_push($results, $r); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | return new JSONResponse($results); |
125 | 125 | } |
126 | 126 | |
127 | - public function acceptRequestDeletion($vault_guid, $requested_by){ |
|
127 | + public function acceptRequestDeletion($vault_guid, $requested_by) { |
|
128 | 128 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
129 | 129 | try{ |
130 | 130 | $vault = $this->vaultService->getByGuid($vault_guid, $requested_by); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | //Ignore |
133 | 133 | } |
134 | 134 | |
135 | - if(isset($vault)){ |
|
135 | + if(isset($vault)) { |
|
136 | 136 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $requested_by); |
137 | - foreach($credentials as $credential){ |
|
137 | + foreach($credentials as $credential) { |
|
138 | 138 | $revisions = $this->revisionService->getRevisions($credential->getId()); |
139 | - foreach($revisions as $revision){ |
|
139 | + foreach($revisions as $revision) { |
|
140 | 140 | $this->revisionService->deleteRevision($revision['revision_id'], $requested_by); |
141 | 141 | } |
142 | - if($credential instanceof Credential){ |
|
142 | + if($credential instanceof Credential) { |
|
143 | 143 | $this->credentialService->deleteCredential($credential); |
144 | 144 | } |
145 | 145 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function requestDeletion($vault_guid, $reason) { |
159 | 159 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
160 | - if($req){ |
|
160 | + if($req) { |
|
161 | 161 | return new JSONResponse('Already exists'); |
162 | 162 | } |
163 | 163 | $vault = $this->vaultService->getByGuid($vault_guid, $this->userId); |
@@ -27,12 +27,12 @@ |
||
27 | 27 | private $appManager; |
28 | 28 | |
29 | 29 | public function __construct($AppName, |
30 | - IRequest $request, |
|
31 | - $UserId, |
|
32 | - CredentialService $credentialService, |
|
33 | - IConfig $config, |
|
34 | - IManager $IManager, |
|
35 | - IAppManager $appManager |
|
30 | + IRequest $request, |
|
31 | + $UserId, |
|
32 | + CredentialService $credentialService, |
|
33 | + IConfig $config, |
|
34 | + IManager $IManager, |
|
35 | + IAppManager $appManager |
|
36 | 36 | ) { |
37 | 37 | parent::__construct( |
38 | 38 | $AppName, |
@@ -60,7 +60,7 @@ |
||
60 | 60 | private $fileService; |
61 | 61 | |
62 | 62 | public function __construct(EncryptService $encryptService, IDBConnection $db, LoggerInterface $logger, CredentialService $credentialService, CredentialRevisionService $revisionService, |
63 | - FileService $fileService, IConfig $config) { |
|
63 | + FileService $fileService, IConfig $config) { |
|
64 | 64 | $this->encryptService = $encryptService; |
65 | 65 | $this->db = $db; |
66 | 66 | $this->logger = $logger; |
@@ -94,7 +94,7 @@ |
||
94 | 94 | $qb = $this->db->getQueryBuilder(); |
95 | 95 | $qb->select('*') |
96 | 96 | ->from(self::TABLE_NAME) |
97 | - ->where($qb->expr()->gt('expire_time', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))) |
|
97 | + ->where($qb->expr()->gt('expire_time', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))) |
|
98 | 98 | ->andWhere($qb->expr()->lt('expire_time', $qb->createNamedParameter($timestamp, IQueryBuilder::PARAM_INT))); |
99 | 99 | |
100 | 100 | /** @var Credential[] $credentials */ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param $user_id |
96 | 96 | * @return Vault|Entity |
97 | 97 | */ |
98 | - public function setLastAccess($vault_id, $user_id){ |
|
98 | + public function setLastAccess($vault_id, $user_id) { |
|
99 | 99 | return $this->vaultMapper->setLastAccess($vault_id, $user_id); |
100 | 100 | } |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param $publicKey |
107 | 107 | * @return Vault|Entity |
108 | 108 | */ |
109 | - public function updateSharingKeys($vault_id, $privateKey, $publicKey){ |
|
109 | + public function updateSharingKeys($vault_id, $privateKey, $publicKey) { |
|
110 | 110 | return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey); |
111 | 111 | } |
112 | 112 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * @param string $vault_guid |
116 | 116 | * @param string $user_id |
117 | 117 | */ |
118 | - public function deleteVault($vault_guid, $user_id){ |
|
118 | + public function deleteVault($vault_guid, $user_id) { |
|
119 | 119 | $vault = $this->getByGuid($vault_guid, $user_id); |
120 | - if($vault instanceof Vault) { |
|
120 | + if ($vault instanceof Vault) { |
|
121 | 121 | $this->vaultMapper->deleteVault($vault); |
122 | 122 | } |
123 | 123 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param $user_id |
96 | 96 | * @return Vault|Entity |
97 | 97 | */ |
98 | - public function setLastAccess($vault_id, $user_id){ |
|
98 | + public function setLastAccess($vault_id, $user_id) { |
|
99 | 99 | return $this->vaultMapper->setLastAccess($vault_id, $user_id); |
100 | 100 | } |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param $publicKey |
107 | 107 | * @return Vault|Entity |
108 | 108 | */ |
109 | - public function updateSharingKeys($vault_id, $privateKey, $publicKey){ |
|
109 | + public function updateSharingKeys($vault_id, $privateKey, $publicKey) { |
|
110 | 110 | return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey); |
111 | 111 | } |
112 | 112 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string $vault_guid |
116 | 116 | * @param string $user_id |
117 | 117 | */ |
118 | - public function deleteVault($vault_guid, $user_id){ |
|
118 | + public function deleteVault($vault_guid, $user_id) { |
|
119 | 119 | $vault = $this->getByGuid($vault_guid, $user_id); |
120 | 120 | if($vault instanceof Vault) { |
121 | 121 | $this->vaultMapper->deleteVault($vault); |
@@ -101,7 +101,9 @@ discard block |
||
101 | 101 | * @return Entity |
102 | 102 | */ |
103 | 103 | public function createACLEntry(SharingACL $acl) { |
104 | - if ($acl->getCreated() === null) $acl->setCreated((new \DateTime())->getTimestamp()); |
|
104 | + if ($acl->getCreated() === null) { |
|
105 | + $acl->setCreated((new \DateTime())->getTimestamp()); |
|
106 | + } |
|
105 | 107 | return $this->sharingACL->createACLEntry($acl); |
106 | 108 | } |
107 | 109 | |
@@ -159,13 +161,17 @@ discard block |
||
159 | 161 | $return = []; |
160 | 162 | foreach ($entries as $entry) { |
161 | 163 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
162 | - if (!$entry->hasPermission(SharingACL::READ)) continue; |
|
164 | + if (!$entry->hasPermission(SharingACL::READ)) { |
|
165 | + continue; |
|
166 | + } |
|
163 | 167 | $tmp = $entry->jsonSerialize(); |
164 | 168 | $credential = $this->credential->getCredentialById($entry->getItemId()); |
165 | 169 | $credential = $this->encryptService->decryptCredential($credential); |
166 | 170 | $tmp['credential_data'] = $credential->jsonSerialize(); |
167 | 171 | |
168 | - if (!$entry->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
172 | + if (!$entry->hasPermission(SharingACL::FILES)) { |
|
173 | + unset($tmp['credential_data']['files']); |
|
174 | + } |
|
169 | 175 | unset($tmp['credential_data']['shared_key']); |
170 | 176 | $return[] = $tmp; |
171 | 177 | } |
@@ -194,7 +200,9 @@ discard block |
||
194 | 200 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
195 | 201 | |
196 | 202 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
197 | - if (!$acl->hasPermission(SharingACL::READ)) throw new DoesNotExistException("Item not found or wrong access level"); |
|
203 | + if (!$acl->hasPermission(SharingACL::READ)) { |
|
204 | + throw new DoesNotExistException("Item not found or wrong access level"); |
|
205 | + } |
|
198 | 206 | |
199 | 207 | $tmp = $acl->jsonSerialize(); |
200 | 208 | $credential = $this->credential->getCredentialById($acl->getItemId()); |
@@ -202,7 +210,9 @@ discard block |
||
202 | 210 | |
203 | 211 | $tmp['credential_data'] = $credential->jsonSerialize(); |
204 | 212 | |
205 | - if (!$acl->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
213 | + if (!$acl->hasPermission(SharingACL::FILES)) { |
|
214 | + unset($tmp['credential_data']['files']); |
|
215 | + } |
|
206 | 216 | unset($tmp['credential_data']['shared_key']); |
207 | 217 | |
208 | 218 | return $tmp; |
@@ -217,7 +227,9 @@ discard block |
||
217 | 227 | */ |
218 | 228 | public function getItemHistory(string $user_id, string $item_guid) { |
219 | 229 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
220 | - if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) return []; |
|
230 | + if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) { |
|
231 | + return []; |
|
232 | + } |
|
221 | 233 | |
222 | 234 | return $this->revisions->getRevisions($acl->getItemId()); |
223 | 235 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | if ($data !== false) { |
83 | - $version = (string)$data->version; |
|
83 | + $version = (string) $data->version; |
|
84 | 84 | } else { |
85 | 85 | libxml_clear_errors(); |
86 | 86 | } |
@@ -267,7 +267,7 @@ |
||
267 | 267 | 'apps' => array(self::FILTER_PASSMAN => |
268 | 268 | array( |
269 | 269 | 'id' => 'passman', |
270 | - 'name' => (string)$l->t('Passwords'), |
|
270 | + 'name' => (string) $l->t('Passwords'), |
|
271 | 271 | 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', ['filter' => self::FILTER_PASSMAN]), |
272 | 272 | ), |
273 | 273 | ), |