ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_saml_IdP_SQLNameID Class Reference
+ Collaboration diagram for sspmod_saml_IdP_SQLNameID:

Static Public Member Functions

static add ($idpEntityId, $spEntityId, $user, $value)
 Add a NameID into the database. More...
 
static get ($idpEntityId, $spEntityId, $user)
 Retrieve a NameID into from database. More...
 
static delete ($idpEntityId, $spEntityId, $user)
 Delete a NameID from the database. More...
 
static getIdentities ($idpEntityId, $spEntityId)
 Retrieve all federated identities for an IdP-SP pair. More...
 

Static Private Member Functions

static createTable (\SimpleSAML\Store\SQL $store)
 Create NameID table in SQL, if it is missing. More...
 
static getStore ()
 Retrieve the SQL datastore. More...
 

Detailed Description

Definition at line 8 of file SQLNameID.php.

Member Function Documentation

◆ add()

static sspmod_saml_IdP_SQLNameID::add (   $idpEntityId,
  $spEntityId,
  $user,
  $value 
)
static

Add a NameID into the database.

Parameters
\SimpleSAML\Store\SQL$storeThe data store.
string$idpEntityIdThe IdP entityID.
string$spEntityIdThe SP entityID.
string$userThe user's unique identificator (e.g. username).
string$valueThe NameID value.

Definition at line 66 of file SQLNameID.php.

References $idpEntityId, PHPMailer\PHPMailer\$params, $query, $spEntityId, $store, and $user.

Referenced by sspmod_saml_Auth_Process_SQLPersistentNameID\getValue().

67  {
68  assert(is_string($idpEntityId));
69  assert(is_string($spEntityId));
70  assert(is_string($user));
71  assert(is_string($value));
72 
73  $store = self::getStore();
74 
75  $params = array(
76  '_idp' => $idpEntityId,
77  '_sp' => $spEntityId,
78  '_user' => $user,
79  '_value' => $value,
80  );
81 
82  $query = 'INSERT INTO ' . $store->prefix . '_saml_PersistentNameID (_idp, _sp, _user, _value) VALUES(:_idp, :_sp, :_user, :_value)';
83  $query = $store->pdo->prepare($query);
84  $query->execute($params);
85  }
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
$user
Definition: migrateto20.php:57
+ Here is the caller graph for this function:

◆ createTable()

static sspmod_saml_IdP_SQLNameID::createTable ( \SimpleSAML\Store\SQL  $store)
staticprivate

Create NameID table in SQL, if it is missing.

Parameters
\SimpleSAML\Store\SQL$storeThe datastore.

Definition at line 15 of file SQLNameID.php.

References $query.

16  {
17  if ($store->getTableVersion('saml_PersistentNameID') === 1) {
18  return;
19  }
20 
21  $query = 'CREATE TABLE ' . $store->prefix . '_saml_PersistentNameID (
22  _idp VARCHAR(256) NOT NULL,
23  _sp VARCHAR(256) NOT NULL,
24  _user VARCHAR(256) NOT NULL,
25  _value VARCHAR(40) NOT NULL,
26  UNIQUE (_idp, _sp, _user)
27  )';
28  $store->pdo->exec($query);
29 
30  $query = 'CREATE INDEX ' . $store->prefix . '_saml_PersistentNameID_idp_sp ON ' . $store->prefix . '_saml_PersistentNameID (_idp, _sp)';
31  $store->pdo->exec($query);
32 
33  $store->setTableVersion('saml_PersistentNameID', 1);
34  }
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query

◆ delete()

static sspmod_saml_IdP_SQLNameID::delete (   $idpEntityId,
  $spEntityId,
  $user 
)
static

Delete a NameID from the database.

Parameters
string$idpEntityIdThe IdP entityID.
string$spEntityIdThe SP entityID.
string$userThe user's unique identificator (e.g. username).

Definition at line 131 of file SQLNameID.php.

References $idpEntityId, PHPMailer\PHPMailer\$params, $query, $store, and $user.

132  {
133  assert(is_string($idpEntityId));
134  assert(is_string($spEntityId));
135  assert(is_string($user));
136 
137  $store = self::getStore();
138 
139  $params = array(
140  '_idp' => $idpEntityId,
141  '_sp' => $spEntityId,
142  '_user' => $user,
143  );
144 
145  $query = 'DELETE FROM ' . $store->prefix . '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user';
146  $query = $store->pdo->prepare($query);
147  $query->execute($params);
148  }
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
$user
Definition: migrateto20.php:57

◆ get()

static sspmod_saml_IdP_SQLNameID::get (   $idpEntityId,
  $spEntityId,
  $user 
)
static

Retrieve a NameID into from database.

Parameters
string$idpEntityIdThe IdP entityID.
string$spEntityIdThe SP entityID.
string$userThe user's unique identificator (e.g. username).
Returns
string|NULL $value The NameID value, or NULL of no NameID value was found.

Definition at line 96 of file SQLNameID.php.

References $idpEntityId, PHPMailer\PHPMailer\$params, $query, $row, $store, and $user.

Referenced by sspmod_saml_Auth_Process_SQLPersistentNameID\getValue().

97  {
98  assert(is_string($idpEntityId));
99  assert(is_string($spEntityId));
100  assert(is_string($user));
101 
102  $store = self::getStore();
103 
104  $params = array(
105  '_idp' => $idpEntityId,
106  '_sp' => $spEntityId,
107  '_user' => $user,
108  );
109 
110  $query = 'SELECT _value FROM ' . $store->prefix . '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user';
111  $query = $store->pdo->prepare($query);
112  $query->execute($params);
113 
114  $row = $query->fetch(PDO::FETCH_ASSOC);
115  if ($row === false) {
116  // No NameID found
117  return null;
118  }
119 
120  return $row['_value'];
121  }
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
$user
Definition: migrateto20.php:57
$row
+ Here is the caller graph for this function:

◆ getIdentities()

static sspmod_saml_IdP_SQLNameID::getIdentities (   $idpEntityId,
  $spEntityId 
)
static

Retrieve all federated identities for an IdP-SP pair.

Parameters
string$idpEntityIdThe IdP entityID.
string$spEntityIdThe SP entityID.
Returns
array Array of userid => NameID.

Definition at line 158 of file SQLNameID.php.

References $idpEntityId, PHPMailer\PHPMailer\$params, $query, $res, $row, and $store.

159  {
160  assert(is_string($idpEntityId));
161  assert(is_string($spEntityId));
162 
163  $store = self::getStore();
164 
165  $params = array(
166  '_idp' => $idpEntityId,
167  '_sp' => $spEntityId,
168  );
169 
170  $query = 'SELECT _user, _value FROM ' . $store->prefix . '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp';
171  $query = $store->pdo->prepare($query);
172  $query->execute($params);
173 
174  $res = array();
175  while (($row = $query->fetch(PDO::FETCH_ASSOC)) !== false) {
176  $res[$row['_user']] = $row['_value'];
177  }
178 
179  return $res;
180  }
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
foreach($_POST as $key=> $value) $res
$query
$row

◆ getStore()

static sspmod_saml_IdP_SQLNameID::getStore ( )
staticprivate

Retrieve the SQL datastore.

Will also ensure that the NameID table is present.

Returns
SQL datastore.

Definition at line 44 of file SQLNameID.php.

References $store, and SimpleSAML\Store\getInstance().

45  {
47  if (!($store instanceof \SimpleSAML\Store\SQL)) {
48  throw new SimpleSAML_Error_Exception('SQL NameID store requires SimpleSAMLphp to be configured with a SQL datastore.');
49  }
50 
51  self::createTable($store);
52 
53  return $store;
54  }
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
Attribute-related utility methods.
static getInstance()
Retrieve our singleton instance.
Definition: Store.php:31
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: