signon  8.56
signonidentityinfo.h
Go to the documentation of this file.
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  *
6  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 #ifndef SIGNONIDENTITYINFO_H
24 #define SIGNONIDENTITYINFO_H
25 
26 #include <QStringList>
27 #include <QVariantMap>
28 
29 #include "signond/signoncommon.h"
30 
31 namespace SignonDaemonNS {
32 
33 typedef QString MethodName;
34 typedef QStringList MechanismsList;
36 
42 struct SignonIdentityInfo: protected QVariantMap
43 {
45  SignonIdentityInfo(const QVariantMap &info);
46 
47  const QVariantMap toMap() const;
48 
49  void setNew() { setId(SIGNOND_NEW_IDENTITY); }
50  bool isNew() const { return id() == SIGNOND_NEW_IDENTITY; }
51  void setId(quint32 id) { insert(SIGNOND_IDENTITY_INFO_ID, id); }
52  quint32 id() const { return value(SIGNOND_IDENTITY_INFO_ID, 0).toUInt(); }
53 
54  void setUserName(const QString &userName) {
55  insert(SIGNOND_IDENTITY_INFO_USERNAME, userName);
56  }
57 
58  QString userName() const {
59  return value(SIGNOND_IDENTITY_INFO_USERNAME).toString();
60  }
61 
62  void setUserNameSecret(bool secret) {
63  insert(SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET, secret);
64  }
65 
66  bool isUserNameSecret() const {
67  return value(SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET).toBool();
68  }
69 
70  void setPassword(const QString &password) {
71  insert(SIGNOND_IDENTITY_INFO_SECRET, password);
72  }
73 
74  QString password() const {
75  return value(SIGNOND_IDENTITY_INFO_SECRET).toString();
76  }
77 
78  void removeSecrets() {
79  remove(SIGNOND_IDENTITY_INFO_SECRET);
80  if (isUserNameSecret())
81  remove(SIGNOND_IDENTITY_INFO_USERNAME);
82  }
83 
84  bool hasSecrets() const {
85  return contains(SIGNOND_IDENTITY_INFO_SECRET) ||
86  (isUserNameSecret() && contains(SIGNOND_IDENTITY_INFO_USERNAME));
87  }
88 
90  insert(SIGNOND_IDENTITY_INFO_STORESECRET, storePassword);
91  }
92 
93  bool storePassword() const {
94  return value(SIGNOND_IDENTITY_INFO_STORESECRET).toBool();
95  }
96 
97  void setCaption(const QString &caption) {
98  insert(SIGNOND_IDENTITY_INFO_CAPTION, caption);
99  }
100 
101  QString caption() const {
102  return value(SIGNOND_IDENTITY_INFO_CAPTION).toString();
103  }
104 
105  void setRealms(const QStringList &realms) {
106  insert(SIGNOND_IDENTITY_INFO_REALMS, realms);
107  }
108 
109  QStringList realms() const {
110  return value(SIGNOND_IDENTITY_INFO_REALMS).toStringList();
111  }
112 
113  void setMethods(const MethodMap &methods) {
114  insert(SIGNOND_IDENTITY_INFO_AUTHMETHODS, QVariant::fromValue(methods));
115  }
116 
117  MethodMap methods() const {
118  return value(SIGNOND_IDENTITY_INFO_AUTHMETHODS).value<MethodMap>();
119  }
120 
121  void setAccessControlList(const QStringList &accessControlList) {
122  insert(SIGNOND_IDENTITY_INFO_ACL, accessControlList);
123  }
124 
125  QStringList accessControlList() const {
126  return value(SIGNOND_IDENTITY_INFO_ACL).toStringList();
127  }
128 
129  void setValidated(bool validated) {
130  insert(SIGNOND_IDENTITY_INFO_VALIDATED, validated);
131  }
132 
133  bool validated() const {
134  return value(SIGNOND_IDENTITY_INFO_VALIDATED).toBool();
135  }
136 
137  void setType(int type) {
138  insert(SIGNOND_IDENTITY_INFO_TYPE, type);
139  }
140 
141  int type() const {
142  return value(SIGNOND_IDENTITY_INFO_TYPE).toInt();
143  }
144 
145  void setOwnerList(const QStringList &owners) {
146  insert(SIGNOND_IDENTITY_INFO_OWNER, owners);
147  }
148 
149  QStringList ownerList() const {
150  return value(SIGNOND_IDENTITY_INFO_OWNER).toStringList();
151  }
152 
153  void setRefCount(int refCount) {
154  insert(SIGNOND_IDENTITY_INFO_REFCOUNT, refCount);
155  }
156 
157  int refCount() const {
158  return value(SIGNOND_IDENTITY_INFO_REFCOUNT).toInt();
159  }
160 
161  bool checkMethodAndMechanism(const QString &method,
162  const QString &mechanism,
163  QString &allowedMechanism);
164 }; //struct SignonIdentityInfo
165 
166 } //namespace SignonDaemonNS
167 
168 Q_DECLARE_METATYPE(SignonDaemonNS::MethodMap)
169 
170 #endif // SIGNONIDENTITYINFO_H
QStringList MechanismsList
void setRealms(const QStringList &realms)
void setStorePassword(bool storePassword)
void setMethods(const MethodMap &methods)
void setCaption(const QString &caption)
bool checkMethodAndMechanism(const QString &method, const QString &mechanism, QString &allowedMechanism)
void setPassword(const QString &password)
QMap< MethodName, MechanismsList > MethodMap
void setAccessControlList(const QStringList &accessControlList)
Daemon side representation of identity information.
void setUserName(const QString &userName)
const QVariantMap toMap() const
void setOwnerList(const QStringList &owners)