diff options
Diffstat (limited to 'src/global.cpp')
-rw-r--r-- | src/global.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/global.cpp b/src/global.cpp index ab2519b..91704f3 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -9,6 +9,7 @@ #include <QStringList> #include <QCryptographicHash> #include <QRegularExpression> +#include <QSet> bool Global::m_testMode = false; @@ -139,3 +140,29 @@ bool Global::isValidShibCreds(const QString &ustr, const QString &upass) && R_USER.match(ustr).hasMatch() && R_PASS.match(upass).hasMatch(); } + +QString Global::getCombinedIdpWhitelist() +{ + QDir configDir(QLatin1String("/opt/openslx/pam/shibboleth/whitelist")); + QFileInfoList fileInfoList = configDir.entryInfoList(QStringList() << "*.idp", QDir::Files); + + QSet<QString> list; + for (QFileInfo fileInfo : fileInfoList) { + QString filePath = fileInfo.absoluteFilePath(); + QFile f(filePath); + if (!f.open(QFile::ReadOnly)) + continue; + while (f.canReadLine()) { + list << QString::fromUtf8(f.readLine()); + } + f.close(); + } + QString retval; + for (const QString &s : list) { + if (!retval.isEmpty()) { + retval.append(QLatin1Char(' ')); + } + retval += s; + } + return retval; +} |