@@ -129,7 +129,7 @@ |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | if (!is_array($config)) { |
132 | - throw new \Exception('Invalid configuration for consent store option: ' . var_export($config, true)); |
|
132 | + throw new \Exception('Invalid configuration for consent store option: '.var_export($config, true)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | if (!array_key_exists(0, $config)) { |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | public function hasConsent(string $userId, string $destinationId, string $attributeSet): bool |
171 | 171 | { |
172 | 172 | $st = $this->execute( |
173 | - 'UPDATE ' . $this->table . ' ' . |
|
174 | - 'SET usage_date = ' . $this->dateTime . ' ' . |
|
173 | + 'UPDATE '.$this->table.' '. |
|
174 | + 'SET usage_date = '.$this->dateTime.' '. |
|
175 | 175 | 'WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', |
176 | 176 | [$userId, $destinationId, $attributeSet] |
177 | 177 | ); |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | { |
208 | 208 | // Check for old consent (with different attribute set) |
209 | 209 | $st = $this->execute( |
210 | - 'UPDATE ' . $this->table . ' ' . |
|
211 | - 'SET consent_date = ' . $this->dateTime . ', usage_date = ' . $this->dateTime . ', attribute = ? ' . |
|
210 | + 'UPDATE '.$this->table.' '. |
|
211 | + 'SET consent_date = '.$this->dateTime.', usage_date = '.$this->dateTime.', attribute = ? '. |
|
212 | 212 | 'WHERE hashed_user_id = ? AND service_id = ?', |
213 | 213 | [$attributeSet, $userId, $destinationId] |
214 | 214 | ); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | |
226 | 226 | // Add new consent |
227 | 227 | $st = $this->execute( |
228 | - 'INSERT INTO ' . $this->table . ' (' . 'consent_date, usage_date, hashed_user_id, service_id, attribute' . |
|
229 | - ') ' . 'VALUES (' . $this->dateTime . ', ' . $this->dateTime . ', ?, ?, ?)', |
|
228 | + 'INSERT INTO '.$this->table.' ('.'consent_date, usage_date, hashed_user_id, service_id, attribute'. |
|
229 | + ') '.'VALUES ('.$this->dateTime.', '.$this->dateTime.', ?, ?, ?)', |
|
230 | 230 | [$userId, $destinationId, $attributeSet] |
231 | 231 | ); |
232 | 232 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function deleteConsent(string $userId, string $destinationId): int |
251 | 251 | { |
252 | 252 | $st = $this->execute( |
253 | - 'DELETE FROM ' . $this->table . ' WHERE hashed_user_id = ? AND service_id = ?;', |
|
253 | + 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ?;', |
|
254 | 254 | [$userId, $destinationId] |
255 | 255 | ); |
256 | 256 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function deleteAllConsents(string $userId): int |
279 | 279 | { |
280 | 280 | $st = $this->execute( |
281 | - 'DELETE FROM ' . $this->table . ' WHERE hashed_user_id = ?', |
|
281 | + 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ?', |
|
282 | 282 | [$userId] |
283 | 283 | ); |
284 | 284 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | if ($st->rowCount() > 0) { |
290 | - Logger::debug('consent:Database - Deleted (' . $st->rowCount() . ') consent(s) . '); |
|
290 | + Logger::debug('consent:Database - Deleted ('.$st->rowCount().') consent(s) . '); |
|
291 | 291 | return $st->rowCount(); |
292 | 292 | } |
293 | 293 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $ret = []; |
311 | 311 | |
312 | 312 | $st = $this->execute( |
313 | - 'SELECT service_id, attribute, consent_date, usage_date FROM ' . $this->table . |
|
313 | + 'SELECT service_id, attribute, consent_date, usage_date FROM '.$this->table. |
|
314 | 314 | ' WHERE hashed_user_id = ?', |
315 | 315 | [$userId] |
316 | 316 | ); |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | $st = $db->prepare($statement); |
350 | 350 | if ($st === false) { |
351 | 351 | Logger::error( |
352 | - 'consent:Database - Error preparing statement \'' . |
|
353 | - $statement . '\': ' . self::formatError($db->errorInfo()) |
|
352 | + 'consent:Database - Error preparing statement \''. |
|
353 | + $statement.'\': '.self::formatError($db->errorInfo()) |
|
354 | 354 | ); |
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | 358 | if ($st->execute($parameters) !== true) { |
359 | 359 | Logger::error( |
360 | - 'consent:Database - Error executing statement \'' . |
|
361 | - $statement . '\': ' . self::formatError($st->errorInfo()) |
|
360 | + 'consent:Database - Error executing statement \''. |
|
361 | + $statement.'\': '.self::formatError($st->errorInfo()) |
|
362 | 362 | ); |
363 | 363 | return false; |
364 | 364 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $ret = []; |
383 | 383 | |
384 | 384 | // Get total number of consents |
385 | - $st = $this->execute('SELECT COUNT(*) AS no FROM ' . $this->table, []); |
|
385 | + $st = $this->execute('SELECT COUNT(*) AS no FROM '.$this->table, []); |
|
386 | 386 | |
387 | 387 | if ($st === false) { |
388 | 388 | return []; |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | |
395 | 395 | // Get total number of users that has given consent |
396 | 396 | $st = $this->execute( |
397 | - 'SELECT COUNT(*) AS no ' . |
|
398 | - 'FROM (SELECT DISTINCT hashed_user_id FROM ' . $this->table . ' ) AS foo', |
|
397 | + 'SELECT COUNT(*) AS no '. |
|
398 | + 'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->table.' ) AS foo', |
|
399 | 399 | [] |
400 | 400 | ); |
401 | 401 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | |
410 | 410 | // Get total number of services that has been given consent to |
411 | 411 | $st = $this->execute( |
412 | - 'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM ' . $this->table . ') AS foo', |
|
412 | + 'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->table.') AS foo', |
|
413 | 413 | [] |
414 | 414 | ); |
415 | 415 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | Assert::greaterThanEq(count($error), 3); |
467 | 467 | |
468 | - return $error[0] . ' - ' . $error[2] . ' (' . $error[1] . ')'; |
|
468 | + return $error[0].' - '.$error[2].' ('.$error[1].')'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | public function selftest(): bool |
478 | 478 | { |
479 | 479 | $st = $this->execute( |
480 | - 'SELECT * FROM ' . $this->table . ' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', |
|
480 | + 'SELECT * FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', |
|
481 | 481 | ['test', 'test', 'test'] |
482 | 482 | ); |
483 | 483 |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | { |
47 | 47 | $cookieName = self::getCookieName($userId, $destinationId); |
48 | 48 | |
49 | - $data = $userId . ':' . $attributeSet . ':' . $destinationId; |
|
49 | + $data = $userId.':'.$attributeSet.':'.$destinationId; |
|
50 | 50 | |
51 | - Logger::debug('Consent cookie - Get [' . $data . ']'); |
|
51 | + Logger::debug('Consent cookie - Get ['.$data.']'); |
|
52 | 52 | |
53 | 53 | if (!array_key_exists($cookieName, $_COOKIE)) { |
54 | 54 | Logger::debug( |
55 | - 'Consent cookie - no cookie with name \'' . $cookieName . '\'.' |
|
55 | + 'Consent cookie - no cookie with name \''.$cookieName.'\'.' |
|
56 | 56 | ); |
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | if (!is_string($_COOKIE[$cookieName])) { |
60 | 60 | Logger::warning( |
61 | - 'Value of consent cookie wasn\'t a string. Was: ' . |
|
61 | + 'Value of consent cookie wasn\'t a string. Was: '. |
|
62 | 62 | var_export($_COOKIE[$cookieName], true) |
63 | 63 | ); |
64 | 64 | return false; |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | public function saveConsent(string $userId, string $destinationId, string $attributeSet): bool |
97 | 97 | { |
98 | 98 | $name = self::getCookieName($userId, $destinationId); |
99 | - $value = $userId . ':' . $attributeSet . ':' . $destinationId; |
|
99 | + $value = $userId.':'.$attributeSet.':'.$destinationId; |
|
100 | 100 | |
101 | - Logger::debug('Consent cookie - Set [' . $value . ']'); |
|
101 | + Logger::debug('Consent cookie - Set ['.$value.']'); |
|
102 | 102 | |
103 | 103 | $value = self::sign($value); |
104 | 104 | return $this->setConsentCookie($name, $value); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $tmp = explode(':', $value, 3); |
169 | 169 | if (count($tmp) !== 3) { |
170 | 170 | Logger::warning( |
171 | - 'Consent cookie with invalid value: ' . $value |
|
171 | + 'Consent cookie with invalid value: '.$value |
|
172 | 172 | ); |
173 | 173 | continue; |
174 | 174 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | $secretSalt = Utils\Config::getSecretSalt(); |
201 | 201 | |
202 | - return sha1($secretSalt . $data . $secretSalt) . ':' . $data; |
|
202 | + return sha1($secretSalt.$data.$secretSalt).':'.$data; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | private static function getCookieName(string $userId, string $destinationId): string |
245 | 245 | { |
246 | - return '\SimpleSAML\Module\consent:' . sha1($userId . ':' . $destinationId); |
|
246 | + return '\SimpleSAML\Module\consent:'.sha1($userId.':'.$destinationId); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 |
@@ -103,12 +103,12 @@ |
||
103 | 103 | $attributeSet = $state['consent:store.attributeSet']; |
104 | 104 | |
105 | 105 | Logger::debug( |
106 | - 'Consent - saveConsent() : [' . $userId . '|' . $targetedId . '|' . $attributeSet . ']' |
|
106 | + 'Consent - saveConsent() : ['.$userId.'|'.$targetedId.'|'.$attributeSet.']' |
|
107 | 107 | ); |
108 | 108 | try { |
109 | 109 | $store->saveConsent($userId, $targetedId, $attributeSet); |
110 | 110 | } catch (Exception $e) { |
111 | - Logger::error('Consent: Error writing to storage: ' . $e->getMessage()); |
|
111 | + Logger::error('Consent: Error writing to storage: '.$e->getMessage()); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | if (array_key_exists('includeValues', $config)) { |
98 | 98 | if (!is_bool($config['includeValues'])) { |
99 | 99 | throw new Error\Exception( |
100 | - 'Consent: includeValues must be boolean. ' . |
|
101 | - var_export($config['includeValues'], true) . ' given.' |
|
100 | + 'Consent: includeValues must be boolean. '. |
|
101 | + var_export($config['includeValues'], true).' given.' |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | $this->includeValues = $config['includeValues']; |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | if (array_key_exists('checked', $config)) { |
108 | 108 | if (!is_bool($config['checked'])) { |
109 | 109 | throw new Error\Exception( |
110 | - 'Consent: checked must be boolean. ' . |
|
111 | - var_export($config['checked'], true) . ' given.' |
|
110 | + 'Consent: checked must be boolean. '. |
|
111 | + var_export($config['checked'], true).' given.' |
|
112 | 112 | ); |
113 | 113 | } |
114 | 114 | $this->checked = $config['checked']; |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | if (array_key_exists('focus', $config)) { |
118 | 118 | if (!in_array($config['focus'], ['yes', 'no'], true)) { |
119 | 119 | throw new Error\Exception( |
120 | - 'Consent: focus must be a string with values `yes` or `no`. ' . |
|
121 | - var_export($config['focus'], true) . ' given.' |
|
120 | + 'Consent: focus must be a string with values `yes` or `no`. '. |
|
121 | + var_export($config['focus'], true).' given.' |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | $this->focus = $config['focus']; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | if (array_key_exists('hiddenAttributes', $config)) { |
128 | 128 | if (!is_array($config['hiddenAttributes'])) { |
129 | 129 | throw new Error\Exception( |
130 | - 'Consent: hiddenAttributes must be an array. ' . |
|
131 | - var_export($config['hiddenAttributes'], true) . ' given.' |
|
130 | + 'Consent: hiddenAttributes must be an array. '. |
|
131 | + var_export($config['hiddenAttributes'], true).' given.' |
|
132 | 132 | ); |
133 | 133 | } |
134 | 134 | $this->hiddenAttributes = $config['hiddenAttributes']; |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | if (array_key_exists('attributes.exclude', $config)) { |
138 | 138 | if (!is_array($config['attributes.exclude'])) { |
139 | 139 | throw new Error\Exception( |
140 | - 'Consent: attributes.exclude must be an array. ' . |
|
141 | - var_export($config['attributes.exclude'], true) . ' given.' |
|
140 | + 'Consent: attributes.exclude must be an array. '. |
|
141 | + var_export($config['attributes.exclude'], true).' given.' |
|
142 | 142 | ); |
143 | 143 | } |
144 | 144 | $this->noconsentattributes = $config['attributes.exclude']; |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | Logger::warning("The 'noconsentattributes' option has been deprecated in favour of 'attributes.exclude'."); |
147 | 147 | if (!is_array($config['noconsentattributes'])) { |
148 | 148 | throw new Error\Exception( |
149 | - 'Consent: noconsentattributes must be an array. ' . |
|
150 | - var_export($config['noconsentattributes'], true) . ' given.' |
|
149 | + 'Consent: noconsentattributes must be an array. '. |
|
150 | + var_export($config['noconsentattributes'], true).' given.' |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | $this->noconsentattributes = $config['noconsentattributes']; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $this->store = \SimpleSAML\Module\consent\Store::parseStoreConfig($config['store']); |
159 | 159 | } catch (Exception $e) { |
160 | 160 | Logger::error( |
161 | - 'Consent: Could not create consent storage: ' . |
|
161 | + 'Consent: Could not create consent storage: '. |
|
162 | 162 | $e->getMessage() |
163 | 163 | ); |
164 | 164 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | isset($state['Source']['consent.disable']) && |
279 | 279 | self::checkDisable($state['Source']['consent.disable'], $spEntityId) |
280 | 280 | ) { |
281 | - Logger::debug('Consent: Consent disabled for entity ' . $spEntityId . ' with IdP ' . $idpEntityId); |
|
281 | + Logger::debug('Consent: Consent disabled for entity '.$spEntityId.' with IdP '.$idpEntityId); |
|
282 | 282 | Stats::log('consent:disabled', $statsData); |
283 | 283 | return; |
284 | 284 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | isset($state['Destination']['consent.disable']) && |
287 | 287 | self::checkDisable($state['Destination']['consent.disable'], $idpEntityId) |
288 | 288 | ) { |
289 | - Logger::debug('Consent: Consent disabled for entity ' . $spEntityId . ' with IdP ' . $idpEntityId); |
|
289 | + Logger::debug('Consent: Consent disabled for entity '.$spEntityId.' with IdP '.$idpEntityId); |
|
290 | 290 | Stats::log('consent:disabled', $statsData); |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | 294 | if ($this->store !== null) { |
295 | - $source = $state['Source']['metadata-set'] . '|' . $idpEntityId; |
|
296 | - $destination = $state['Destination']['metadata-set'] . '|' . $spEntityId; |
|
295 | + $source = $state['Source']['metadata-set'].'|'.$idpEntityId; |
|
296 | + $destination = $state['Destination']['metadata-set'].'|'.$spEntityId; |
|
297 | 297 | $attributes = $state['Attributes']; |
298 | 298 | Assert::keyExists($attributes, $this->identifyingAttribute, "No attribute '%s' was found in the user's attributes."); |
299 | 299 | $userId = $attributes[$this->identifyingAttribute][0]; |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | - Logger::debug('Consent: userid: ' . $userId); |
|
309 | - Logger::debug('Consent: source: ' . $source); |
|
310 | - Logger::debug('Consent: destination: ' . $destination); |
|
308 | + Logger::debug('Consent: userid: '.$userId); |
|
309 | + Logger::debug('Consent: source: '.$source); |
|
310 | + Logger::debug('Consent: destination: '.$destination); |
|
311 | 311 | |
312 | 312 | $hashedUserId = self::getHashedUserID($userId, $source); |
313 | 313 | $targetedId = self::getTargetedID($userId, $source, $destination); |
314 | 314 | $attributeSet = self::getAttributeHash($attributes, $this->includeValues); |
315 | 315 | |
316 | 316 | Logger::debug( |
317 | - 'Consent: hasConsent() [' . $hashedUserId . '|' . $targetedId . '|' . $attributeSet . ']' |
|
317 | + 'Consent: hasConsent() ['.$hashedUserId.'|'.$targetedId.'|'.$attributeSet.']' |
|
318 | 318 | ); |
319 | 319 | |
320 | 320 | try { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $state['consent:store.destination'] = $targetedId; |
334 | 334 | $state['consent:store.attributeSet'] = $attributeSet; |
335 | 335 | } catch (\Exception $e) { |
336 | - Logger::error('Consent: Error reading from storage: ' . $e->getMessage()); |
|
336 | + Logger::error('Consent: Error reading from storage: '.$e->getMessage()); |
|
337 | 337 | Logger::stats('Consent failed'); |
338 | 338 | Stats::log('consent:failed', $statsData); |
339 | 339 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public static function getHashedUserID(string $userid, string $source): string |
376 | 376 | { |
377 | - return hash('sha1', $userid . '|' . Utils\Config::getSecretSalt() . '|' . $source); |
|
377 | + return hash('sha1', $userid.'|'.Utils\Config::getSecretSalt().'|'.$source); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public static function getTargetedID(string $userid, string $source, string $destination): string |
391 | 391 | { |
392 | - return hash('sha1', $userid . '|' . Utils\Config::getSecretSalt() . '|' . $source . '|' . $destination); |
|
392 | + return hash('sha1', $userid.'|'.Utils\Config::getSecretSalt().'|'.$source.'|'.$destination); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 |