@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
87 | 87 | $sth->execute(array($userId)); |
88 | 88 | return (false !== $sth->fetchColumn()); |
89 | - } |
|
90 | - catch (Exception $e) { |
|
89 | + } catch (Exception $e) { |
|
91 | 90 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
92 | 91 | throw ReadWriteException::fromOriginalException($e); |
93 | 92 | } |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
112 | 111 | throw new RuntimeException('User not found'); |
113 | 112 | } |
114 | - } |
|
115 | - catch (Exception $e) { |
|
113 | + } catch (Exception $e) { |
|
116 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId)); |
117 | 115 | throw ReadWriteException::fromOriginalException($e); |
118 | 116 | } |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
147 | 145 | } |
148 | 146 | $sth->execute(array($secret, $userId)); |
149 | - } |
|
150 | - catch (Exception $e) { |
|
147 | + } catch (Exception $e) { |
|
151 | 148 | $this->logger->error( |
152 | 149 | sprintf('Unable to persist user secret for user "%s" in user secret storage (PDO)', $userId), |
153 | 150 | array('exception'=>$e) |
@@ -74,7 +74,9 @@ |
||
74 | 74 | */ |
75 | 75 | public function getPath(): string |
76 | 76 | { |
77 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
77 | + if (substr($this->path, -1)!="/") { |
|
78 | + return $this->path."/"; |
|
79 | + } |
|
78 | 80 | return $this->path; |
79 | 81 | } |
80 | 82 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function createUser(string $userId, string $displayName) : void |
61 | 61 | { |
62 | 62 | $user = array("userId"=>$userId, |
63 | - "displayName"=>$displayName); |
|
63 | + "displayName"=>$displayName); |
|
64 | 64 | $this->_saveUser($userId, $user); |
65 | 65 | } |
66 | 66 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | if ($data = $this->_loadUser($userId)) { |
92 | 92 | if (isset($data["notificationType"])) { |
93 | - return $data["notificationType"]; |
|
93 | + return $data["notificationType"]; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | return ''; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | if ($data = $this->_loadUser($userId)) { |
115 | 115 | if (isset($data["notificationAddress"])) { |
116 | - return $data["notificationAddress"]; |
|
116 | + return $data["notificationAddress"]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | $this->logger->info('Unable to find notification address for user'); |
@@ -54,8 +54,8 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | $envelope = array("expire"=>$expire, |
57 | - "createdAt"=>time(), |
|
58 | - "value"=>$value); |
|
57 | + "createdAt"=>time(), |
|
58 | + "value"=>$value); |
|
59 | 59 | $filename = $this->getFilenameByKey($key); |
60 | 60 | |
61 | 61 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -21,7 +21,6 @@ |
||
21 | 21 | * |
22 | 22 | * |
23 | 23 | * Create SQL table (MySQL): |
24 | - |
|
25 | 24 | * CREATE TABLE IF NOT EXISTS tiqrstate ( |
26 | 25 | key varchar(255) PRIMARY KEY, |
27 | 26 | expire BIGINT, |
@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?'); |
81 | 81 | $sth->execute(array($key)); |
82 | 82 | return $sth->fetchColumn() !== false; |
83 | - } |
|
84 | - catch (Exception $e) { |
|
83 | + } catch (Exception $e) { |
|
85 | 84 | $this->logger->error( |
86 | 85 | sprintf('Error checking for key "%s" in PDO StateStorage', $key), |
87 | 86 | array('exception' => $e) |
@@ -103,8 +102,7 @@ discard block |
||
103 | 102 | $this->logger->notice( |
104 | 103 | sprintf("Deleted %i expired keys", $deletedRows) |
105 | 104 | ); |
106 | - } |
|
107 | - catch (Exception $e) { |
|
105 | + } catch (Exception $e) { |
|
108 | 106 | $this->logger->error( |
109 | 107 | sprintf("Deleting expired keys failed: %s", $e->getMessage()), |
110 | 108 | array('exception', $e) |
@@ -134,8 +132,7 @@ discard block |
||
134 | 132 | } |
135 | 133 | try { |
136 | 134 | $sth->execute(array(serialize($value), $expire, $key)); |
137 | - } |
|
138 | - catch (Exception $e) { |
|
135 | + } catch (Exception $e) { |
|
139 | 136 | $this->logger->error( |
140 | 137 | sprintf('Unable to store key "%s" in PDO StateStorage', $key), |
141 | 138 | array('exception' => $e) |
@@ -155,8 +152,7 @@ discard block |
||
155 | 152 | try { |
156 | 153 | $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
157 | 154 | $sth->execute(array($key)); |
158 | - } |
|
159 | - catch (Exception $e) { |
|
155 | + } catch (Exception $e) { |
|
160 | 156 | $this->logger->error( |
161 | 157 | sprintf('Error deleting key "%s" from PDO StateStorage', $key), |
162 | 158 | array('exception' => $e) |
@@ -185,8 +181,7 @@ discard block |
||
185 | 181 | try { |
186 | 182 | $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
187 | 183 | $sth->execute(array($key, time())); |
188 | - } |
|
189 | - catch (Exception $e) { |
|
184 | + } catch (Exception $e) { |
|
190 | 185 | $this->logger->error( |
191 | 186 | sprintf('Error getting value for key "%s" from PDO StateStorage', $key), |
192 | 187 | array('exception' => $e) |
@@ -36,8 +36,7 @@ |
||
36 | 36 | // response as the client calculated. |
37 | 37 | try { |
38 | 38 | $expected = OCRA::generateOCRA($this->_ocraSuite, $userSecret, "", $challenge, "", $sessionInformation, ""); |
39 | - } |
|
40 | - catch (Exception $e) { |
|
39 | + } catch (Exception $e) { |
|
41 | 40 | $this->logger->warning(sprintf('Error calculating OCRA response for user "%s"', $userId), array('exception'=>$e)); |
42 | 41 | return false; |
43 | 42 | } |
@@ -571,17 +571,17 @@ discard block |
||
571 | 571 | } |
572 | 572 | |
573 | 573 | $metadata = array("service"=> |
574 | - array("displayName" => $this->_name, |
|
575 | - "identifier" => $this->_identifier, |
|
576 | - "logoUrl" => $this->_logoUrl, |
|
577 | - "infoUrl" => $this->_infoUrl, |
|
578 | - "authenticationUrl" => $authenticationUrl, |
|
579 | - "ocraSuite" => $this->_ocraSuite, |
|
580 | - "enrollmentUrl" => $enrollmentUrl |
|
581 | - ), |
|
582 | - "identity"=> |
|
583 | - array("identifier" =>$data["userId"], |
|
584 | - "displayName"=>$data["displayName"])); |
|
574 | + array("displayName" => $this->_name, |
|
575 | + "identifier" => $this->_identifier, |
|
576 | + "logoUrl" => $this->_logoUrl, |
|
577 | + "infoUrl" => $this->_infoUrl, |
|
578 | + "authenticationUrl" => $authenticationUrl, |
|
579 | + "ocraSuite" => $this->_ocraSuite, |
|
580 | + "enrollmentUrl" => $enrollmentUrl |
|
581 | + ), |
|
582 | + "identity"=> |
|
583 | + array("identifier" =>$data["userId"], |
|
584 | + "displayName"=>$data["displayName"])); |
|
585 | 585 | |
586 | 586 | $this->_unsetStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
587 | 587 | |
@@ -611,28 +611,28 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function getEnrollmentSecret(string $enrollmentKey): string |
613 | 613 | { |
614 | - $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
615 | - if (!is_array($data)) { |
|
616 | - $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
617 | - throw new RuntimeException('enrollment key not found'); |
|
618 | - } |
|
619 | - $userId = $data["userId"] ?? NULL; |
|
620 | - $sessionId = $data["sessionId"] ?? NULL; |
|
621 | - if (!is_string($userId) || !(is_string($sessionId))) { |
|
622 | - throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
623 | - } |
|
624 | - $enrollmentData = [ |
|
625 | - "userId" => $userId, |
|
626 | - "sessionId" => $sessionId |
|
627 | - ]; |
|
628 | - $enrollmentSecret = $this->_uniqueSessionKey(); |
|
629 | - $this->_setStateValue( |
|
630 | - self::PREFIX_ENROLLMENT_SECRET, |
|
631 | - $enrollmentSecret, |
|
632 | - $enrollmentData, |
|
633 | - self::ENROLLMENT_EXPIRE |
|
634 | - ); |
|
635 | - return $enrollmentSecret; |
|
614 | + $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
615 | + if (!is_array($data)) { |
|
616 | + $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
617 | + throw new RuntimeException('enrollment key not found'); |
|
618 | + } |
|
619 | + $userId = $data["userId"] ?? NULL; |
|
620 | + $sessionId = $data["sessionId"] ?? NULL; |
|
621 | + if (!is_string($userId) || !(is_string($sessionId))) { |
|
622 | + throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
623 | + } |
|
624 | + $enrollmentData = [ |
|
625 | + "userId" => $userId, |
|
626 | + "sessionId" => $sessionId |
|
627 | + ]; |
|
628 | + $enrollmentSecret = $this->_uniqueSessionKey(); |
|
629 | + $this->_setStateValue( |
|
630 | + self::PREFIX_ENROLLMENT_SECRET, |
|
631 | + $enrollmentSecret, |
|
632 | + $enrollmentData, |
|
633 | + self::ENROLLMENT_EXPIRE |
|
634 | + ); |
|
635 | + return $enrollmentSecret; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -290,8 +290,7 @@ discard block |
||
290 | 290 | if (isset($options['ocraservice']) && $options['ocraservice']['type'] != 'tiqr') { |
291 | 291 | $options['ocraservice']['ocra.suite'] = $this->_ocraSuite; |
292 | 292 | $this->_ocraService = Tiqr_OcraService::getOcraService($options['ocraservice']['type'], $options['ocraservice'], $logger); |
293 | - } |
|
294 | - else { // Create default ocraservice |
|
293 | + } else { // Create default ocraservice |
|
295 | 294 | $this->_ocraService = Tiqr_OcraService::getOcraService('tiqr', array('ocra.suite' => $this->_ocraSuite), $logger); |
296 | 295 | } |
297 | 296 | } |
@@ -350,10 +349,11 @@ discard block |
||
350 | 349 | case 'APNS': |
351 | 350 | case 'APNS_DIRECT': |
352 | 351 | $apns_version = $this->_options['apns.version'] ?? 1; |
353 | - if ($apns_version ==2 ) |
|
354 | - $message = new Tiqr_Message_APNS2($this->_options, $this->logger); |
|
355 | - else |
|
356 | - $message = new Tiqr_Message_APNS($this->_options, $this->logger); |
|
352 | + if ($apns_version ==2 ) { |
|
353 | + $message = new Tiqr_Message_APNS2($this->_options, $this->logger); |
|
354 | + } else { |
|
355 | + $message = new Tiqr_Message_APNS($this->_options, $this->logger); |
|
356 | + } |
|
357 | 357 | break; |
358 | 358 | |
359 | 359 | case 'GCM': |
@@ -518,7 +518,9 @@ discard block |
||
518 | 518 | $sessionId = session_id(); |
519 | 519 | } |
520 | 520 | $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId); |
521 | - if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE; |
|
521 | + if (is_null($status)) { |
|
522 | + return self::ENROLLMENT_STATUS_IDLE; |
|
523 | + } |
|
522 | 524 | return $status; |
523 | 525 | } |
524 | 526 | |
@@ -875,8 +877,7 @@ discard block |
||
875 | 877 | |
876 | 878 | try { |
877 | 879 | return $this->_getStateValue("authenticated_", $sessionId); |
878 | - } |
|
879 | - catch (Exception $e) { |
|
880 | + } catch (Exception $e) { |
|
880 | 881 | $this->logger->error('getAuthenticatedUser failed', array('exception'=>$e)); |
881 | 882 | return NULL; |
882 | 883 | } |
@@ -30,13 +30,11 @@ |
||
30 | 30 | notificationtype varchar(10), |
31 | 31 | notificationaddress varchar(64) |
32 | 32 | ); |
33 | - |
|
34 | 33 | * |
35 | 34 | * In version 3.0 the format of the tmpblocktimestamp was changed from a datetime format to an integer. |
36 | 35 | * Because it holds a unix timestamp a 64-bit (8-byte) integer. To upgrade the user table to the new format use: |
37 | 36 | |
38 | 37 | ALTER TABLE user MODIFY tmpblocktimestamp BIGINT; |
39 | - |
|
40 | 38 | */ |
41 | 39 | |
42 | 40 | use Psr\Log\LoggerInterface; |
@@ -110,8 +110,7 @@ discard block |
||
110 | 110 | throw new RuntimeException('Unexpected return type'); |
111 | 111 | } |
112 | 112 | return $res; |
113 | - } |
|
114 | - catch (Exception $e) { |
|
113 | + } catch (Exception $e) { |
|
115 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
116 | 115 | throw ReadWriteException::fromOriginalException($e); |
117 | 116 | } |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | throw new RuntimeException('Unexpected return type'); |
150 | 149 | } |
151 | 150 | return (int)$res; |
152 | - } |
|
153 | - catch (Exception $e) { |
|
151 | + } catch (Exception $e) { |
|
154 | 152 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
155 | 153 | throw ReadWriteException::fromOriginalException($e); |
156 | 154 | } |
@@ -177,8 +175,7 @@ discard block |
||
177 | 175 | throw new RuntimeException('User not found'); |
178 | 176 | } |
179 | 177 | } |
180 | - } |
|
181 | - catch (Exception $e) { |
|
178 | + } catch (Exception $e) { |
|
182 | 179 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
183 | 180 | throw ReadWriteException::fromOriginalException($e); |
184 | 181 | } |
@@ -205,8 +202,7 @@ discard block |
||
205 | 202 | throw new RuntimeException('User not found'); |
206 | 203 | } |
207 | 204 | } |
208 | - } |
|
209 | - catch (Exception $e) { |
|
205 | + } catch (Exception $e) { |
|
210 | 206 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
211 | 207 | throw ReadWriteException::fromOriginalException($e); |
212 | 208 | } |
@@ -223,8 +219,7 @@ discard block |
||
223 | 219 | try { |
224 | 220 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
225 | 221 | $sth->execute(array($displayName, $userId)); |
226 | - } |
|
227 | - catch (Exception $e) { |
|
222 | + } catch (Exception $e) { |
|
228 | 223 | $this->logger->error(sprintf('Error creating user "%s"', $userId), array('exception'=>$e)); |
229 | 224 | throw new ReadWriteException('The user could not be saved in the user storage (PDO)'); |
230 | 225 | } |
@@ -239,8 +234,7 @@ discard block |
||
239 | 234 | $sth = $this->handle->prepare("SELECT userid FROM ".$this->tablename." WHERE userid = ?"); |
240 | 235 | $sth->execute(array($userId)); |
241 | 236 | return (false !== $sth->fetchColumn()); |
242 | - } |
|
243 | - catch (Exception $e) { |
|
237 | + } catch (Exception $e) { |
|
244 | 238 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
245 | 239 | throw ReadWriteException::fromOriginalException($e); |
246 | 240 | } |
@@ -28,8 +28,7 @@ |
||
28 | 28 | // Use HTTP/1.1 instead of HTTP/2 |
29 | 29 | $curl_options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; |
30 | 30 | $this->logger->notice(sprintf('Using HTTP/1.1 CURL Proxy URL: "%s" and port "%s"', $curl_options[CURLOPT_URL], $curl_options[CURLOPT_URL])); |
31 | - } |
|
32 | - else { |
|
31 | + } else { |
|
33 | 32 | $version_info = curl_version(); |
34 | 33 | if ($version_info['features'] & CURL_VERSION_HTTP2 == 0) { |
35 | 34 | throw new RuntimeException('APNS2 requires HTTP/2 support in curl'); |