TreeFrogFramework  2.8
taccessvalidator.h
Go to the documentation of this file.
1 #pragma once
2 #include <QList>
3 #include <QString>
4 #include <QStringList>
5 #include <TGlobal>
6 
7 class TAbstractUser;
9 
10 
12 public:
14  virtual ~TAccessValidator() { }
15 
16  void setAllowDefault(bool allow = true) { allowDefault = allow; }
17  void setDenyDefault(bool deny = true) { allowDefault = !deny; }
18  void setAllowGroup(const QString &groupKey, const QString &action);
19  void setAllowGroup(const QString &groupKey, const QStringList &actions);
20  void setDenyGroup(const QString &groupKey, const QString &action);
21  void setDenyGroup(const QString &groupKey, const QStringList &actions);
22  void setAllowUser(const QString &identityKey, const QString &action);
23  void setAllowUser(const QString &identityKey, const QStringList &actions);
24  void setDenyUser(const QString &identityKey, const QString &action);
25  void setDenyUser(const QString &identityKey, const QStringList &actions);
26  void setAllowUnauthenticatedUser(const QString &action);
27  void setAllowUnauthenticatedUser(const QStringList &actions);
28  void setDenyUnauthenticatedUser(const QString &action);
29  void setDenyUnauthenticatedUser(const QStringList &actions);
30  void clear();
31  virtual bool validate(const TAbstractUser *user, const TActionController *controller) const;
32 
33 protected:
34  void addRules(int type, const QString &key, const QStringList &actions, bool allow);
35 
36  class AccessRule {
37  public:
38  enum Type {
39  Group = 0,
42  };
43 
44  AccessRule(int t, const QString &k, const QString &act, bool alw) :
45  type(t), key(k), action(act), allow(alw)
46  {
47  }
48 
49  int type {0};
50  QString key;
51  QString action;
52  bool allow {true};
53  };
54 
55  bool allowDefault {true};
56  QList<AccessRule> accessRules;
57 };
58 
59 
The TAbstractUser class is the abstract base class of users, providing functionality common to users.
Definition: tabstractuser.h:6
The AccessRule class is for internal use only.
Definition: taccessvalidator.h:36
Type
Definition: taccessvalidator.h:38
@ User
Definition: taccessvalidator.h:40
@ UnauthenticatedUser
Definition: taccessvalidator.h:41
QString key
Definition: taccessvalidator.h:50
QString action
Definition: taccessvalidator.h:51
AccessRule(int t, const QString &k, const QString &act, bool alw)
Definition: taccessvalidator.h:44
The TAccessValidator class provides validation of user access.
Definition: taccessvalidator.h:11
void setDenyDefault(bool deny=true)
Sets the default rule to deny any user to access to any action if deny is true; otherwise sets to all...
Definition: taccessvalidator.h:17
virtual ~TAccessValidator()
Definition: taccessvalidator.h:14
void setAllowDefault(bool allow=true)
Sets the default rule to allow all users to access to all actions if allow is true; otherwise sets to...
Definition: taccessvalidator.h:16
QList< AccessRule > accessRules
Definition: taccessvalidator.h:56
The TActionController class is the base class of all action controllers.
Definition: tactioncontroller.h:21
#define T_CORE_EXPORT
Definition: tdeclexport.h:28