Cutelyst  2.3.0
authenticationuser.h
1 /*
2  * Copyright (C) 2013-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef AUTHENTICATIONUSER_H
19 #define AUTHENTICATIONUSER_H
20 
21 #include <QDataStream>
22 #include <QVariantMap>
23 
24 #include <Cutelyst/cutelyst_global.h>
25 #include <Cutelyst/paramsmultimap.h>
26 #include <Cutelyst/plugin.h>
27 
28 namespace Cutelyst {
29 
30 class AuthenticationRealm;
31 class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationUser
32 {
33  Q_GADGET
34 public:
39 
43  AuthenticationUser(const QVariant &id);
44  virtual ~AuthenticationUser();
45 
49  QVariant id() const;
50 
54  void setId(const QVariant &id);
55 
59  bool isNull() const;
60 
64  QString authRealm();
65 
69  void setAuthRealm(const QString &authRealm);
70 
71  inline QVariantMap data() const;
72 
73  inline void setData(const QVariantMap &data);
74 
75  inline void insert(const QString &key, const QVariant &value);
76 
77  inline QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
78 
79  inline operator QVariant() const {
80  return QVariant::fromValue(m_data);
81  }
82 
83 protected:
84  QVariantMap m_data;
85 };
86 
87 QVariantMap AuthenticationUser::data() const
88 {
89  return m_data;
90 }
91 
92 void AuthenticationUser::setData(const QVariantMap &data)
93 {
94  m_data = data;
95 }
96 
97 void AuthenticationUser::insert(const QString &key, const QVariant &value)
98 {
99  m_data.insert(key, value);
100 }
101 
102 QVariant AuthenticationUser::value(const QString &key, const QVariant &defaultValue) const
103 {
104  return m_data.value(key, defaultValue);
105 }
106 
107 }
108 
109 Q_DECLARE_METATYPE(Cutelyst::AuthenticationUser)
110 QDataStream &operator<<(QDataStream &out, const Cutelyst::AuthenticationUser &myObj);
111 QDataStream &operator>>(QDataStream &in, Cutelyst::AuthenticationUser &myObj);
112 
113 QDebug CUTELYST_PLUGIN_AUTHENTICATION_EXPORT operator<<(QDebug dbg, const Cutelyst::AuthenticationUser &user);
114 
115 #endif // AUTHENTICATIONUSER_H
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7