ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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, $params, $query, $spEntityId, $store, and array.

Referenced by sspmod_saml_Auth_Process_SQLPersistentNameID\getValue().

66  {
67  assert('is_string($idpEntityId)');
68  assert('is_string($spEntityId)');
69  assert('is_string($user)');
70  assert('is_string($value)');
71 
72  $store = self::getStore();
73 
74  $params = array(
75  '_idp' => $idpEntityId,
76  '_sp' => $spEntityId,
77  '_user' => $user,
78  '_value' => $value,
79  );
80 
81  $query = 'INSERT INTO ' . $store->prefix . '_saml_PersistentNameID (_idp, _sp, _user, _value) VALUES(:_idp, :_sp, :_user, :_value)';
82  $query = $store->pdo->prepare($query);
83  $query->execute($params);
84  }
$params
Definition: disable.php:11
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
Create styles array
The data for the language used.
+ 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.

15  {
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 129 of file SQLNameID.php.

References $idpEntityId, $params, $query, $store, and array.

129  {
130  assert('is_string($idpEntityId)');
131  assert('is_string($spEntityId)');
132  assert('is_string($user)');
133 
134  $store = self::getStore();
135 
136  $params = array(
137  '_idp' => $idpEntityId,
138  '_sp' => $spEntityId,
139  '_user' => $user,
140  );
141 
142  $query = 'DELETE FROM ' . $store->prefix . '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user';
143  $query = $store->pdo->prepare($query);
144  $query->execute($params);
145  }
$params
Definition: disable.php:11
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
Create styles array
The data for the language used.

◆ 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 95 of file SQLNameID.php.

References $idpEntityId, $params, $query, $row, $store, and array.

Referenced by sspmod_saml_Auth_Process_SQLPersistentNameID\getValue().

95  {
96  assert('is_string($idpEntityId)');
97  assert('is_string($spEntityId)');
98  assert('is_string($user)');
99 
100  $store = self::getStore();
101 
102  $params = array(
103  '_idp' => $idpEntityId,
104  '_sp' => $spEntityId,
105  '_user' => $user,
106  );
107 
108  $query = 'SELECT _value FROM ' . $store->prefix . '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user';
109  $query = $store->pdo->prepare($query);
110  $query->execute($params);
111 
112  $row = $query->fetch(PDO::FETCH_ASSOC);
113  if ($row === FALSE) {
114  // No NameID found
115  return NULL;
116  }
117 
118  return $row['_value'];
119  }
$params
Definition: disable.php:11
$idpEntityId
Definition: prp.php:12
$spEntityId
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
$query
Create styles array
The data for the language used.
+ 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 155 of file SQLNameID.php.

References $idpEntityId, $params, $query, $res, $row, $store, and array.

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

◆ 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().

44  {
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: