summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2018-06-18 11:10:41 +0200
committerSimon Rettberg2018-06-18 11:10:41 +0200
commitfb9bcbcad0b522b131682ebbffb78ff87abd0bdd (patch)
tree7bbfab4af8894ec826eb6c51c4cfc464207b9727 /src/vsession.cpp
parentClean up globals.* (remove unused, rename constants, prefix) (diff)
downloadvmchooser2-fb9bcbcad0b522b131682ebbffb78ff87abd0bdd.tar.gz
vmchooser2-fb9bcbcad0b522b131682ebbffb78ff87abd0bdd.tar.xz
vmchooser2-fb9bcbcad0b522b131682ebbffb78ff87abd0bdd.zip
Add support for filtering by LDAP values from file
This is a temporary solution until we can do server-side filtering.
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 05b84a1..04d0ac2 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -14,6 +14,7 @@
#include "globals.h"
#include "vsession.h"
#include "sessionsiconholder.h"
+#include "userldapdata.h"
static QProcess _process;
@@ -43,7 +44,7 @@ void VSession::addNodeWithAttribute(const QString& nodeName,
QIcon VSession::icon() const {
QString icon(getAttribute("icon"));
SessionsIconHolder *iconHolder = SessionsIconHolder::get();
- if (icon.startsWith("http://")) {
+ if (icon.startsWith("http://") || icon.startsWith("https://")) {
// try to load icon from url
QIcon url_icon(iconHolder->getIcon(QUrl(icon)));
if (!url_icon.isNull()) {
@@ -169,11 +170,13 @@ ImgType VSession::imgtype() const {
bool VSession::isActive() const {
QString value(getAttribute("active"));
-
+ // Is disabled completely
if (value.compare("false") == 0) {
if (g_debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: active == false";
return false;
- } else if (value.count("/") == 1) {
+ }
+ // Check for date range
+ if (value.count("/") == 1) {
// try to interpret value as date range
// [YYYY-MM-DD]/[YYYY-MM-DD]
// eg. "1970-01-01/1971-01-01" from Jan 1st 1970 till Jan 1st 1971
@@ -202,7 +205,7 @@ bool VSession::isActive() const {
return false;
}
}
-
+ // Filtering by pool name
if (!g_currentPoolName.isEmpty()) {
QStringList pools = getAttribute("pools").split("\\s*,\\s*");
if (!pools.isEmpty() && !pools.contains(g_currentPoolName)) {
@@ -211,6 +214,19 @@ bool VSession::isActive() const {
return false;
}
}
+ // Filter by LDAP data
+ if (!UserLdapData::isEmpty()) {
+ QDomNode keywordsNode = eintrag_.namedItem("filters");
+ for (QDomElement el(keywordsNode.firstChildElement("filter"));
+ !el.isNull();
+ el = el.nextSiblingElement("filter")) {
+ if (el.attribute("type") != "LDAP")
+ continue;
+ if (UserLdapData::isAllowed(el.firstChildElement("key").text(), el.firstChildElement("value").text()))
+ return true;
+ }
+ return false;
+ }
return true;
}
@@ -337,6 +353,8 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
}
}
+ UserLdapData::init();
+
QDomElement settingsNode = doc.firstChildElement("settings");
for (QDomElement el(settingsNode.firstChildElement("eintrag"));
!el.isNull();