signon  8.41
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 <QMap>
27 #include <QStringList>
28 #include <QVariant>
29 
30 #include "signond/signoncommon.h"
31 
32 namespace SignonDaemonNS {
33 
34 typedef QString MethodName;
35 typedef QStringList MechanismsList;
36 typedef QMap<MethodName, MechanismsList> MethodMap;
37 
44 {
46  SignonIdentityInfo(const QVariantMap &info);
47  SignonIdentityInfo(const quint32 id,
48  const QString &userName,
49  const QString &password,
50  const bool storePassword,
51  const QString &caption,
52  const MethodMap &methods,
53  const QStringList &realms = QStringList(),
54  const QStringList &accessControlList = QStringList(),
55  const QStringList &ownerList = QStringList(),
56  int type = 0,
57  int refCount = 0,
58  bool validated = false);
59 
60  const QList<QVariant> toVariantList();
61  const QVariantMap toMap() const;
62 
63  bool operator== (const SignonIdentityInfo &other) const;
65 
66  void setNew() { m_id = SIGNOND_NEW_IDENTITY; }
67  bool isNew() const { return m_id == SIGNOND_NEW_IDENTITY; }
68  void setId(quint32 id) { m_id = id; }
69  quint32 id() const { return m_id; }
70 
71  void setUserName(const QString &userName) { m_userName = userName; }
72  QString userName() const { return m_userName; }
73  void setUserNameSecret(bool secret) { m_isUserNameSecret = secret; }
74  bool isUserNameSecret() const { return m_isUserNameSecret; }
75 
76  void setPassword(const QString &password) { m_password = password; }
77  QString password() const { return m_password; }
78  bool storePassword() const { return m_storePassword; }
79 
80  void setCaption(const QString &caption) { m_caption = caption; }
81  QString caption() const { return m_caption; }
82 
83  void setRealms(const QStringList &realms) { m_realms = realms; }
84  QStringList realms() const { return m_realms; }
85 
86  void setMethods(const MethodMap &methods)
87  { m_methods = methods; }
88  MethodMap methods() const { return m_methods; }
89 
90  void setAccessControlList(const QStringList &acl)
91  { m_accessControlList = acl; }
92  QStringList accessControlList() const { return m_accessControlList; }
93 
94  void setValidated(bool validated) { m_validated = validated; }
95  bool validated() const { return m_validated; }
96 
97  void setType(const int type) { m_type = type; }
98  int type() const { return m_type; }
99 
100  void setOwnerList(const QStringList &owner) { m_ownerList = owner; }
101  QStringList ownerList() const { return m_ownerList; }
102 
103  bool checkMethodAndMechanism(const QString &method,
104  const QString &mechanism,
105  QString &allowedMechanism);
106 
107 private:
108  quint32 m_id;
109  QString m_userName;
110  QString m_password;
111  bool m_storePassword;
112  QString m_caption;
113  MethodMap m_methods;
114  QStringList m_realms;
115  QStringList m_accessControlList;
116  QStringList m_ownerList;
117  int m_type;
118  int m_refCount;
119  bool m_validated;
120  bool m_isUserNameSecret;
121 }; //struct SignonIdentityInfo
122 
123 } //namespace SignonDaemonNS
124 
125 Q_DECLARE_METATYPE(SignonDaemonNS::MethodMap)
126 
127 #endif // SIGNONIDENTITYINFO_H