ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
SQLNameID.php
Go to the documentation of this file.
1
<?
php
2
8
class
sspmod_saml_IdP_SQLNameID
9
{
15
private
static
function
createTable
(\
SimpleSAML
\Store\SQL
$store
)
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
}
35
36
44
private
static
function
getStore
()
45
{
46
$store
=
\SimpleSAML\Store::getInstance
();
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
}
55
56
66
public
static
function
add
(
$idpEntityId
,
$spEntityId
,
$user
, $value)
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
}
86
87
96
public
static
function
get
(
$idpEntityId
,
$spEntityId
,
$user
)
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
}
122
123
131
public
static
function
delete
(
$idpEntityId
,
$spEntityId
,
$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
}
149
150
158
public
static
function
getIdentities
(
$idpEntityId
,
$spEntityId
)
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
}
181
}
$spEntityId
$spEntityId
Definition:
attributeserver.php:14
php
An exception for terminatinating execution or to throw for unit testing.
SimpleSAML\Store\getInstance
static getInstance()
Retrieve our singleton instance.
Definition:
Store.php:31
SimpleSAML_Error_Exception
Definition:
Exception.php:13
sspmod_saml_IdP_SQLNameID
Definition:
SQLNameID.php:9
sspmod_saml_IdP_SQLNameID\getIdentities
static getIdentities($idpEntityId, $spEntityId)
Retrieve all federated identities for an IdP-SP pair.
Definition:
SQLNameID.php:158
sspmod_saml_IdP_SQLNameID\add
static add($idpEntityId, $spEntityId, $user, $value)
Add a NameID into the database.
Definition:
SQLNameID.php:66
sspmod_saml_IdP_SQLNameID\getStore
static getStore()
Retrieve the SQL datastore.
Definition:
SQLNameID.php:44
sspmod_saml_IdP_SQLNameID\createTable
static createTable(\SimpleSAML\Store\SQL $store)
Create NameID table in SQL, if it is missing.
Definition:
SQLNameID.php:15
$store
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition:
getUserInfo.php:11
$user
$user
Definition:
migrateto20.php:57
$row
$row
Definition:
migrateto20.php:360
PHPMailer\PHPMailer\$params
$params
Definition:
get_oauth_token.php:84
SimpleSAML
Attribute-related utility methods.
$query
$query
Definition:
proxy_ylocal.php:13
$idpEntityId
$idpEntityId
Definition:
prp.php:12
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
libs
composer
vendor
simplesamlphp
simplesamlphp
modules
saml
lib
IdP
SQLNameID.php
Generated on Thu Oct 2 2025 19:01:19 for ILIAS by
1.9.4 (using
Doxyfile
)