Cutelyst  2.5.0
authenticationuser.cpp
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 #include "authenticationuser.h"
19 
20 #include <QDataStream>
21 #include <QDebug>
22 
23 using namespace Cutelyst;
24 
26 {
27 
28 }
29 
31 {
32  setId(id);
33 }
34 
35 AuthenticationUser::~AuthenticationUser()
36 {
37 }
38 
39 QVariant AuthenticationUser::id() const
40 {
41  return m_data.value(QStringLiteral("id")).toString();
42 }
43 
44 void AuthenticationUser::setId(const QVariant &id)
45 {
46  m_data.insert(QStringLiteral("id"), id);
47 }
48 
50 {
51  return m_data.isEmpty();
52 }
53 
55 {
56  return m_data.value(QStringLiteral("authRealm")).toString();
57 }
58 
60 {
61  m_data.insert(QStringLiteral("authRealm"), authRealm);
62 }
63 
64 QDataStream &operator<<(QDataStream &out, const AuthenticationUser &user)
65 {
66  out << user.data();
67  return out;
68 }
69 
70 QDataStream &operator>>(QDataStream &in, AuthenticationUser &user)
71 {
72  QVariantMap map;
73  in >> map;
74  user.setData(map);
75  return in;
76 }
77 
78 QDebug operator<<(QDebug dbg, const AuthenticationUser &user)
79 {
80  const QVariantMap map = user.data();
81  const bool oldSetting = dbg.autoInsertSpaces();
82  dbg.nospace() << "AuthenticationUser(";
83  for (auto it = map.constBegin();
84  it != map.constEnd(); ++it) {
85  dbg << '(' << it.key() << ", " << it.value() << ')';
86  }
87  dbg << ')';
88  dbg.setAutoInsertSpaces(oldSetting);
89  return dbg.maybeSpace();
90 }
91 
92 #include "moc_authenticationuser.cpp"
void setId(const QVariant &id)
Sets the unique user id restored from the store.
bool isNull() const
Returns true if the object is null.
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
QString authRealm()
Returns the authentication realm from which this user was retrieved.
void setAuthRealm(const QString &authRealm)
Sets the authentication realm from which this user was retrieved.
AuthenticationUser()
Constructs a new AuthenticationUser object.