Completed
Push — master ( e355ed...1c7137 )
by Michiel
01:02 queued 11s
created
library/tiqr/Tiqr/Message/FCM.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@
 block discarded – undo
97 97
 
98 98
         // Wait and retry once in case of a 502 Bad Gateway error
99 99
         if ($statusCode === 502 && !($retry)) {
100
-          sleep(2);
101
-          $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true);
102
-          return;
100
+            sleep(2);
101
+            $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true);
102
+            return;
103 103
         }
104 104
 
105 105
         if ($statusCode !== 200) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @throws Tiqr_Message_Exception_SendFailure
59 59
      */
60
-    private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry=false)
60
+    private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry = false)
61 61
     {
62 62
         $msg = array(
63 63
             'challenge' => $challenge,
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         );
72 72
 
73 73
         $headers = array(
74
-            'Authorization: key=' . $apiKey,
74
+            'Authorization: key='.$apiKey,
75 75
             'Content-Type: application/json',
76 76
         );
77 77
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $result = curl_exec($ch);
85 85
         $errors = curl_error($ch);
86 86
         $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
87
-        $remoteip = curl_getinfo($ch,CURLINFO_PRIMARY_IP);
87
+        $remoteip = curl_getinfo($ch, CURLINFO_PRIMARY_IP);
88 88
         curl_close($ch);
89 89
 
90 90
         if ($result === false) {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         }
93 93
 
94 94
         if (!empty($errors)) {
95
-            throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true);
95
+            throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true);
96 96
         }
97 97
 
98 98
         // Wait and retry once in case of a 502 Bad Gateway error
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $response = json_decode($result, true);
111 111
         foreach ($response['results'] as $k => $v) {
112 112
             if (isset($v['error'])) {
113
-                throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: " . $v['error'], true);
113
+                throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: ".$v['error'], true);
114 114
             }
115 115
         }
116 116
     }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Service.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
         }
539 539
 
540 540
         $metadata = array("service"=>
541
-                               array("displayName"       => $this->_name,
542
-                                     "identifier"        => $this->_identifier,
543
-                                     "logoUrl"           => $this->_logoUrl,
544
-                                     "infoUrl"           => $this->_infoUrl,
545
-                                     "authenticationUrl" => $authenticationUrl,
546
-                                     "ocraSuite"         => $this->_ocraSuite,
547
-                                     "enrollmentUrl"     => $enrollmentUrl
548
-                               ),
549
-                          "identity"=>
550
-                               array("identifier" =>$data["userId"],
551
-                                     "displayName"=>$data["displayName"]));
541
+                                array("displayName"       => $this->_name,
542
+                                        "identifier"        => $this->_identifier,
543
+                                        "logoUrl"           => $this->_logoUrl,
544
+                                        "infoUrl"           => $this->_infoUrl,
545
+                                        "authenticationUrl" => $authenticationUrl,
546
+                                        "ocraSuite"         => $this->_ocraSuite,
547
+                                        "enrollmentUrl"     => $enrollmentUrl
548
+                                ),
549
+                            "identity"=>
550
+                                array("identifier" =>$data["userId"],
551
+                                        "displayName"=>$data["displayName"]));
552 552
 
553 553
         $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
554 554
 
@@ -571,18 +571,18 @@  discard block
 block discarded – undo
571 571
      */
572 572
     public function getEnrollmentSecret($enrollmentKey)
573 573
     {
574
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
575
-         $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
576
-         $enrollmentData = [
577
-             "userId" => $data["userId"],
578
-             "sessionId" => $data["sessionId"]
579
-         ];
580
-         $this->_stateStorage->setValue(
581
-             self::PREFIX_ENROLLMENT_SECRET . $secret,
582
-             $enrollmentData,
583
-             self::ENROLLMENT_EXPIRE
584
-         );
585
-         return $secret;
574
+            $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
575
+            $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
576
+            $enrollmentData = [
577
+                "userId" => $data["userId"],
578
+                "sessionId" => $data["sessionId"]
579
+            ];
580
+            $this->_stateStorage->setValue(
581
+                self::PREFIX_ENROLLMENT_SECRET . $secret,
582
+                $enrollmentData,
583
+                self::ENROLLMENT_EXPIRE
584
+            );
585
+            return $secret;
586 586
     } 
587 587
 
588 588
     /**
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
      */
598 598
     public function validateEnrollmentSecret($enrollmentSecret)
599 599
     {
600
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
601
-         if (is_array($data)) { 
602
-             // Secret is valid, application may accept the user secret. 
603
-             $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_PROCESSED);
604
-             return $data["userId"];
605
-         }
606
-         return false;
600
+            $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
601
+            if (is_array($data)) { 
602
+                // Secret is valid, application may accept the user secret. 
603
+                $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_PROCESSED);
604
+                return $data["userId"];
605
+            }
606
+            return false;
607 607
     }
608 608
     
609 609
     /**
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
      */
621 621
     public function finalizeEnrollment($enrollmentSecret) 
622 622
     {
623
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
624
-         if (is_array($data)) {
625
-             // Enrollment is finalized, destroy our session data.
626
-             $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
627
-             $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
628
-         }
629
-         return true;
623
+            $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
624
+            if (is_array($data)) {
625
+                // Enrollment is finalized, destroy our session data.
626
+                $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
627
+                $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret);
628
+            }
629
+            return true;
630 630
     }
631 631
 
632 632
     /**
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 
663 663
         $challengeUserId = NULL;
664 664
         if (isset($state["userId"])) {
665
-          $challengeUserId = $state["userId"];
665
+            $challengeUserId = $state["userId"];
666 666
         }
667 667
         // Check if we're dealing with a second factor
668 668
         if ($challengeUserId!=NULL && ($userId != $challengeUserId)) {
@@ -801,6 +801,6 @@  discard block
 block discarded – undo
801 801
      */
802 802
     protected function _setEnrollmentStatus($sessionId, $status)
803 803
     {
804
-       $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE);
804
+        $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE);
805 805
     }
806 806
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
     /**
69 69
      * Enrollment status codes
70 70
      */
71
-    const ENROLLMENT_STATUS_IDLE = 1;        // Nothing happens
71
+    const ENROLLMENT_STATUS_IDLE = 1; // Nothing happens
72 72
     const ENROLLMENT_STATUS_INITIALIZED = 2; // An enrollment session has begun
73
-    const ENROLLMENT_STATUS_RETRIEVED = 3;   // The device has retrieved the metadata
74
-    const ENROLLMENT_STATUS_PROCESSED = 4;   // The device has snet back a secret
75
-    const ENROLLMENT_STATUS_FINALIZED = 5;   // The application has stored the secret
76
-    const ENROLLMENT_STATUS_VALIDATED = 6;   // A first succesful authentication was performed
73
+    const ENROLLMENT_STATUS_RETRIEVED = 3; // The device has retrieved the metadata
74
+    const ENROLLMENT_STATUS_PROCESSED = 4; // The device has snet back a secret
75
+    const ENROLLMENT_STATUS_FINALIZED = 5; // The application has stored the secret
76
+    const ENROLLMENT_STATUS_VALIDATED = 6; // A first succesful authentication was performed
77 77
 
78 78
     const PREFIX_ENROLLMENT_SECRET = 'enrollsecret';
79 79
     const PREFIX_ENROLLMENT = 'enroll';
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      * @param array $options
157 157
      * @param int $version The protocol version to use (defaults to the latest)
158 158
      */
159
-    public function __construct($options=array(), $version = 2)
159
+    public function __construct($options = array(), $version = 2)
160 160
     {
161 161
         $this->_options = $options;
162 162
         
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
             $message = new $class($this->_options);
296 296
             $message->setId(time());
297
-            $message->setText("Please authenticate for " . $this->_name);
297
+            $message->setText("Please authenticate for ".$this->_name);
298 298
             $message->setAddress($notificationAddress);
299 299
             $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey));
300 300
             $message->send();
@@ -362,13 +362,13 @@  discard block
 block discarded – undo
362 362
      * @param String $spIdentifier If SP and IDP are 2 different things, pass the url/identifier of the SP the user is logging into.
363 363
      *                             For setups where IDP==SP, just leave this blank.
364 364
      */
365
-    public function startAuthenticationSession($userId="", $sessionId="", $spIdentifier="")
365
+    public function startAuthenticationSession($userId = "", $sessionId = "", $spIdentifier = "")
366 366
     {
367
-        if ($sessionId=="") {
367
+        if ($sessionId == "") {
368 368
             $sessionId = session_id();
369 369
         }
370 370
 
371
-        if ($spIdentifier=="") {
371
+        if ($spIdentifier == "") {
372 372
             $spIdentifier = $this->_identifier;
373 373
         }
374 374
 
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
         
379 379
         $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier);
380 380
         
381
-        if ($userId!="") {
381
+        if ($userId != "") {
382 382
             $data["userId"] = $userId;
383 383
         }
384 384
         
385
-        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE);
385
+        $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE);
386 386
        
387 387
         return $sessionKey;
388 388
     }
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
      *                           to php session)
403 403
      * @return String The enrollment key
404 404
      */
405
-    public function startEnrollmentSession($userId, $displayName, $sessionId="")
405
+    public function startEnrollmentSession($userId, $displayName, $sessionId = "")
406 406
     {
407
-        if ($sessionId=="") {
407
+        if ($sessionId == "") {
408 408
             $sessionId = session_id();
409 409
         }
410 410
         $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT);
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             "displayName" => $displayName,
414 414
             "sessionId" => $sessionId
415 415
         ];
416
-        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
416
+        $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE);
417 417
         $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED);
418 418
 
419 419
         return $enrollmentKey;
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
      * @param $sessionId The application's session identifier (defaults
425 425
      *                   to php session)
426 426
      */
427
-    public function resetEnrollmentSession($sessionId="")
427
+    public function resetEnrollmentSession($sessionId = "")
428 428
     {
429
-        if ($sessionId=="") {
429
+        if ($sessionId == "") {
430 430
             $sessionId = session_id();
431 431
         }
432 432
 
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
      *               A first successful authentication was performed 
472 472
      *               (todo: currently not used)
473 473
      */
474
-    public function getEnrollmentStatus($sessionId="")
474
+    public function getEnrollmentStatus($sessionId = "")
475 475
     { 
476
-        if ($sessionId=="") {
476
+        if ($sessionId == "") {
477 477
             $sessionId = session_id(); 
478 478
         }
479 479
         $status = $this->_stateStorage->getValue("enrollstatus".$sessionId);
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
      */
533 533
     public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl)
534 534
     {
535
-        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
535
+        $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
536 536
         if (!is_array($data)) {
537 537
             return false;
538 538
         }
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                                array("identifier" =>$data["userId"],
551 551
                                      "displayName"=>$data["displayName"]));
552 552
 
553
-        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
553
+        $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
554 554
 
555 555
         $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED);
556 556
         return $metadata;
@@ -571,14 +571,14 @@  discard block
 block discarded – undo
571 571
      */
572 572
     public function getEnrollmentSecret($enrollmentKey)
573 573
     {
574
-         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey);
574
+         $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey);
575 575
          $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET);
576 576
          $enrollmentData = [
577 577
              "userId" => $data["userId"],
578 578
              "sessionId" => $data["sessionId"]
579 579
          ];
580 580
          $this->_stateStorage->setValue(
581
-             self::PREFIX_ENROLLMENT_SECRET . $secret,
581
+             self::PREFIX_ENROLLMENT_SECRET.$secret,
582 582
              $enrollmentData,
583 583
              self::ENROLLMENT_EXPIRE
584 584
          );
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
      */
653 653
     public function authenticate($userId, $userSecret, $sessionKey, $response)
654 654
     {
655
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
655
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
656 656
         if (is_null($state)) {
657 657
             return self::AUTH_RESULT_INVALID_CHALLENGE;
658 658
         }
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
           $challengeUserId = $state["userId"];
666 666
         }
667 667
         // Check if we're dealing with a second factor
668
-        if ($challengeUserId!=NULL && ($userId != $challengeUserId)) {
668
+        if ($challengeUserId != NULL && ($userId != $challengeUserId)) {
669 669
             return self::AUTH_RESULT_INVALID_USERID; // only allowed to authenticate against the user that's authenticated in the first factor
670 670
         }
671 671
 
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
             $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE);
681 681
             
682 682
             // Clean up the challenge.
683
-            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey);
683
+            $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey);
684 684
             
685 685
             return self::AUTH_RESULT_AUTHENTICATED;
686 686
         }
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
      * @param String $sessionId The application's session identifier (defaults
693 693
      *                          to the php session).
694 694
      */
695
-    public function logout($sessionId="")
695
+    public function logout($sessionId = "")
696 696
     {
697
-        if ($sessionId=="") {
697
+        if ($sessionId == "") {
698 698
             $sessionId = session_id(); 
699 699
         }
700 700
         
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
      * @return mixed An array with user data if a user was logged in or NULL if
730 730
      *               no user is logged in.
731 731
      */
732
-    public function getAuthenticatedUser($sessionId="")
732
+    public function getAuthenticatedUser($sessionId = "")
733 733
     {
734
-        if ($sessionId=="") {
734
+        if ($sessionId == "") {
735 735
             $sessionId = session_id(); 
736 736
         }
737 737
         
@@ -749,12 +749,12 @@  discard block
 block discarded – undo
749 749
      */
750 750
     protected function _getChallengeUrl($sessionKey)
751 751
     {                
752
-        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey);
752
+        $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey);
753 753
         if (is_null($state)) {
754 754
             return false;
755 755
         }
756 756
         
757
-        $userId   = NULL;
757
+        $userId = NULL;
758 758
         $challenge = $state["challenge"];
759 759
         if (isset($state["userId"])) {
760 760
             $userId = $state["userId"];
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         $spIdentifier = $state["spIdentifier"];
763 763
         
764 764
         // Last bit is the spIdentifier
765
-        return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
765
+        return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
766 766
     }
767 767
 
768 768
     /**
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     protected function _uniqueSessionKey($prefix)
787 787
     {      
788 788
         $value = 1;
789
-        while ($value!=NULL) {
789
+        while ($value != NULL) {
790 790
             $sessionKey = $this->_ocraWrapper->generateSessionKey();
791 791
             $value = $this->_stateStorage->getValue($prefix.$sessionKey);
792 792
         }
Please login to merge, or discard this patch.