@@ -43,7 +43,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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'); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | parent::__construct($config, $logger, $secretconfig); |
| 47 | 47 | $this->tablename = isset($config['table']) ? $config['table'] : 'tiqruser'; |
| 48 | 48 | try { |
| 49 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
| 49 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
| 50 | 50 | } catch (PDOException $e) { |
| 51 | 51 | $this->logger->error( |
| 52 | 52 | sprintf('Unable to establish a PDO connection. Error message from PDO: %s', $e->getMessage()) |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } else { |
| 62 | 62 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
| 63 | 63 | } |
| 64 | - if ($sth->execute(array($displayName,$userId))){ |
|
| 64 | + if ($sth->execute(array($displayName, $userId))) { |
|
| 65 | 65 | return $this->userExists($userId); |
| 66 | 66 | } |
| 67 | 67 | $this->logger->error('The user could not be saved in the user storage (PDO)'); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | public function setNotificationType($userId, $type) |
| 106 | 106 | { |
| 107 | 107 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationtype = ? WHERE userid = ?"); |
| 108 | - if (!$sth->execute(array($type,$userId))) { |
|
| 108 | + if (!$sth->execute(array($type, $userId))) { |
|
| 109 | 109 | $this->logger->error('Unable to set the notification type in user storage for a given user (PDO)'); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function setNotificationAddress($userId, $address) |
| 123 | 123 | { |
| 124 | 124 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationaddress = ? WHERE userid = ?"); |
| 125 | - if (!$sth->execute(array($address,$userId))) { |
|
| 125 | + if (!$sth->execute(array($address, $userId))) { |
|
| 126 | 126 | $this->logger->error('Unable to set the notification address in user storage for a given user (PDO)'); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function setLoginAttempts($userId, $amount) |
| 140 | 140 | { |
| 141 | 141 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET loginattempts = ? WHERE userid = ?"); |
| 142 | - if (!$sth->execute(array($amount,$userId))) { |
|
| 142 | + if (!$sth->execute(array($amount, $userId))) { |
|
| 143 | 143 | $this->logger->error('Unable to set login attempts in user storage for a given user (PDO)'); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function setTemporaryBlockAttempts($userId, $amount) { |
| 174 | 174 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblockattempts = ? WHERE userid = ?"); |
| 175 | - if (!$sth->execute(array($amount,$userId))) { |
|
| 175 | + if (!$sth->execute(array($amount, $userId))) { |
|
| 176 | 176 | $this->logger->error('Unable to set temp login attempts in user storage for a given user (PDO)'); |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public function setTemporaryBlockTimestamp($userId, $timestamp) |
| 198 | 198 | { |
| 199 | 199 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblocktimestamp = ? WHERE userid = ?"); |
| 200 | - if (!$sth->execute(array($timestamp,$userId))) { |
|
| 200 | + if (!$sth->execute(array($timestamp, $userId))) { |
|
| 201 | 201 | $this->logger->error('Unable to update temp lock timestamp in user storage for a given user (PDO)'); |
| 202 | 202 | } |
| 203 | 203 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @return Tiqr_UserStorage_Encryption_Interface |
| 42 | 42 | */ |
| 43 | - public static function getEncryption(LoggerInterface $logger, $type="dummy", $options=array()) |
|
| 43 | + public static function getEncryption(LoggerInterface $logger, $type = "dummy", $options = array()) |
|
| 44 | 44 | { |
| 45 | 45 | $logger->info(sprintf('Using %s as UserStorage encryption type', $type)); |
| 46 | 46 | switch ($type) { |
@@ -552,17 +552,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * options per type. |
| 46 | 46 | * @throws Exception If an unknown type is requested. |
| 47 | 47 | */ |
| 48 | - public static function getStorage($type="file", $options=array(), LoggerInterface $logger) |
|
| 48 | + public static function getStorage($type = "file", $options = array(), LoggerInterface $logger) |
|
| 49 | 49 | { |
| 50 | 50 | switch ($type) { |
| 51 | 51 | case "file": |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $pdoInstance = new PDO($options['dsn'],$options['username'],$options['password']); |
|
| 74 | + $pdoInstance = new PDO($options['dsn'], $options['username'], $options['password']); |
|
| 75 | 75 | // Set a hard-coded default for the probability the expired state is removed |
| 76 | 76 | // 0.1 translates to a 10% chance the garbage collection is executed |
| 77 | 77 | $cleanupProbability = 0.1; |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | if (!isset($type)) { |
| 87 | 87 | throw new Exception('Class name not set'); |
| 88 | 88 | } elseif (!class_exists($type)) { |
| 89 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
| 89 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
| 90 | 90 | } elseif (!is_subclass_of($type, 'Tiqr_StateStorage_Abstract')) { |
| 91 | - throw new Exception('Class ' . $type . ' not subclass of Tiqr_StateStorage_Abstract'); |
|
| 91 | + throw new Exception('Class '.$type.' not subclass of Tiqr_StateStorage_Abstract'); |
|
| 92 | 92 | } |
| 93 | 93 | $instance = new $type($options); |
| 94 | 94 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * config options per type. |
| 45 | 45 | * @throws Exception An exception if an unknown storage is requested. |
| 46 | 46 | */ |
| 47 | - public static function getStorage($type="dummy", $options=array(), LoggerInterface $logger) |
|
| 47 | + public static function getStorage($type = "dummy", $options = array(), LoggerInterface $logger) |
|
| 48 | 48 | { |
| 49 | 49 | switch ($type) { |
| 50 | 50 | case "dummy": |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | default: |
| 60 | 60 | $instance = NULL; |
| 61 | 61 | } |
| 62 | - if ($instance!=NULL) { |
|
| 62 | + if ($instance != NULL) { |
|
| 63 | 63 | $instance->init(); |
| 64 | 64 | return $instance; |
| 65 | 65 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->logger = $logger; |
| 44 | 44 | $this->tablename = isset($config['table']) ? $config['table'] : 'tiqrusersecret'; |
| 45 | 45 | try { |
| 46 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
| 46 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
| 47 | 47 | } catch (PDOException $e) { |
| 48 | 48 | $this->logger->error( |
| 49 | 49 | sprintf('Unable to establish a PDO connection. Error message from PDO: %s', $e->getMessage()) |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function getUserSecret($userId) |
| 62 | 62 | { |
| 63 | 63 | $sth = $this->handle->prepare("SELECT secret FROM ".$this->tablename." WHERE userid = ?"); |
| 64 | - if($sth->execute(array($userId))) { |
|
| 64 | + if ($sth->execute(array($userId))) { |
|
| 65 | 65 | return $sth->fetchColumn(); |
| 66 | 66 | } |
| 67 | 67 | $this->logger->error('Unable to retrieve user secret from user secret storage (PDO)'); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } else { |
| 81 | 81 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (secret,userid) VALUES (?,?)"); |
| 82 | 82 | } |
| 83 | - if (!$sth->execute(array($secret,$userId))) { |
|
| 83 | + if (!$sth->execute(array($secret, $userId))) { |
|
| 84 | 84 | $this->logger->error('Unable to persist user secret in user secret storage (PDO)'); |
| 85 | 85 | } |
| 86 | 86 | } |