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