@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return Tiqr_OcraService_Interface |
38 | 38 | */ |
39 | - public static function getOcraService($type="tiqr", $options=array()) |
|
39 | + public static function getOcraService($type = "tiqr", $options = array()) |
|
40 | 40 | { |
41 | 41 | switch ($type) { |
42 | 42 | case "tiqr": |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (!isset($type)) { |
52 | 52 | throw new Exception('Class name not set'); |
53 | 53 | } elseif (!class_exists($type)) { |
54 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
54 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
55 | 55 | } |
56 | 56 | $instance = new $type($options); |
57 | 57 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * the Tiqr_DeviceStorage factory will call this for you. |
54 | 54 | * @param array $options The options for the s |
55 | 55 | */ |
56 | - public function __construct($options=array()) |
|
56 | + public function __construct($options = array()) |
|
57 | 57 | { |
58 | 58 | $this->_options = $options; |
59 | 59 | } |
@@ -41,11 +41,11 @@ |
||
41 | 41 | { |
42 | 42 | $url = $this->_options["url"]."?appId=".$this->_options["appid"]; |
43 | 43 | |
44 | - $url.= "¬ificationToken=".$notificationToken; |
|
44 | + $url .= "¬ificationToken=".$notificationToken; |
|
45 | 45 | |
46 | 46 | $output = file_get_contents($url); |
47 | - if (stripos($output, "not found")!==false) return false; |
|
48 | - if (stripos($output, "error")!==false) return false; |
|
47 | + if (stripos($output, "not found") !== false) return false; |
|
48 | + if (stripos($output, "error") !== false) return false; |
|
49 | 49 | return trim($output); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * config options per type. |
43 | 43 | * @throws Exception An exception if an unknown storage is requested. |
44 | 44 | */ |
45 | - public static function getStorage($type="dummy", $options=array()) |
|
45 | + public static function getStorage($type = "dummy", $options = array()) |
|
46 | 46 | { |
47 | 47 | switch ($type) { |
48 | 48 | case "dummy": |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | default: |
58 | 58 | $instance = NULL; |
59 | 59 | } |
60 | - if ($instance!=NULL) { |
|
60 | + if ($instance != NULL) { |
|
61 | 61 | $instance->init(); |
62 | 62 | return $instance; |
63 | 63 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return Tiqr_UserSecretStorage_Interface |
38 | 38 | */ |
39 | - public static function getSecretStorage($type="file", $options=array()) |
|
39 | + public static function getSecretStorage($type = "file", $options = array()) |
|
40 | 40 | { |
41 | 41 | switch ($type) { |
42 | 42 | case "file": |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (!isset($type)) { |
60 | 60 | throw new Exception('Class name not set'); |
61 | 61 | } elseif (!class_exists($type)) { |
62 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
62 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
63 | 63 | } |
64 | 64 | $instance = new $type($options); |
65 | 65 | } |
@@ -35,7 +35,7 @@ |
||
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; |
@@ -29,7 +29,7 @@ |
||
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 | } |
@@ -35,7 +35,7 @@ |
||
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; |
@@ -68,12 +68,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |