Skip to content
Snippets Groups Projects
Unverified Commit 8bafc63a authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

PSR-2 + unused code

parent 141c28ed
No related branches found
No related tags found
No related merge requests found
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
* *
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
class sspmod_saml_SP_LogoutStore { class sspmod_saml_SP_LogoutStore
{
/** /**
* Create logout table in SQL, if it is missing. * Create logout table in SQL, if it is missing.
* *
* @param \SimpleSAML\Store\SQL $store The datastore. * @param \SimpleSAML\Store\SQL $store The datastore.
*/ */
private static function createLogoutTable(\SimpleSAML\Store\SQL $store) { private static function createLogoutTable(\SimpleSAML\Store\SQL $store)
{
$tableVer = $store->getTableVersion('saml_LogoutStore'); $tableVer = $store->getTableVersion('saml_LogoutStore');
if ($tableVer === 2) { if ($tableVer === 2) {
return; return;
...@@ -21,7 +21,7 @@ class sspmod_saml_SP_LogoutStore { ...@@ -21,7 +21,7 @@ class sspmod_saml_SP_LogoutStore {
/* TableVersion 2 increased the column size to 255 which is the maximum length of a FQDN. */ /* TableVersion 2 increased the column size to 255 which is the maximum length of a FQDN. */
$query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL'; $query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL';
try { try {
$ret = $store->pdo->exec($query); $store->pdo->exec($query);
} catch (Exception $e) { } catch (Exception $e) {
SimpleSAML\Logger::warning($store->pdo->errorInfo()); SimpleSAML\Logger::warning($store->pdo->errorInfo());
return; return;
...@@ -55,8 +55,8 @@ class sspmod_saml_SP_LogoutStore { ...@@ -55,8 +55,8 @@ class sspmod_saml_SP_LogoutStore {
* *
* @param \SimpleSAML\Store\SQL $store The datastore. * @param \SimpleSAML\Store\SQL $store The datastore.
*/ */
private static function cleanLogoutStore(\SimpleSAML\Store\SQL $store) { private static function cleanLogoutStore(\SimpleSAML\Store\SQL $store)
{
SimpleSAML\Logger::debug('saml.LogoutStore: Cleaning logout store.'); SimpleSAML\Logger::debug('saml.LogoutStore: Cleaning logout store.');
$query = 'DELETE FROM ' . $store->prefix . '_saml_LogoutStore WHERE _expire < :now'; $query = 'DELETE FROM ' . $store->prefix . '_saml_LogoutStore WHERE _expire < :now';
...@@ -75,7 +75,8 @@ class sspmod_saml_SP_LogoutStore { ...@@ -75,7 +75,8 @@ class sspmod_saml_SP_LogoutStore {
* @param string $nameId The hash of the users NameID. * @param string $nameId The hash of the users NameID.
* @param string $sessionIndex The SessionIndex of the user. * @param string $sessionIndex The SessionIndex of the user.
*/ */
private static function addSessionSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId, $sessionIndex, $expire, $sessionId) { private static function addSessionSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId, $sessionIndex, $expire, $sessionId)
{
assert(is_string($authId)); assert(is_string($authId));
assert(is_string($nameId)); assert(is_string($nameId));
assert(is_string($sessionIndex)); assert(is_string($sessionIndex));
...@@ -107,7 +108,8 @@ class sspmod_saml_SP_LogoutStore { ...@@ -107,7 +108,8 @@ class sspmod_saml_SP_LogoutStore {
* @param string $nameId The hash of the users NameID. * @param string $nameId The hash of the users NameID.
* @return array Associative array of SessionIndex => SessionId. * @return array Associative array of SessionIndex => SessionId.
*/ */
private static function getSessionsSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId) { private static function getSessionsSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId)
{
assert(is_string($authId)); assert(is_string($authId));
assert(is_string($nameId)); assert(is_string($nameId));
...@@ -126,7 +128,7 @@ class sspmod_saml_SP_LogoutStore { ...@@ -126,7 +128,7 @@ class sspmod_saml_SP_LogoutStore {
$query->execute($params); $query->execute($params);
$res = array(); $res = array();
while ( ($row = $query->fetch(PDO::FETCH_ASSOC)) !== FALSE) { while ( ($row = $query->fetch(PDO::FETCH_ASSOC)) !== false) {
$res[$row['_sessionindex']] = $row['_sessionid']; $res[$row['_sessionindex']] = $row['_sessionid'];
} }
...@@ -143,14 +145,15 @@ class sspmod_saml_SP_LogoutStore { ...@@ -143,14 +145,15 @@ class sspmod_saml_SP_LogoutStore {
* @param array $sessionIndexes The session indexes. * @param array $sessionIndexes The session indexes.
* @return array Associative array of SessionIndex => SessionId. * @return array Associative array of SessionIndex => SessionId.
*/ */
private static function getSessionsStore(\SimpleSAML\Store $store, $authId, $nameId, array $sessionIndexes) { private static function getSessionsStore(\SimpleSAML\Store $store, $authId, $nameId, array $sessionIndexes)
{
assert(is_string($authId)); assert(is_string($authId));
assert(is_string($nameId)); assert(is_string($nameId));
$res = array(); $res = array();
foreach ($sessionIndexes as $sessionIndex) { foreach ($sessionIndexes as $sessionIndex) {
$sessionId = $store->get('saml.LogoutStore', $nameId . ':' . $sessionIndex); $sessionId = $store->get('saml.LogoutStore', $nameId . ':' . $sessionIndex);
if ($sessionId === NULL) { if ($sessionId === null) {
continue; continue;
} }
assert(is_string($sessionId)); assert(is_string($sessionId));
...@@ -174,12 +177,13 @@ class sspmod_saml_SP_LogoutStore { ...@@ -174,12 +177,13 @@ class sspmod_saml_SP_LogoutStore {
* @param \SAML2\XML\saml\NameID $nameId The NameID of the user. * @param \SAML2\XML\saml\NameID $nameId The NameID of the user.
* @param string|NULL $sessionIndex The SessionIndex of the user. * @param string|NULL $sessionIndex The SessionIndex of the user.
*/ */
public static function addSession($authId, $nameId, $sessionIndex, $expire) { public static function addSession($authId, $nameId, $sessionIndex, $expire)
{
assert(is_string($authId)); assert(is_string($authId));
assert(is_string($sessionIndex) || $sessionIndex === null); assert(is_string($sessionIndex) || $sessionIndex === null);
assert(is_int($expire)); assert(is_int($expire));
if ($sessionIndex === NULL) { if ($sessionIndex === null) {
/* This IdP apparently did not include a SessionIndex, and thus probably does not /* This IdP apparently did not include a SessionIndex, and thus probably does not
* support SLO. We still want to add the session to the data store just in case * support SLO. We still want to add the session to the data store just in case
* it supports SLO, but we don't want an LogoutRequest with a specific * it supports SLO, but we don't want an LogoutRequest with a specific
...@@ -189,7 +193,7 @@ class sspmod_saml_SP_LogoutStore { ...@@ -189,7 +193,7 @@ class sspmod_saml_SP_LogoutStore {
} }
$store = \SimpleSAML\Store::getInstance(); $store = \SimpleSAML\Store::getInstance();
if ($store === FALSE) { if ($store === false) {
// We don't have a datastore. // We don't have a datastore.
return; return;
} }
...@@ -226,13 +230,14 @@ class sspmod_saml_SP_LogoutStore { ...@@ -226,13 +230,14 @@ class sspmod_saml_SP_LogoutStore {
* @param array $sessionIndexes The SessionIndexes we should log out of. Logs out of all if this is empty. * @param array $sessionIndexes The SessionIndexes we should log out of. Logs out of all if this is empty.
* @returns int|FALSE Number of sessions logged out, or FALSE if not supported. * @returns int|FALSE Number of sessions logged out, or FALSE if not supported.
*/ */
public static function logoutSessions($authId, $nameId, array $sessionIndexes) { public static function logoutSessions($authId, $nameId, array $sessionIndexes)
{
assert(is_string($authId)); assert(is_string($authId));
$store = \SimpleSAML\Store::getInstance(); $store = \SimpleSAML\Store::getInstance();
if ($store === FALSE) { if ($store === false) {
/* We don't have a datastore. */ /* We don't have a datastore. */
return FALSE; return false;
} }
// serialize and anonymize the NameID // serialize and anonymize the NameID
...@@ -256,7 +261,7 @@ class sspmod_saml_SP_LogoutStore { ...@@ -256,7 +261,7 @@ class sspmod_saml_SP_LogoutStore {
$sessions = self::getSessionsSQL($store, $authId, $strNameId); $sessions = self::getSessionsSQL($store, $authId, $strNameId);
} elseif (empty($sessionIndexes)) { } elseif (empty($sessionIndexes)) {
/* We cannot fetch all sessions without a SQL store. */ /* We cannot fetch all sessions without a SQL store. */
return FALSE; return false;
} else { } else {
/** @var \SimpleSAML\Store $sessions At this point the store cannot be false */ /** @var \SimpleSAML\Store $sessions At this point the store cannot be false */
$sessions = self::getSessionsStore($store, $authId, $strNameId, $sessionIndexes); $sessions = self::getSessionsStore($store, $authId, $strNameId, $sessionIndexes);
...@@ -267,8 +272,6 @@ class sspmod_saml_SP_LogoutStore { ...@@ -267,8 +272,6 @@ class sspmod_saml_SP_LogoutStore {
$sessionIndexes = array_keys($sessions); $sessionIndexes = array_keys($sessions);
} }
$sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
$numLoggedOut = 0; $numLoggedOut = 0;
foreach ($sessionIndexes as $sessionIndex) { foreach ($sessionIndexes as $sessionIndex) {
if (!isset($sessions[$sessionIndex])) { if (!isset($sessions[$sessionIndex])) {
...@@ -279,7 +282,7 @@ class sspmod_saml_SP_LogoutStore { ...@@ -279,7 +282,7 @@ class sspmod_saml_SP_LogoutStore {
$sessionId = $sessions[$sessionIndex]; $sessionId = $sessions[$sessionIndex];
$session = SimpleSAML_Session::getSession($sessionId); $session = SimpleSAML_Session::getSession($sessionId);
if ($session === NULL) { if ($session === null) {
SimpleSAML\Logger::info('saml.LogoutStore: Skipping logout of missing session.'); SimpleSAML\Logger::info('saml.LogoutStore: Skipping logout of missing session.');
continue; continue;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment