signon  8.42
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  void setStorePassword(bool storePassword) {
79  m_storePassword = storePassword;
80  }
81  bool storePassword() const { return m_storePassword; }
82 
83  void setCaption(const QString &caption) { m_caption = caption; }
84  QString caption() const { return m_caption; }
85 
86  void setRealms(const QStringList &realms) { m_realms = realms; }
87  QStringList realms() const { return m_realms; }
88 
89  void setMethods(const MethodMap &methods)
90  { m_methods = methods; }
91  MethodMap methods() const { return m_methods; }
92 
93  void setAccessControlList(const QStringList &acl)
94  { m_accessControlList = acl; }
95  QStringList accessControlList() const { return m_accessControlList; }
96 
97  void setValidated(bool validated) { m_validated = validated; }
98  bool validated() const { return m_validated; }
99 
100  void setType(const int type) { m_type = type; }
101  int type() const { return m_type; }
102 
103  void setOwnerList(const QStringList &owner) { m_ownerList = owner; }
104  QStringList ownerList() const { return m_ownerList; }
105 
106  bool checkMethodAndMechanism(const QString &method,
107  const QString &mechanism,
108  QString &allowedMechanism);
109 
110 private:
111  quint32 m_id;
112  QString m_userName;
113  QString m_password;
114  bool m_storePassword;
115  QString m_caption;
116  MethodMap m_methods;
117  QStringList m_realms;
118  QStringList m_accessControlList;
119  QStringList m_ownerList;
120  int m_type;
121  int m_refCount;
122  bool m_validated;
123  bool m_isUserNameSecret;
124 }; //struct SignonIdentityInfo
125 
126 } //namespace SignonDaemonNS
127 
128 Q_DECLARE_METATYPE(SignonDaemonNS::MethodMap)
129 
130 #endif // SIGNONIDENTITYINFO_H