Test Failed
Push — develop ( c83d6c...a27d56 )
by Michiel
03:12
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 2 patches
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.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function createUser($userId, $displayName) 
44 44
     {
45 45
         $user = array("userId"=>$userId,
46
-                      "displayName"=>$displayName);
46
+                        "displayName"=>$displayName);
47 47
         return $this->_saveUser($userId, $user);
48 48
     }
49 49
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         if ($data = $this->_loadUser($userId)) {
79 79
             if (isset($data["notificationType"])) {
80
-               return $data["notificationType"];
80
+                return $data["notificationType"];
81 81
             }
82 82
         }
83 83
         return NULL;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         if ($data = $this->_loadUser($userId)) {
104 104
             if (isset($data["notificationAddress"])) {
105
-               return $data["notificationAddress"];
105
+                return $data["notificationAddress"];
106 106
             }
107 107
         }
108 108
         $this->logger->info('Unable to find notification address for user');
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRAWrapper_v1.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@
 block discarded – undo
90 90
      */
91 91
     public function verifyResponse($response, $secret, $challenge, $sessionKey)
92 92
     {
93
-         $expected = $this->calculateResponse($secret, $challenge, $sessionKey);
93
+            $expected = $this->calculateResponse($secret, $challenge, $sessionKey);
94 94
 
95
-         return ($expected == $response);
95
+            return ($expected == $response);
96 96
     }
97 97
 
98 98
     /**
Please login to merge, or discard this patch.
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 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
             $keyBytes,
47 47
             $text)
48 48
     {
49
-         $hash = hash_hmac ($crypto, $text, $keyBytes);
50
-         return $hash;
49
+            $hash = hash_hmac ($crypto, $text, $keyBytes);
50
+            return $hash;
51 51
     }
52 52
 
53 53
     /**
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
      * {@link truncationDigits} digits
84 84
      */
85 85
     static function generateOCRA($ocraSuite,
86
-                                 $key,
87
-                                 $counter,
88
-                                 $question,
89
-                                 $password,
90
-                                 $sessionInformation,
91
-                                 $timeStamp)
86
+                                    $key,
87
+                                    $counter,
88
+                                    $question,
89
+                                    $password,
90
+                                    $sessionInformation,
91
+                                    $timeStamp)
92 92
     {
93 93
         $codeDigits = 0;
94 94
         $crypto = "";
Please login to merge, or discard this patch.
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/OATH/OCRA.php 3 patches
Braces   +42 added lines, -28 removed lines patch added patch discarded remove patch
@@ -97,12 +97,15 @@  discard block
 block discarded – undo
97 97
         $cryptoFunction = $components[1];
98 98
         $dataInput = strtolower($components[2]); // lower here so we can do case insensitive comparisons
99 99
         
100
-        if(stripos($cryptoFunction, "sha1")!==false)
101
-            $crypto = "sha1";
102
-        if(stripos($cryptoFunction, "sha256")!==false)
103
-            $crypto = "sha256";
104
-        if(stripos($cryptoFunction, "sha512")!==false)
105
-            $crypto = "sha512";
100
+        if(stripos($cryptoFunction, "sha1")!==false) {
101
+                    $crypto = "sha1";
102
+        }
103
+        if(stripos($cryptoFunction, "sha256")!==false) {
104
+                    $crypto = "sha256";
105
+        }
106
+        if(stripos($cryptoFunction, "sha512")!==false) {
107
+                    $crypto = "sha512";
108
+        }
106 109
         
107 110
         $codeDigits = substr($cryptoFunction, strrpos($cryptoFunction, "-")+1);
108 111
                 
@@ -110,63 +113,73 @@  discard block
 block discarded – undo
110 113
         // Counter
111 114
         if($dataInput[0] == "c" ) {
112 115
             // Fix the length of the HEX string
113
-            while(strlen($counter) < 16)
114
-                $counter = "0" . $counter;
116
+            while(strlen($counter) < 16) {
117
+                            $counter = "0" . $counter;
118
+            }
115 119
             $counterLength=8;
116 120
         }
117 121
         // Question
118 122
         if($dataInput[0] == "q" ||
119 123
                 stripos($dataInput, "-q")!==false) {
120
-            while(strlen($question) < 256)
121
-                $question = $question . "0";
124
+            while(strlen($question) < 256) {
125
+                            $question = $question . "0";
126
+            }
122 127
             $questionLength=128;
123 128
         }
124 129
 
125 130
         // Password
126 131
         if(stripos($dataInput, "psha1")!==false) {
127
-            while(strlen($password) < 40)
128
-                $password = "0" . $password;
132
+            while(strlen($password) < 40) {
133
+                            $password = "0" . $password;
134
+            }
129 135
             $passwordLength=20;
130 136
         }
131 137
     
132 138
         if(stripos($dataInput, "psha256")!==false) {
133
-            while(strlen($password) < 64)
134
-                $password = "0" . $password;
139
+            while(strlen($password) < 64) {
140
+                            $password = "0" . $password;
141
+            }
135 142
             $passwordLength=32;
136 143
         }
137 144
         
138 145
         if(stripos($dataInput, "psha512")!==false) {
139
-            while(strlen($password) < 128)
140
-                $password = "0" . $password;
146
+            while(strlen($password) < 128) {
147
+                            $password = "0" . $password;
148
+            }
141 149
             $passwordLength=64;
142 150
         }
143 151
         
144 152
         // sessionInformation
145 153
         if(stripos($dataInput, "s064") !==false) {
146
-            while(strlen($sessionInformation) < 128)
147
-                $sessionInformation = "0" . $sessionInformation;
154
+            while(strlen($sessionInformation) < 128) {
155
+                            $sessionInformation = "0" . $sessionInformation;
156
+            }
148 157
 
149 158
             $sessionInformationLength=64;
150 159
         } else if(stripos($dataInput, "s128") !==false) {
151
-            while(strlen($sessionInformation) < 256)
152
-                $sessionInformation = "0" . $sessionInformation;
160
+            while(strlen($sessionInformation) < 256) {
161
+                            $sessionInformation = "0" . $sessionInformation;
162
+            }
153 163
         
154 164
             $sessionInformationLength=128;
155 165
         } else if(stripos($dataInput, "s256") !==false) {
156
-            while(strlen($sessionInformation) < 512)
157
-                $sessionInformation = "0" . $sessionInformation;
166
+            while(strlen($sessionInformation) < 512) {
167
+                            $sessionInformation = "0" . $sessionInformation;
168
+            }
158 169
         
159 170
             $sessionInformationLength=256;
160 171
         } else if(stripos($dataInput, "s512") !==false) {
161
-            while(strlen($sessionInformation) < 128)
162
-                $sessionInformation = "0" . $sessionInformation;
172
+            while(strlen($sessionInformation) < 128) {
173
+                            $sessionInformation = "0" . $sessionInformation;
174
+            }
163 175
         
164 176
             $sessionInformationLength=64;
165 177
         } else if (stripos($dataInput, "s") !== false ) {
166 178
             // deviation from spec. Officially 's' without a length indicator is not in the reference implementation.
167 179
             // RFC is ambigious. However we have supported this in Tiqr since day 1, so we continue to support it.
168
-            while(strlen($sessionInformation) < 128)
169
-                $sessionInformation = "0" . $sessionInformation;
180
+            while(strlen($sessionInformation) < 128) {
181
+                            $sessionInformation = "0" . $sessionInformation;
182
+            }
170 183
             
171 184
             $sessionInformationLength=64;
172 185
         }
@@ -176,8 +189,9 @@  discard block
 block discarded – undo
176 189
         // TimeStamp
177 190
         if($dataInput[0] == "t" ||
178 191
                 stripos($dataInput, "-t") !== false) {
179
-            while(strlen($timeStamp) < 16)
180
-                $timeStamp = "0" . $timeStamp;
192
+            while(strlen($timeStamp) < 16) {
193
+                            $timeStamp = "0" . $timeStamp;
194
+            }
181 195
             $timeStampLength=8;
182 196
         }
183 197
 
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
             $keyBytes,
47 47
             $text)
48 48
     {
49
-         $hash = hash_hmac ($crypto, $text, $keyBytes);
50
-         return $hash;
49
+            $hash = hash_hmac ($crypto, $text, $keyBytes);
50
+            return $hash;
51 51
     }
52 52
 
53 53
     /**
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
      * {@link truncationDigits} digits
84 84
      */
85 85
     static function generateOCRA($ocraSuite,
86
-                                 $key,
87
-                                 $counter,
88
-                                 $question,
89
-                                 $password,
90
-                                 $sessionInformation,
91
-                                 $timeStamp)
86
+                                    $key,
87
+                                    $counter,
88
+                                    $question,
89
+                                    $password,
90
+                                    $sessionInformation,
91
+                                    $timeStamp)
92 92
     {
93 93
         $codeDigits = 0;
94 94
         $crypto = "";
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $keyBytes,
38 38
             $text)
39 39
     {
40
-         $hash = hash_hmac ($crypto, $text, $keyBytes);
40
+         $hash = hash_hmac($crypto, $text, $keyBytes);
41 41
          return $hash;
42 42
     }
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return String a string with raw bytes
50 50
      */
51
-    private static function _hexStr2Bytes($hex){
51
+    private static function _hexStr2Bytes($hex) {
52 52
         return pack("H*", $hex);
53 53
     }
54 54
 
@@ -97,95 +97,95 @@  discard block
 block discarded – undo
97 97
         $cryptoFunction = $components[1];
98 98
         $dataInput = strtolower($components[2]); // lower here so we can do case insensitive comparisons
99 99
         
100
-        if(stripos($cryptoFunction, "sha1")!==false)
100
+        if (stripos($cryptoFunction, "sha1") !== false)
101 101
             $crypto = "sha1";
102
-        if(stripos($cryptoFunction, "sha256")!==false)
102
+        if (stripos($cryptoFunction, "sha256") !== false)
103 103
             $crypto = "sha256";
104
-        if(stripos($cryptoFunction, "sha512")!==false)
104
+        if (stripos($cryptoFunction, "sha512") !== false)
105 105
             $crypto = "sha512";
106 106
         
107
-        $codeDigits = substr($cryptoFunction, strrpos($cryptoFunction, "-")+1);
107
+        $codeDigits = substr($cryptoFunction, strrpos($cryptoFunction, "-") + 1);
108 108
                 
109 109
         // The size of the byte array message to be encrypted
110 110
         // Counter
111
-        if($dataInput[0] == "c" ) {
111
+        if ($dataInput[0] == "c") {
112 112
             // Fix the length of the HEX string
113
-            while(strlen($counter) < 16)
114
-                $counter = "0" . $counter;
115
-            $counterLength=8;
113
+            while (strlen($counter) < 16)
114
+                $counter = "0".$counter;
115
+            $counterLength = 8;
116 116
         }
117 117
         // Question
118
-        if($dataInput[0] == "q" ||
119
-                stripos($dataInput, "-q")!==false) {
120
-            while(strlen($question) < 256)
121
-                $question = $question . "0";
122
-            $questionLength=128;
118
+        if ($dataInput[0] == "q" ||
119
+                stripos($dataInput, "-q") !== false) {
120
+            while (strlen($question) < 256)
121
+                $question = $question."0";
122
+            $questionLength = 128;
123 123
         }
124 124
 
125 125
         // Password
126
-        if(stripos($dataInput, "psha1")!==false) {
127
-            while(strlen($password) < 40)
128
-                $password = "0" . $password;
129
-            $passwordLength=20;
126
+        if (stripos($dataInput, "psha1") !== false) {
127
+            while (strlen($password) < 40)
128
+                $password = "0".$password;
129
+            $passwordLength = 20;
130 130
         }
131 131
     
132
-        if(stripos($dataInput, "psha256")!==false) {
133
-            while(strlen($password) < 64)
134
-                $password = "0" . $password;
135
-            $passwordLength=32;
132
+        if (stripos($dataInput, "psha256") !== false) {
133
+            while (strlen($password) < 64)
134
+                $password = "0".$password;
135
+            $passwordLength = 32;
136 136
         }
137 137
         
138
-        if(stripos($dataInput, "psha512")!==false) {
139
-            while(strlen($password) < 128)
140
-                $password = "0" . $password;
141
-            $passwordLength=64;
138
+        if (stripos($dataInput, "psha512") !== false) {
139
+            while (strlen($password) < 128)
140
+                $password = "0".$password;
141
+            $passwordLength = 64;
142 142
         }
143 143
         
144 144
         // sessionInformation
145
-        if(stripos($dataInput, "s064") !==false) {
146
-            while(strlen($sessionInformation) < 128)
147
-                $sessionInformation = "0" . $sessionInformation;
145
+        if (stripos($dataInput, "s064") !== false) {
146
+            while (strlen($sessionInformation) < 128)
147
+                $sessionInformation = "0".$sessionInformation;
148 148
 
149
-            $sessionInformationLength=64;
150
-        } else if(stripos($dataInput, "s128") !==false) {
151
-            while(strlen($sessionInformation) < 256)
152
-                $sessionInformation = "0" . $sessionInformation;
149
+            $sessionInformationLength = 64;
150
+        } else if (stripos($dataInput, "s128") !== false) {
151
+            while (strlen($sessionInformation) < 256)
152
+                $sessionInformation = "0".$sessionInformation;
153 153
         
154
-            $sessionInformationLength=128;
155
-        } else if(stripos($dataInput, "s256") !==false) {
156
-            while(strlen($sessionInformation) < 512)
157
-                $sessionInformation = "0" . $sessionInformation;
154
+            $sessionInformationLength = 128;
155
+        } else if (stripos($dataInput, "s256") !== false) {
156
+            while (strlen($sessionInformation) < 512)
157
+                $sessionInformation = "0".$sessionInformation;
158 158
         
159
-            $sessionInformationLength=256;
160
-        } else if(stripos($dataInput, "s512") !==false) {
161
-            while(strlen($sessionInformation) < 128)
162
-                $sessionInformation = "0" . $sessionInformation;
159
+            $sessionInformationLength = 256;
160
+        } else if (stripos($dataInput, "s512") !== false) {
161
+            while (strlen($sessionInformation) < 128)
162
+                $sessionInformation = "0".$sessionInformation;
163 163
         
164
-            $sessionInformationLength=64;
165
-        } else if (stripos($dataInput, "s") !== false ) {
164
+            $sessionInformationLength = 64;
165
+        } else if (stripos($dataInput, "s") !== false) {
166 166
             // deviation from spec. Officially 's' without a length indicator is not in the reference implementation.
167 167
             // RFC is ambigious. However we have supported this in Tiqr since day 1, so we continue to support it.
168
-            while(strlen($sessionInformation) < 128)
169
-                $sessionInformation = "0" . $sessionInformation;
168
+            while (strlen($sessionInformation) < 128)
169
+                $sessionInformation = "0".$sessionInformation;
170 170
             
171
-            $sessionInformationLength=64;
171
+            $sessionInformationLength = 64;
172 172
         }
173 173
         
174 174
         
175 175
              
176 176
         // TimeStamp
177
-        if($dataInput[0] == "t" ||
177
+        if ($dataInput[0] == "t" ||
178 178
                 stripos($dataInput, "-t") !== false) {
179
-            while(strlen($timeStamp) < 16)
180
-                $timeStamp = "0" . $timeStamp;
181
-            $timeStampLength=8;
179
+            while (strlen($timeStamp) < 16)
180
+                $timeStamp = "0".$timeStamp;
181
+            $timeStampLength = 8;
182 182
         }
183 183
 
184 184
         // Put the bytes of "ocraSuite" parameters into the message
185 185
         
186
-        $msg = array_fill(0,$ocraSuiteLength+$counterLength+$questionLength+$passwordLength+$sessionInformationLength+$timeStampLength+1, 0);
186
+        $msg = array_fill(0, $ocraSuiteLength + $counterLength + $questionLength + $passwordLength + $sessionInformationLength + $timeStampLength + 1, 0);
187 187
                 
188
-        for($i=0;$i<strlen($ocraSuite);$i++) {
188
+        for ($i = 0; $i < strlen($ocraSuite); $i++) {
189 189
             $msg[$i] = $ocraSuite[$i];
190 190
         }
191 191
         
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 
195 195
         // Put the bytes of "Counter" to the message
196 196
         // Input is HEX encoded
197
-        if($counterLength > 0 ) {
197
+        if ($counterLength > 0) {
198 198
             $bArray = self::_hexStr2Bytes($counter);
199
-            for ($i=0;$i<strlen($bArray);$i++) {
199
+            for ($i = 0; $i < strlen($bArray); $i++) {
200 200
                 $msg [$i + $ocraSuiteLength + 1] = $bArray[$i];
201 201
             }
202 202
         }
@@ -204,36 +204,36 @@  discard block
 block discarded – undo
204 204
 
205 205
         // Put the bytes of "question" to the message
206 206
         // Input is text encoded
207
-        if($questionLength > 0 ) {
207
+        if ($questionLength > 0) {
208 208
             $bArray = self::_hexStr2Bytes($question);
209
-            for ($i=0;$i<strlen($bArray);$i++) {
209
+            for ($i = 0; $i < strlen($bArray); $i++) {
210 210
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength] = $bArray[$i];
211 211
             }
212 212
         }
213 213
 
214 214
         // Put the bytes of "password" to the message
215 215
         // Input is HEX encoded
216
-        if($passwordLength > 0){
216
+        if ($passwordLength > 0) {
217 217
             $bArray = self::_hexStr2Bytes($password);
218
-            for ($i=0;$i<strlen($bArray);$i++) {
218
+            for ($i = 0; $i < strlen($bArray); $i++) {
219 219
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength] = $bArray[$i];
220 220
             }
221 221
         }
222 222
 
223 223
         // Put the bytes of "sessionInformation" to the message
224 224
         // Input is text encoded
225
-        if($sessionInformationLength > 0 ){
225
+        if ($sessionInformationLength > 0) {
226 226
             $bArray = self::_hexStr2Bytes($sessionInformation);
227
-            for ($i=0;$i<strlen($bArray);$i++) {
227
+            for ($i = 0; $i < strlen($bArray); $i++) {
228 228
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength + $passwordLength] = $bArray[$i];
229 229
             }
230 230
         }
231 231
 
232 232
         // Put the bytes of "time" to the message
233 233
         // Input is text value of minutes
234
-        if($timeStampLength > 0){
234
+        if ($timeStampLength > 0) {
235 235
             $bArray = self::_hexStr2Bytes($timeStamp);
236
-            for ($i=0;$i<strlen($bArray);$i++) {
236
+            for ($i = 0; $i < strlen($bArray); $i++) {
237 237
                 $msg [$i + $ocraSuiteLength + 1 + $counterLength + $questionLength + $passwordLength + $sessionInformationLength] = $bArray[$i];
238 238
             }
239 239
         }
@@ -260,23 +260,23 @@  discard block
 block discarded – undo
260 260
     static function _oath_truncate($hash, $length = 6)
261 261
     {
262 262
         // Convert to dec
263
-        foreach(str_split($hash,2) as $hex)
263
+        foreach (str_split($hash, 2) as $hex)
264 264
         {
265
-            $hmac_result[]=hexdec($hex);
265
+            $hmac_result[] = hexdec($hex);
266 266
         }
267 267
     
268 268
         // Find offset
269 269
         $offset = $hmac_result[count($hmac_result) - 1] & 0xf;
270 270
     
271 271
         $v = strval(
272
-            (($hmac_result[$offset+0] & 0x7f) << 24 ) |
273
-            (($hmac_result[$offset+1] & 0xff) << 16 ) |
274
-            (($hmac_result[$offset+2] & 0xff) << 8 ) |
275
-            ($hmac_result[$offset+3] & 0xff)
272
+            (($hmac_result[$offset + 0] & 0x7f) << 24) |
273
+            (($hmac_result[$offset + 1] & 0xff) << 16) |
274
+            (($hmac_result[$offset + 2] & 0xff) << 8) |
275
+            ($hmac_result[$offset + 3] & 0xff)
276 276
         );
277 277
 
278 278
         // Prefix truncated string with 0's to ensure it always has the required length
279
-        $v=str_pad($v, $length, "0", STR_PAD_LEFT);
279
+        $v = str_pad($v, $length, "0", STR_PAD_LEFT);
280 280
 
281 281
         $v = substr($v, strlen($v) - $length);
282 282
         return $v;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Service.php 3 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.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
         }
553 553
 
554 554
         $metadata = array("service"=>
555
-                               array("displayName"       => $this->_name,
556
-                                     "identifier"        => $this->_identifier,
557
-                                     "logoUrl"           => $this->_logoUrl,
558
-                                     "infoUrl"           => $this->_infoUrl,
559
-                                     "authenticationUrl" => $authenticationUrl,
560
-                                     "ocraSuite"         => $this->_ocraSuite,
561
-                                     "enrollmentUrl"     => $enrollmentUrl
562
-                               ),
563
-                          "identity"=>
564
-                               array("identifier" =>$data["userId"],
565
-                                     "displayName"=>$data["displayName"]));
555
+                                array("displayName"       => $this->_name,
556
+                                        "identifier"        => $this->_identifier,
557
+                                        "logoUrl"           => $this->_logoUrl,
558
+                                        "infoUrl"           => $this->_infoUrl,
559
+                                        "authenticationUrl" => $authenticationUrl,
560
+                                        "ocraSuite"         => $this->_ocraSuite,
561
+                                        "enrollmentUrl"     => $enrollmentUrl
562
+                                ),
563
+                            "identity"=>
564
+                                array("identifier" =>$data["userId"],
565
+                                        "displayName"=>$data["displayName"]));
566 566
 
567 567
         $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
568 568
 
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function getEnrollmentSecret($enrollmentKey)
587 587
     {
588
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
589
-         $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
590
-         $enrollmentData = [
591
-             "userId" => $data["userId"],
592
-             "sessionId" => $data["sessionId"]
593
-         ];
594
-         $this->_stateStorage->setValue(
595
-             self::PREFIX_ENROLLMENT_SECRET . $secret,
596
-             $enrollmentData,
597
-             self::ENROLLMENT_EXPIRE
598
-         );
599
-         return $secret;
588
+            $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
589
+            $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
590
+            $enrollmentData = [
591
+                "userId" => $data["userId"],
592
+                "sessionId" => $data["sessionId"]
593
+            ];
594
+            $this->_stateStorage->setValue(
595
+                self::PREFIX_ENROLLMENT_SECRET . $secret,
596
+                $enrollmentData,
597
+                self::ENROLLMENT_EXPIRE
598
+            );
599
+            return $secret;
600 600
     } 
601 601
 
602 602
     /**
@@ -635,18 +635,18 @@  discard block
 block discarded – undo
635 635
      */
636 636
     public function finalizeEnrollment($enrollmentSecret) 
637 637
     {
638
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
639
-         if (is_array($data)) {
640
-             // Enrollment is finalized, destroy our session data.
641
-             $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
642
-             $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
643
-         } else {
644
-             $this->logger->error(
645
-                 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
646
-                 'Warning! the method will still return "true" as a result.'
647
-             );
648
-         }
649
-         return true;
638
+            $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
639
+            if (is_array($data)) {
640
+                // Enrollment is finalized, destroy our session data.
641
+                $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
642
+                $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
643
+            } else {
644
+                $this->logger->error(
645
+                    'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
646
+                    'Warning! the method will still return "true" as a result.'
647
+                );
648
+            }
649
+            return true;
650 650
     }
651 651
 
652 652
     /**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 
684 684
         $challengeUserId = NULL;
685 685
         if (isset($state["userId"])) {
686
-          $challengeUserId = $state["userId"];
686
+            $challengeUserId = $state["userId"];
687 687
         }
688 688
         // Check if we're dealing with a second factor
689 689
         if ($challengeUserId!=NULL && ($userId != $challengeUserId)) {
@@ -830,6 +830,6 @@  discard block
 block discarded – undo
830 830
      */
831 831
     protected function _setEnrollmentStatus($sessionId, $status)
832 832
     {
833
-       $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE);
833
+        $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE);
834 834
     }
835 835
 }
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';
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param array $options
163 163
      * @param int $version The protocol version to use (defaults to the latest)
164 164
      */
165
-    public function __construct(LoggerInterface $logger, $options=array(), $version = 2)
165
+    public function __construct(LoggerInterface $logger, $options = array(), $version = 2)
166 166
     {
167 167
         $this->_options = $options;
168 168
         $this->logger = $logger;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType));
307 307
             $message = new $class($this->_options);
308 308
             $message->setId(time());
309
-            $message->setText("Please authenticate for " . $this->_name);
309
+            $message->setText("Please authenticate for ".$this->_name);
310 310
             $message->setAddress($notificationAddress);
311 311
             $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey));
312 312
             $message->send();
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
      * @param String $spIdentifier If SP and IDP are 2 different things, pass the url/identifier of the SP the user is logging into.
376 376
      *                             For setups where IDP==SP, just leave this blank.
377 377
      */
378
-    public function startAuthenticationSession($userId="", $sessionId="", $spIdentifier="")
378
+    public function startAuthenticationSession($userId = "", $sessionId = "", $spIdentifier = "")
379 379
     {
380
-        if ($sessionId=="") {
380
+        if ($sessionId == "") {
381 381
             $sessionId = session_id();
382 382
         }
383 383
 
384
-        if ($spIdentifier=="") {
384
+        if ($spIdentifier == "") {
385 385
             $spIdentifier = $this->_identifier;
386 386
         }
387 387
 
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         
392 392
         $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier);
393 393
         
394
-        if ($userId!="") {
394
+        if ($userId != "") {
395 395
             $data["userId"] = $userId;
396 396
         }
397 397
         
398
-        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE);
398
+        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE);
399 399
        
400 400
         return $sessionKey;
401 401
     }
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
      *                           to php session)
416 416
      * @return String The enrollment key
417 417
      */
418
-    public function startEnrollmentSession($userId, $displayName, $sessionId="")
418
+    public function startEnrollmentSession($userId, $displayName, $sessionId = "")
419 419
     {
420
-        if ($sessionId=="") {
420
+        if ($sessionId == "") {
421 421
             $sessionId = session_id();
422 422
         }
423 423
         $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT);
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
             "displayName" => $displayName,
427 427
             "sessionId" => $sessionId
428 428
         ];
429
-        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
429
+        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
430 430
         $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED);
431 431
 
432 432
         return $enrollmentKey;
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
      * @param $sessionId The application's session identifier (defaults
438 438
      *                   to php session)
439 439
      */
440
-    public function resetEnrollmentSession($sessionId="")
440
+    public function resetEnrollmentSession($sessionId = "")
441 441
     {
442
-        if ($sessionId=="") {
442
+        if ($sessionId == "") {
443 443
             $sessionId = session_id();
444 444
         }
445 445
 
@@ -484,9 +484,9 @@  discard block
 block discarded – undo
484 484
      *               A first successful authentication was performed 
485 485
      *               (todo: currently not used)
486 486
      */
487
-    public function getEnrollmentStatus($sessionId="")
487
+    public function getEnrollmentStatus($sessionId = "")
488 488
     { 
489
-        if ($sessionId=="") {
489
+        if ($sessionId == "") {
490 490
             $sessionId = session_id(); 
491 491
         }
492 492
         $status = $this->_stateStorage->getValue("enrollstatus".$sessionId);
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      */
546 546
     public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl)
547 547
     {
548
-        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
548
+        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
549 549
         if (!is_array($data)) {
550 550
             $this->logger->error('Unable to find enrollment metadata in state storage');
551 551
             return false;
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
                                array("identifier" =>$data["userId"],
565 565
                                      "displayName"=>$data["displayName"]));
566 566
 
567
-        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
567
+        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
568 568
 
569 569
         $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED);
570 570
         return $metadata;
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function getEnrollmentSecret($enrollmentKey)
587 587
     {
588
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
588
+         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
589 589
          $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
590 590
          $enrollmentData = [
591 591
              "userId" => $data["userId"],
592 592
              "sessionId" => $data["sessionId"]
593 593
          ];
594 594
          $this->_stateStorage->setValue(
595
-             self::PREFIX_ENROLLMENT_SECRET . $secret,
595
+             self::PREFIX_ENROLLMENT_SECRET.$secret,
596 596
              $enrollmentData,
597 597
              self::ENROLLMENT_EXPIRE
598 598
          );
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
              $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
643 643
          } else {
644 644
              $this->logger->error(
645
-                 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
645
+                 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '.
646 646
                  'Warning! the method will still return "true" as a result.'
647 647
              );
648 648
          }
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
      */
673 673
     public function authenticate($userId, $userSecret, $sessionKey, $response)
674 674
     {
675
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
675
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
676 676
         if (is_null($state)) {
677 677
             $this->logger->info('The auth challenge could not be found in the state storage');
678 678
             return self::AUTH_RESULT_INVALID_CHALLENGE;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
           $challengeUserId = $state["userId"];
687 687
         }
688 688
         // Check if we're dealing with a second factor
689
-        if ($challengeUserId!=NULL && ($userId != $challengeUserId)) {
689
+        if ($challengeUserId != NULL && ($userId != $challengeUserId)) {
690 690
             $this->logger->error(
691 691
                 'Authentication failed: the first factor user id does not match with that of the second factor'
692 692
             );
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE);
705 705
             
706 706
             // Clean up the challenge.
707
-            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey);
707
+            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey);
708 708
             $this->logger->info('Authentication succeeded');
709 709
             return self::AUTH_RESULT_AUTHENTICATED;
710 710
         }
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
      * @param String $sessionId The application's session identifier (defaults
718 718
      *                          to the php session).
719 719
      */
720
-    public function logout($sessionId="")
720
+    public function logout($sessionId = "")
721 721
     {
722
-        if ($sessionId=="") {
722
+        if ($sessionId == "") {
723 723
             $sessionId = session_id(); 
724 724
         }
725 725
         
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
      * @return mixed An array with user data if a user was logged in or NULL if
755 755
      *               no user is logged in.
756 756
      */
757
-    public function getAuthenticatedUser($sessionId="")
757
+    public function getAuthenticatedUser($sessionId = "")
758 758
     {
759
-        if ($sessionId=="") {
759
+        if ($sessionId == "") {
760 760
             $this->logger->debug('Using the PHP session id, as no session id was provided');
761 761
             $sessionId = session_id(); 
762 762
         }
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
      */
776 776
     protected function _getChallengeUrl($sessionKey)
777 777
     {                
778
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
778
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
779 779
         if (is_null($state)) {
780 780
             $this->logger->error(
781 781
                 'Unable find an existing challenge url in the state storage based on the existing session key'
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
             return false;
784 784
         }
785 785
         
786
-        $userId   = NULL;
786
+        $userId = NULL;
787 787
         $challenge = $state["challenge"];
788 788
         if (isset($state["userId"])) {
789 789
             $userId = $state["userId"];
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
         $spIdentifier = $state["spIdentifier"];
792 792
         
793 793
         // Last bit is the spIdentifier
794
-        return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
794
+        return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
795 795
     }
796 796
 
797 797
     /**
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
     protected function _uniqueSessionKey($prefix)
816 816
     {      
817 817
         $value = 1;
818
-        while ($value!=NULL) {
818
+        while ($value != NULL) {
819 819
             $sessionKey = $this->_ocraWrapper->generateSessionKey();
820 820
             $value = $this->_stateStorage->getValue($prefix.$sessionKey);
821 821
         }
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 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 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)
33
-     {
34
-         parent::__construct($message, 0, $parent);
35
-     }
32
+        public function __construct($message, $parent=null)
33
+        {
34
+            parent::__construct($message, 0, $parent);
35
+        }
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this 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.