Passed
Branch develop (1cdaf9)
by Pieter van der
02:50
created
library/tiqr/Tiqr/API/Client.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function setBaseURL($apiBaseURL)
27 27
     {
28
-        $this->_apiBaseURL = rtrim($apiBaseURL, '/') . '/';
28
+        $this->_apiBaseURL = rtrim($apiBaseURL, '/').'/';
29 29
     }
30 30
 
31 31
     /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     protected function callAPI($resource, $method = "GET", $data = array(), $headers = array())
79 79
     {
80 80
         $ch = curl_init();
81
-        curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL . ltrim($resource, '/'));
81
+        curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL.ltrim($resource, '/'));
82 82
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
83 83
 
84 84
         // Explicitly empty null values, because http_build_query will throw away
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
         $headerArray = array();
109 109
         foreach ($headers as $key => $value) {
110
-            $headerArray[] = $key . ': ' . $value;
110
+            $headerArray[] = $key.': '.$value;
111 111
         }
112 112
 
113 113
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage/GenericStore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public function userExists($userId)
55 55
     {
56 56
         $user = $this->_loadUser($userId, FALSE);
57
-        return (is_array($user)||is_object($user)); 
57
+        return (is_array($user) || is_object($user)); 
58 58
     }
59 59
 
60 60
     /**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         if ($data = $this->_loadUser($userId)) {
154 154
             $timestamp = $this->getTemporaryBlockTimestamp($userId);
155 155
             // if not blocked or block is expired, return false
156
-            if (!isset($data["blocked"]) || $data["blocked"]==false || (false !== $timestamp && false != $duration && (strtotime($timestamp) + $duration * 60) < time())) {
156
+            if (!isset($data["blocked"]) || $data["blocked"] == false || (false !== $timestamp && false != $duration && (strtotime($timestamp) + $duration * 60) < time())) {
157 157
                 return false;
158 158
             }
159 159
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRAWrapper_v1.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,9 @@
 block discarded – undo
107 107
     {
108 108
         // find the :QN10, -QN10, QH10 etc. bit
109 109
         $pos = stripos($ocraSuite, ":q");
110
-        if ($pos===false) $pos = stripos($ocraSuite, "-q");
110
+        if ($pos===false) {
111
+            $pos = stripos($ocraSuite, "-q");
112
+        }
111 113
         if ($pos===false) {
112 114
             // No challenge config specified. Since we only support challenge based OCRA, we fallback to default 10 digit hexadecimal.
113 115
             return array("format"=>"H", "length"=>10);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function generateSessionKey() 
65 65
     {
66
-        return bin2hex( Tiqr_Random::randomBytes(self::SESSIONKEY_SIZE) );
66
+        return bin2hex(Tiqr_Random::randomBytes(self::SESSIONKEY_SIZE));
67 67
     }
68 68
     
69 69
     /**
@@ -107,19 +107,19 @@  discard block
 block discarded – undo
107 107
     {
108 108
         // find the :QN10, -QN10, QH10 etc. bit
109 109
         $pos = stripos($ocraSuite, ":q");
110
-        if ($pos===false) $pos = stripos($ocraSuite, "-q");
111
-        if ($pos===false) {
110
+        if ($pos === false) $pos = stripos($ocraSuite, "-q");
111
+        if ($pos === false) {
112 112
             // No challenge config specified. Since we only support challenge based OCRA, we fallback to default 10 digit hexadecimal.
113 113
             return array("format"=>"H", "length"=>10);
114 114
         }
115
-        $format = substr($ocraSuite, $pos+2, 1);
115
+        $format = substr($ocraSuite, $pos + 2, 1);
116 116
         if (!in_array($format, array("N", "A", "H"))) {
117 117
             $format = "H";
118 118
         }
119 119
         
120
-        $length = (int)substr($ocraSuite, $pos+3, 2);
120
+        $length = (int) substr($ocraSuite, $pos + 3, 2);
121 121
                 
122
-        if ($length<=0) {
122
+        if ($length <= 0) {
123 123
             $length = 10;
124 124
         }
125 125
         
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     protected function _calculateResponse($ocraSuite, $secret, $challenge, $sessionKey)
192 192
     {       
193
-        if (strpos(strtolower($ocraSuite), "qn")!==false) {
193
+        if (strpos(strtolower($ocraSuite), "qn") !== false) {
194 194
             
195 195
             // challenge is decimal, but generateOcra always wants it in hex.
196 196
             $challenge = dechex($challenge);
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRA_v1.php 2 patches
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -101,12 +101,15 @@  discard block
 block discarded – undo
101 101
         $sessionInformationLength = 0;
102 102
         $timeStampLength = 0;
103 103
 
104
-        if(stripos($ocraSuite, "sha1")!==false)
105
-            $crypto = "sha1";
106
-        if(stripos($ocraSuite, "sha256")!==false)
107
-            $crypto = "sha256";
108
-        if(stripos($ocraSuite, "sha512")!==false)
109
-            $crypto = "sha512";
104
+        if(stripos($ocraSuite, "sha1")!==false) {
105
+                    $crypto = "sha1";
106
+        }
107
+        if(stripos($ocraSuite, "sha256")!==false) {
108
+                    $crypto = "sha256";
109
+        }
110
+        if(stripos($ocraSuite, "sha512")!==false) {
111
+                    $crypto = "sha512";
112
+        }
110 113
 
111 114
         // How many digits should we return
112 115
         $oS = substr($ocraSuite, strpos($ocraSuite, ":")+1, strpos($ocraSuite, ":", strpos($ocraSuite, ":")+1) -strpos($ocraSuite, ":")-1);
@@ -116,31 +119,35 @@  discard block
 block discarded – undo
116 119
         // Counter
117 120
         if(stripos($ocraSuite, ":c") !==false) {
118 121
             // Fix the length of the HEX string
119
-            while(strlen($counter) < 16)
120
-                $counter = "0" . $counter;
122
+            while(strlen($counter) < 16) {
123
+                            $counter = "0" . $counter;
124
+            }
121 125
             $counterLength=8;
122 126
         }
123 127
         // Question
124 128
         if(stripos($ocraSuite, ":q")!==false ||
125 129
                 stripos($ocraSuite, "-q")!==false) {
126
-            while(strlen($question) < 256)
127
-                $question = $question . "0";
130
+            while(strlen($question) < 256) {
131
+                            $question = $question . "0";
132
+            }
128 133
             $questionLength=128;
129 134
         }
130 135
 
131 136
         // Password
132 137
         if(stripos($ocraSuite, ":p")!==false ||
133 138
                 stripos($ocraSuite, "-p") !==false) {
134
-            while(strlen($password) < 40)
135
-                $password = "0" . $password;
139
+            while(strlen($password) < 40) {
140
+                            $password = "0" . $password;
141
+            }
136 142
             $passwordLength=20;
137 143
         }
138 144
 
139 145
         // sessionInformation
140 146
         if(stripos($ocraSuite, ":s") !==false ||
141 147
                 stripos($ocraSuite, "-s", strpos($ocraSuite, ":", strpos($ocraSuite, ":")+1)) !== false) {
142
-            while(strlen($sessionInformation) < 128)
143
-                $sessionInformation = "0" . $sessionInformation;
148
+            while(strlen($sessionInformation) < 128) {
149
+                            $sessionInformation = "0" . $sessionInformation;
150
+            }
144 151
 
145 152
             $sessionInformationLength=64;
146 153
         }
@@ -148,8 +155,9 @@  discard block
 block discarded – undo
148 155
         // TimeStamp
149 156
         if(stripos($ocraSuite, ":t") !==false ||
150 157
                 stripos($ocraSuite, "-t") !== false) {
151
-            while(strlen($timeStamp) < 16)
152
-                $timeStamp = "0" . $timeStamp;
158
+            while(strlen($timeStamp) < 16) {
159
+                            $timeStamp = "0" . $timeStamp;
160
+            }
153 161
             $timeStampLength=8;
154 162
         }
155 163
 
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             $keyBytes,
47 47
             $text)
48 48
     {
49
-         $hash = hash_hmac ($crypto, $text, $keyBytes);
49
+         $hash = hash_hmac($crypto, $text, $keyBytes);
50 50
          return $hash;
51 51
     }
52 52
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return String a string with raw bytes
59 59
      */
60
-    private static function _hexStr2Bytes($hex){
60
+    private static function _hexStr2Bytes($hex) {
61 61
         return pack("H*", $hex);
62 62
     }
63 63
 
@@ -101,63 +101,63 @@  discard block
 block discarded – undo
101 101
         $sessionInformationLength = 0;
102 102
         $timeStampLength = 0;
103 103
 
104
-        if(stripos($ocraSuite, "sha1")!==false)
104
+        if (stripos($ocraSuite, "sha1") !== false)
105 105
             $crypto = "sha1";
106
-        if(stripos($ocraSuite, "sha256")!==false)
106
+        if (stripos($ocraSuite, "sha256") !== false)
107 107
             $crypto = "sha256";
108
-        if(stripos($ocraSuite, "sha512")!==false)
108
+        if (stripos($ocraSuite, "sha512") !== false)
109 109
             $crypto = "sha512";
110 110
 
111 111
         // How many digits should we return
112
-        $oS = substr($ocraSuite, strpos($ocraSuite, ":")+1, strpos($ocraSuite, ":", strpos($ocraSuite, ":")+1) -strpos($ocraSuite, ":")-1);
113
-        $codeDigits = substr($oS, strrpos($oS, "-")+1);
112
+        $oS = substr($ocraSuite, strpos($ocraSuite, ":") + 1, strpos($ocraSuite, ":", strpos($ocraSuite, ":") + 1) - strpos($ocraSuite, ":") - 1);
113
+        $codeDigits = substr($oS, strrpos($oS, "-") + 1);
114 114
         
115 115
         // The size of the byte array message to be encrypted
116 116
         // Counter
117
-        if(stripos($ocraSuite, ":c") !==false) {
117
+        if (stripos($ocraSuite, ":c") !== false) {
118 118
             // Fix the length of the HEX string
119
-            while(strlen($counter) < 16)
120
-                $counter = "0" . $counter;
121
-            $counterLength=8;
119
+            while (strlen($counter) < 16)
120
+                $counter = "0".$counter;
121
+            $counterLength = 8;
122 122
         }
123 123
         // Question
124
-        if(stripos($ocraSuite, ":q")!==false ||
125
-                stripos($ocraSuite, "-q")!==false) {
126
-            while(strlen($question) < 256)
127
-                $question = $question . "0";
128
-            $questionLength=128;
124
+        if (stripos($ocraSuite, ":q") !== false ||
125
+                stripos($ocraSuite, "-q") !== false) {
126
+            while (strlen($question) < 256)
127
+                $question = $question."0";
128
+            $questionLength = 128;
129 129
         }
130 130
 
131 131
         // Password
132
-        if(stripos($ocraSuite, ":p")!==false ||
133
-                stripos($ocraSuite, "-p") !==false) {
134
-            while(strlen($password) < 40)
135
-                $password = "0" . $password;
136
-            $passwordLength=20;
132
+        if (stripos($ocraSuite, ":p") !== false ||
133
+                stripos($ocraSuite, "-p") !== false) {
134
+            while (strlen($password) < 40)
135
+                $password = "0".$password;
136
+            $passwordLength = 20;
137 137
         }
138 138
 
139 139
         // sessionInformation
140
-        if(stripos($ocraSuite, ":s") !==false ||
141
-                stripos($ocraSuite, "-s", strpos($ocraSuite, ":", strpos($ocraSuite, ":")+1)) !== false) {
142
-            while(strlen($sessionInformation) < 128)
143
-                $sessionInformation = "0" . $sessionInformation;
140
+        if (stripos($ocraSuite, ":s") !== false ||
141
+                stripos($ocraSuite, "-s", strpos($ocraSuite, ":", strpos($ocraSuite, ":") + 1)) !== false) {
142
+            while (strlen($sessionInformation) < 128)
143
+                $sessionInformation = "0".$sessionInformation;
144 144
 
145
-            $sessionInformationLength=64;
145
+            $sessionInformationLength = 64;
146 146
         }
147 147
              
148 148
         // TimeStamp
149
-        if(stripos($ocraSuite, ":t") !==false ||
149
+        if (stripos($ocraSuite, ":t") !== false ||
150 150
                 stripos($ocraSuite, "-t") !== false) {
151
-            while(strlen($timeStamp) < 16)
152
-                $timeStamp = "0" . $timeStamp;
153
-            $timeStampLength=8;
151
+            while (strlen($timeStamp) < 16)
152
+                $timeStamp = "0".$timeStamp;
153
+            $timeStampLength = 8;
154 154
         }
155 155
 
156 156
         // Put the bytes of "ocraSuite" parameters into the message
157 157
         
158
-        $msg = array_fill(0,$ocraSuiteLength+$counterLength+$questionLength+$passwordLength+$sessionInformationLength+$timeStampLength+1, 0);
158
+        $msg = array_fill(0, $ocraSuiteLength + $counterLength + $questionLength + $passwordLength + $sessionInformationLength + $timeStampLength + 1, 0);
159 159
                 
160
-        for($i=0;$i<strlen($ocraSuite);$i++) {
160
+        for ($i = 0; $i < strlen($ocraSuite); $i++) {
161 161
             $msg[$i] = $ocraSuite[$i];
162 162
         }
163 163
         
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 
167 167
         // Put the bytes of "Counter" to the message
168 168
         // Input is HEX encoded
169
-        if($counterLength > 0 ) {
169
+        if ($counterLength > 0) {
170 170
             $bArray = self::_hexStr2Bytes($counter);
171
-            for ($i=0;$i<strlen($bArray);$i++) {
171
+            for ($i = 0; $i < strlen($bArray); $i++) {
172 172
                 $msg [$i + $ocraSuiteLength + 1] = $bArray[$i];
173 173
             }
174 174
         }
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
 
177 177
         // Put the bytes of "question" to the message
178 178
         // Input is text encoded
179
-        if($questionLength > 0 ) {
179
+        if ($questionLength > 0) {
180 180
             $bArray = self::_hexStr2Bytes($question);
181
-            for ($i=0;$i<strlen($bArray);$i++) {
181
+            for ($i = 0; $i < strlen($bArray); $i++) {
182 182
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength] = $bArray[$i];
183 183
             }
184 184
         }
185 185
 
186 186
         // Put the bytes of "password" to the message
187 187
         // Input is HEX encoded
188
-        if($passwordLength > 0){
188
+        if ($passwordLength > 0) {
189 189
             $bArray = self::_hexStr2Bytes($password);
190
-            for ($i=0;$i<strlen($bArray);$i++) {
190
+            for ($i = 0; $i < strlen($bArray); $i++) {
191 191
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength] = $bArray[$i];
192 192
             }
193 193
         }
194 194
 
195 195
         // Put the bytes of "sessionInformation" to the message
196 196
         // Input is text encoded
197
-        if($sessionInformationLength > 0 ){
197
+        if ($sessionInformationLength > 0) {
198 198
             $bArray = self::_hexStr2Bytes($sessionInformation);
199
-            for ($i=0;$i<strlen($bArray);$i++) {
199
+            for ($i = 0; $i < strlen($bArray); $i++) {
200 200
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength + $passwordLength] = $bArray[$i];
201 201
             }
202 202
         }
203 203
 
204 204
         // Put the bytes of "time" to the message
205 205
         // Input is text value of minutes
206
-        if($timeStampLength > 0){
206
+        if ($timeStampLength > 0) {
207 207
             $bArray = self::_hexStr2Bytes($timestamp);
208
-            for ($i=0;$i<strlen($bArray);$i++) {
208
+            for ($i = 0; $i < strlen($bArray); $i++) {
209 209
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength + $passwordLength + $sessionInformationLength] = $bArray[$i];
210 210
             }
211 211
         }
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
     static function _oath_truncate($hash, $length = 6)
228 228
     {
229 229
         // Convert to dec
230
-        foreach(str_split($hash,2) as $hex)
230
+        foreach (str_split($hash, 2) as $hex)
231 231
         {
232
-            $hmac_result[]=hexdec($hex);
232
+            $hmac_result[] = hexdec($hex);
233 233
         }
234 234
     
235 235
         // Find offset
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
         // Algorithm from RFC
239 239
         return
240 240
         (
241
-            (($hmac_result[$offset+0] & 0x7f) << 24 ) |
242
-            (($hmac_result[$offset+1] & 0xff) << 16 ) |
243
-            (($hmac_result[$offset+2] & 0xff) << 8 ) |
244
-            ($hmac_result[$offset+3] & 0xff)
245
-        ) % pow(10,$length);
241
+            (($hmac_result[$offset + 0] & 0x7f) << 24) |
242
+            (($hmac_result[$offset + 1] & 0xff) << 16) |
243
+            (($hmac_result[$offset + 2] & 0xff) << 8) |
244
+            ($hmac_result[$offset + 3] & 0xff)
245
+        ) % pow(10, $length);
246 246
     }
247 247
     
248 248
 }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Service.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -453,7 +453,9 @@
 block discarded – undo
453 453
             $sessionId = session_id(); 
454 454
         }
455 455
         $status = $this->_stateStorage->getValue("enrollstatus".$sessionId);
456
-        if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE;
456
+        if (is_null($status)) {
457
+            return self::ENROLLMENT_STATUS_IDLE;
458
+        }
457 459
         return $status;
458 460
     }
459 461
         
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
     /**
75 75
      * Enrollment status codes
76 76
      */
77
-    const ENROLLMENT_STATUS_IDLE = 1;        // Nothing happens
77
+    const ENROLLMENT_STATUS_IDLE = 1; // Nothing happens
78 78
     const ENROLLMENT_STATUS_INITIALIZED = 2; // An enrollment session has begun
79
-    const ENROLLMENT_STATUS_RETRIEVED = 3;   // The device has retrieved the metadata
80
-    const ENROLLMENT_STATUS_PROCESSED = 4;   // The device has snet back a secret
81
-    const ENROLLMENT_STATUS_FINALIZED = 5;   // The application has stored the secret
82
-    const ENROLLMENT_STATUS_VALIDATED = 6;   // A first succesful authentication was performed
79
+    const ENROLLMENT_STATUS_RETRIEVED = 3; // The device has retrieved the metadata
80
+    const ENROLLMENT_STATUS_PROCESSED = 4; // The device has snet back a secret
81
+    const ENROLLMENT_STATUS_FINALIZED = 5; // The application has stored the secret
82
+    const ENROLLMENT_STATUS_VALIDATED = 6; // A first succesful authentication was performed
83 83
 
84 84
     const PREFIX_ENROLLMENT_SECRET = 'enrollsecret';
85 85
     const PREFIX_ENROLLMENT = 'enroll';
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      * @param array $options
159 159
      * @param int $version The protocol version to use (defaults to the latest)
160 160
      */
161
-    public function __construct(LoggerInterface $logger, $options=array(), $version = 2)
161
+    public function __construct(LoggerInterface $logger, $options = array(), $version = 2)
162 162
     {
163 163
         $this->_options = $options;
164 164
         $this->logger = $logger;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
             $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType));
313 313
             $message->setId(time());
314
-            $message->setText("Please authenticate for " . $this->_name);
314
+            $message->setText("Please authenticate for ".$this->_name);
315 315
             $message->setAddress($notificationAddress);
316 316
             $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey));
317 317
             $message->send();
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
      * @param String $spIdentifier If SP and IDP are 2 different things, pass the url/identifier of the SP the user is logging into.
381 381
      *                             For setups where IDP==SP, just leave this blank.
382 382
      */
383
-    public function startAuthenticationSession($userId="", $sessionId="", $spIdentifier="")
383
+    public function startAuthenticationSession($userId = "", $sessionId = "", $spIdentifier = "")
384 384
     {
385
-        if ($sessionId=="") {
385
+        if ($sessionId == "") {
386 386
             $sessionId = session_id();
387 387
         }
388 388
 
389
-        if ($spIdentifier=="") {
389
+        if ($spIdentifier == "") {
390 390
             $spIdentifier = $this->_identifier;
391 391
         }
392 392
 
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
         
397 397
         $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier);
398 398
         
399
-        if ($userId!="") {
399
+        if ($userId != "") {
400 400
             $data["userId"] = $userId;
401 401
         }
402 402
         
403
-        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE);
403
+        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE);
404 404
        
405 405
         return $sessionKey;
406 406
     }
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
      *                           to php session)
421 421
      * @return String The enrollment key
422 422
      */
423
-    public function startEnrollmentSession($userId, $displayName, $sessionId="")
423
+    public function startEnrollmentSession($userId, $displayName, $sessionId = "")
424 424
     {
425
-        if ($sessionId=="") {
425
+        if ($sessionId == "") {
426 426
             $sessionId = session_id();
427 427
         }
428 428
         $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT);
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             "displayName" => $displayName,
432 432
             "sessionId" => $sessionId
433 433
         ];
434
-        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
434
+        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
435 435
         $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED);
436 436
 
437 437
         return $enrollmentKey;
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
      * @param $sessionId The application's session identifier (defaults
443 443
      *                   to php session)
444 444
      */
445
-    public function resetEnrollmentSession($sessionId="")
445
+    public function resetEnrollmentSession($sessionId = "")
446 446
     {
447
-        if ($sessionId=="") {
447
+        if ($sessionId == "") {
448 448
             $sessionId = session_id();
449 449
         }
450 450
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
      *               A first successful authentication was performed 
490 490
      *               (todo: currently not used)
491 491
      */
492
-    public function getEnrollmentStatus($sessionId="")
492
+    public function getEnrollmentStatus($sessionId = "")
493 493
     { 
494
-        if ($sessionId=="") {
494
+        if ($sessionId == "") {
495 495
             $sessionId = session_id(); 
496 496
         }
497 497
         $status = $this->_stateStorage->getValue("enrollstatus".$sessionId);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
      */
551 551
     public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl)
552 552
     {
553
-        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
553
+        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
554 554
         if (!is_array($data)) {
555 555
             $this->logger->error('Unable to find enrollment metadata in state storage');
556 556
             return false;
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                                array("identifier" =>$data["userId"],
570 570
                                      "displayName"=>$data["displayName"]));
571 571
 
572
-        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
572
+        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
573 573
 
574 574
         $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED);
575 575
         return $metadata;
@@ -590,14 +590,14 @@  discard block
 block discarded – undo
590 590
      */
591 591
     public function getEnrollmentSecret($enrollmentKey)
592 592
     {
593
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
593
+         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
594 594
          $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
595 595
          $enrollmentData = [
596 596
              "userId" => $data["userId"],
597 597
              "sessionId" => $data["sessionId"]
598 598
          ];
599 599
          $this->_stateStorage->setValue(
600
-             self::PREFIX_ENROLLMENT_SECRET . $secret,
600
+             self::PREFIX_ENROLLMENT_SECRET.$secret,
601 601
              $enrollmentData,
602 602
              self::ENROLLMENT_EXPIRE
603 603
          );
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
              $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
648 648
          } else {
649 649
              $this->logger->error(
650
-                 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
650
+                 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '.
651 651
                  'Warning! the method will still return "true" as a result.'
652 652
              );
653 653
          }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      */
678 678
     public function authenticate($userId, $userSecret, $sessionKey, $response)
679 679
     {
680
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
680
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
681 681
         if (is_null($state)) {
682 682
             $this->logger->info('The auth challenge could not be found in the state storage');
683 683
             return self::AUTH_RESULT_INVALID_CHALLENGE;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
           $challengeUserId = $state["userId"];
692 692
         }
693 693
         // Check if we're dealing with a second factor
694
-        if ($challengeUserId!=NULL && ($userId != $challengeUserId)) {
694
+        if ($challengeUserId != NULL && ($userId != $challengeUserId)) {
695 695
             $this->logger->error(
696 696
                 'Authentication failed: the first factor user id does not match with that of the second factor'
697 697
             );
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
             $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE);
710 710
             
711 711
             // Clean up the challenge.
712
-            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey);
712
+            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey);
713 713
             $this->logger->info('Authentication succeeded');
714 714
             return self::AUTH_RESULT_AUTHENTICATED;
715 715
         }
@@ -722,9 +722,9 @@  discard block
 block discarded – undo
722 722
      * @param String $sessionId The application's session identifier (defaults
723 723
      *                          to the php session).
724 724
      */
725
-    public function logout($sessionId="")
725
+    public function logout($sessionId = "")
726 726
     {
727
-        if ($sessionId=="") {
727
+        if ($sessionId == "") {
728 728
             $sessionId = session_id(); 
729 729
         }
730 730
         
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
      * @return mixed An array with user data if a user was logged in or NULL if
760 760
      *               no user is logged in.
761 761
      */
762
-    public function getAuthenticatedUser($sessionId="")
762
+    public function getAuthenticatedUser($sessionId = "")
763 763
     {
764
-        if ($sessionId=="") {
764
+        if ($sessionId == "") {
765 765
             $this->logger->debug('Using the PHP session id, as no session id was provided');
766 766
             $sessionId = session_id(); 
767 767
         }
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
      */
781 781
     protected function _getChallengeUrl($sessionKey)
782 782
     {                
783
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
783
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
784 784
         if (is_null($state)) {
785 785
             $this->logger->error(
786 786
                 'Unable find an existing challenge url in the state storage based on the existing session key'
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
             return false;
789 789
         }
790 790
         
791
-        $userId   = NULL;
791
+        $userId = NULL;
792 792
         $challenge = $state["challenge"];
793 793
         if (isset($state["userId"])) {
794 794
             $userId = $state["userId"];
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         $spIdentifier = $state["spIdentifier"];
797 797
         
798 798
         // Last bit is the spIdentifier
799
-        return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
799
+        return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
800 800
     }
801 801
 
802 802
     /**
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
     protected function _uniqueSessionKey($prefix)
821 821
     {      
822 822
         $value = 1;
823
-        while ($value!=NULL) {
823
+        while ($value != NULL) {
824 824
             $sessionKey = $this->_ocraWrapper->generateSessionKey();
825 825
             $value = $this->_stateStorage->getValue($prefix.$sessionKey);
826 826
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Message/Exception/MismatchSenderId.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * @param boolean   $temporary  temporary failure?
36 36
      * @param Exception $parent     parent exception
37 37
      */
38
-    public function __construct($message, $temporary=false, Exception $parent=null)
38
+    public function __construct($message, $temporary = false, Exception $parent = null)
39 39
     {
40 40
         parent::__construct($message, $parent);
41 41
         $this->_temporary = $temporary;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Message/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
      * @param string    $message    exception message
30 30
      * @param Exception $parent     parent exception
31 31
      */
32
-     public function __construct($message, $parent=null)
32
+     public function __construct($message, $parent = null)
33 33
      {
34 34
          parent::__construct($message, 0, $parent);
35 35
      }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Message/Exception/SendFailure.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * @param boolean   $temporary  temporary failure?
36 36
      * @param Exception $parent     parent exception
37 37
      */
38
-    public function __construct($message, $temporary=false, Exception $parent=null)
38
+    public function __construct($message, $temporary = false, Exception $parent = null)
39 39
     {
40 40
         parent::__construct($message, $parent);
41 41
         $this->_temporary = $temporary;
Please login to merge, or discard this patch.
library/tiqr/OATH/OCRAParser.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once ( __DIR__ . "/../Tiqr/Random.php");
3
+require_once (__DIR__."/../Tiqr/Random.php");
4 4
 
5 5
 class OATH_OCRAParser {
6 6
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	private function parseOCRASuite($ocraSuite) {
45 45
 		if (!is_string($ocraSuite)) {
46
-			throw new Exception('OCRASuite not in string format: ' . var_export($ocraSuite, TRUE));
46
+			throw new Exception('OCRASuite not in string format: '.var_export($ocraSuite, TRUE));
47 47
 		}
48 48
 
49 49
 		$ocraSuite = strtoupper($ocraSuite);
@@ -51,54 +51,54 @@  discard block
 block discarded – undo
51 51
 
52 52
 		$s = explode(':', $ocraSuite);
53 53
 		if (count($s) != 3) {
54
-			throw new Exception('Invalid OCRASuite format: ' . var_export($ocraSuite, TRUE));
54
+			throw new Exception('Invalid OCRASuite format: '.var_export($ocraSuite, TRUE));
55 55
 		}
56 56
 
57 57
 		$algo = explode('-', $s[0]);
58 58
 		if (count($algo) != 2) {
59
-			throw new Exception('Invalid OCRA version: ' . var_export($s[0], TRUE));
59
+			throw new Exception('Invalid OCRA version: '.var_export($s[0], TRUE));
60 60
 		}
61 61
 
62 62
 		if ($algo[0] !== 'OCRA') {
63
-			throw new Exception('Unsupported OCRA algorithm: ' . var_export($algo[0], TRUE));
63
+			throw new Exception('Unsupported OCRA algorithm: '.var_export($algo[0], TRUE));
64 64
 		}
65 65
 
66 66
 		if ($algo[1] !== '1') {
67
-			throw new Exception('Unsupported OCRA version: ' . var_export($algo[1], TRUE));
67
+			throw new Exception('Unsupported OCRA version: '.var_export($algo[1], TRUE));
68 68
 		}
69 69
 		$this->OCRAVersion = $algo[1];
70 70
 
71 71
 		$cf = explode('-', $s[1]);
72 72
 		if (count($cf) != 3) {
73
-			throw new Exception('Invalid OCRA suite crypto function: ' . var_export($s[1], TRUE));
73
+			throw new Exception('Invalid OCRA suite crypto function: '.var_export($s[1], TRUE));
74 74
 		}
75 75
 
76 76
 		if ($cf[0] !== 'HOTP') {
77
-			throw new Exception('Unsupported OCRA suite crypto function: ' . var_export($cf[0], TRUE));
77
+			throw new Exception('Unsupported OCRA suite crypto function: '.var_export($cf[0], TRUE));
78 78
 		}
79 79
 		$this->CryptoFunctionType = $cf[0];
80 80
 
81 81
 		if (!array_key_exists($cf[1], $this->supportedHashFunctions)) {
82
-			throw new Exception('Unsupported hash function in OCRA suite crypto function: ' . var_export($cf[1], TRUE));
82
+			throw new Exception('Unsupported hash function in OCRA suite crypto function: '.var_export($cf[1], TRUE));
83 83
 		}
84 84
 		$this->CryptoFunctionHash = $cf[1];
85 85
 		$this->CryptoFunctionHashLength = $this->supportedHashFunctions[$cf[1]];
86 86
 
87 87
 		if (!preg_match('/^\d+$/', $cf[2]) || (($cf[2] < 4 || $cf[2] > 10) && $cf[2] != 0)) {
88
-			throw new Exception('Invalid OCRA suite crypto function truncation length: ' . var_export($cf[2], TRUE));
88
+			throw new Exception('Invalid OCRA suite crypto function truncation length: '.var_export($cf[2], TRUE));
89 89
 		}
90 90
 		$this->CryptoFunctionTruncation = intval($cf[2]);
91 91
 
92 92
 		$di = explode('-', $s[2]);
93 93
 		if (count($cf) == 0) {
94
-			throw new Exception('Invalid OCRA suite data input: ' . var_export($s[2], TRUE));
94
+			throw new Exception('Invalid OCRA suite data input: '.var_export($s[2], TRUE));
95 95
 		}
96 96
 
97 97
 		$data_input = array();
98
-		foreach($di as $elem) {
98
+		foreach ($di as $elem) {
99 99
 			$letter = $elem[0];
100 100
 			if (array_key_exists($letter, $data_input)) {
101
-				throw new Exception('Duplicate field in OCRA suite data input: ' . var_export($elem, TRUE));
101
+				throw new Exception('Duplicate field in OCRA suite data input: '.var_export($elem, TRUE));
102 102
 			}
103 103
 			$data_input[$letter] = 1;
104 104
 
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 				} elseif (preg_match('/^Q([AHN])(\d+)$/', $elem, $match)) {
111 111
 					$q_len = intval($match[2]);
112 112
 					if ($q_len < 4 || $q_len > 64) {
113
-						throw new Exception('Invalid OCRA suite data input question length: ' . var_export($q_len, TRUE));
113
+						throw new Exception('Invalid OCRA suite data input question length: '.var_export($q_len, TRUE));
114 114
 					}
115 115
 					$this->Q = TRUE;
116 116
 					$this->QType = $match[1];
117 117
 					$this->QLength = $q_len;
118 118
 				} else {
119
-					throw new Exception('Invalid OCRA suite data input question: ' . var_export($elem, TRUE));
119
+					throw new Exception('Invalid OCRA suite data input question: '.var_export($elem, TRUE));
120 120
 				}
121 121
 			} elseif ($letter === 'P') {
122 122
 				if (strlen($elem) == 1) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				} else {
125 125
 					$p_algo = substr($elem, 1);
126 126
 					if (!array_key_exists($p_algo, $this->supportedHashFunctions)) {
127
-						throw new Exception('Unsupported OCRA suite PIN hash function: ' . var_export($elem, TRUE));
127
+						throw new Exception('Unsupported OCRA suite PIN hash function: '.var_export($elem, TRUE));
128 128
 					}
129 129
 					$this->P = TRUE;
130 130
 					$this->PType = $p_algo;
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 				} elseif (preg_match('/^S(\d+)$/', $elem, $match)) {
137 137
 					$s_len = intval($match[1]);
138 138
 					if ($s_len <= 0 || $s_len > 512) {
139
-						throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($s_len, TRUE));
139
+						throw new Exception('Invalid OCRA suite data input session information length: '.var_export($s_len, TRUE));
140 140
 					}
141 141
 
142 142
 					$this->S = TRUE;
143 143
 					$this->SLength = $s_len;
144 144
 				} else {
145
-					throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($elem, TRUE));
145
+					throw new Exception('Invalid OCRA suite data input session information length: '.var_export($elem, TRUE));
146 146
 				}
147 147
 			} elseif ($letter === 'T') {
148 148
 				if (strlen($elem) == 1) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 					preg_match_all('/(\d+)([HMS])/', $elem, $match);
152 152
 
153 153
 					if (count($match[1]) !== count(array_unique($match[2]))) {
154
-						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: ' . var_export($elem, TRUE));
154
+						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: '.var_export($elem, TRUE));
155 155
 					}
156 156
 
157 157
 					$length = 0;
@@ -159,21 +159,21 @@  discard block
 block discarded – undo
159 159
 						$length += intval($match[1][$i]) * $this->TPeriods[$match[2][$i]];
160 160
 					}
161 161
 					if ($length <= 0) {
162
-						throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
162
+						throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
163 163
 					}
164 164
 
165 165
 					$this->T = TRUE;
166 166
 					$this->TLength = $length;
167 167
 				} else {
168
-					throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
168
+					throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
169 169
 				}
170 170
 			} else {
171
-				throw new Exception('Unsupported OCRA suite data input field: ' . var_export($elem, TRUE));
171
+				throw new Exception('Unsupported OCRA suite data input field: '.var_export($elem, TRUE));
172 172
 			}
173 173
 		}
174 174
 
175 175
 		if (!$this->Q) {
176
-			throw new Exception('OCRA suite data input question not defined: ' . var_export($s[2], TRUE));
176
+			throw new Exception('OCRA suite data input question not defined: '.var_export($s[2], TRUE));
177 177
 		}
178 178
 	}
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
         $bytes = Tiqr_Random::randomBytes($q_length);
185 185
 
186
-		switch($q_type) {
186
+		switch ($q_type) {
187 187
 			case 'A':
188 188
 				$challenge = base64_encode($bytes);
189 189
 				$tr = implode("", unpack('H*', $bytes));
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				$challenge = implode("", unpack('N*', $bytes));
197 197
 				break;
198 198
 			default:
199
-				throw new Exception('Unsupported OCRASuite challenge type: ' . var_export($q_type, TRUE));
199
+				throw new Exception('Unsupported OCRASuite challenge type: '.var_export($q_type, TRUE));
200 200
 				break;
201 201
 		}
202 202
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
 	public function generateSessionInformation() {
210 210
 		if (!$this->S) {
211
-			throw new Exception('Session information not defined in OCRASuite: ' . var_export($this->OCRASuite, TRUE));
211
+			throw new Exception('Session information not defined in OCRASuite: '.var_export($this->OCRASuite, TRUE));
212 212
 		}
213 213
 
214 214
 		$s_length = $this->SLength;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			$result &= ($s1[$i] == $s2[$i]);
239 239
 		}
240 240
 
241
-		return (boolean)$result;
241
+		return (boolean) $result;
242 242
 	}
243 243
 
244 244
 }
Please login to merge, or discard this patch.