My Project
identityinfo.cpp
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  * Copyright (C) 2011-2016 Canonical Ltd.
6  *
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 
24 #include <QVariant>
25 
26 #include "debug.h"
27 #include "libsignoncommon.h"
28 #include "identityinfo.h"
29 #include "identityinfoimpl.h"
30 #include "identity.h"
31 
32 namespace SignOn {
33 
35  impl(new IdentityInfoImpl)
36 {
37  qRegisterMetaType<IdentityInfo>("SignOn::IdentityInfo");
38 
39  if (qMetaTypeId<IdentityInfo>() < QMetaType::User)
40  BLAME() << "IdentityInfo::IdentityInfo() - "
41  "IdentityInfo meta type not registered.";
42 }
43 
45  impl(new IdentityInfoImpl)
46 {
47  *impl = *other.impl;
48 }
49 
51 {
52  *impl = *other.impl;
53  return *this;
54 }
55 
56 IdentityInfo::IdentityInfo(const QString &caption,
57  const QString &userName,
58  const QMap<MethodName, MechanismsList> &methods):
59  impl(new IdentityInfoImpl)
60 {
61  impl->setCaption(caption);
62  impl->setUserName(userName);
63  impl->setMethods(methods);
64 }
65 
67 {
68  if (impl) delete impl;
69  impl = 0;
70 }
71 
72 void IdentityInfo::setId(const quint32 id)
73 {
74  impl->setId(id);
75 }
76 
77 quint32 IdentityInfo::id() const
78 {
79  return impl->id();
80 }
81 
82 void IdentityInfo::setUserName(const QString &userName)
83 {
84  impl->setUserName(userName);
85 }
86 
87 const QString IdentityInfo::userName() const
88 {
89  return impl->userName();
90 }
91 
92 void IdentityInfo::setCaption(const QString &caption)
93 {
94  impl->setCaption(caption);
95 }
96 
97 const QString IdentityInfo::caption() const
98 {
99  return impl->caption();
100 }
101 
102 void IdentityInfo::setRealms(const QStringList &realms)
103 {
104  impl->setRealms(realms);
105 }
106 
107 QStringList IdentityInfo::realms() const
108 {
109  return impl->realms();
110 }
111 
112 void IdentityInfo::setOwner(const QString &ownerToken)
113 {
114  impl->setOwners(QStringList() << ownerToken);
115 }
116 
117 QString IdentityInfo::owner() const
118 {
119  return impl->owners().value(0);
120 }
121 
122 void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
123 {
124  impl->setAccessControlList(accessControlList);
125 }
126 
128 {
129  return impl->accessControlList();
130 }
131 
132 QString IdentityInfo::secret() const
133 {
134  return impl->secret();
135 }
136 
137 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
138 {
139  impl->setSecret(secret);
140  impl->setStoreSecret(storeSecret);
141 }
142 
144 {
145  return impl->storeSecret();
146 }
147 
148 void IdentityInfo::setStoreSecret(const bool storeSecret)
149 {
150  impl->setStoreSecret(storeSecret);
151 }
152 
154  const MechanismsList &mechanismsList)
155 {
156  impl->updateMethod(method, mechanismsList);
157 }
158 
160 {
161  impl->removeMethod(method);
162 }
163 
165 {
166  impl->setType(type);
167 }
168 
170 {
171  return impl->type();
172 }
173 
174 QList<MethodName> IdentityInfo::methods() const
175 {
176  return impl->methods().keys();
177 }
178 
180 {
181  return impl->methods().value(method, QStringList());
182 }
183 
184 void IdentityInfo::setRefCount(qint32 refCount)
185 {
186  /* This method is a mistake, let's keep it for binary compatibility as a
187  * no-op. */
188  Q_UNUSED(refCount);
189 }
190 
192 {
193  return impl->refCount();
194 }
195 
196 } //namespace SignOn
SignOn::IdentityInfo::caption
const QString caption() const
Returns a human-readable representation of the identity.
Definition: identityinfo.cpp:97
SignOn::IdentityInfo::userName
const QString userName() const
Returns the username.
Definition: identityinfo.cpp:87
SignOn::IdentityInfo::CredentialsType
CredentialsType
Values used to describe the type of the identity.
Definition: identityinfo.h:69
SignOn::IdentityInfo::setRefCount
void setRefCount(qint32 refCount)
Sets the refcount into identity info.
Definition: identityinfo.cpp:184
SignOn::IdentityInfo::IdentityInfo
IdentityInfo()
Creates a new empty IdentityInfo object.
Definition: identityinfo.cpp:34
SignOn::IdentityInfo::setOwner
void setOwner(const QString &ownerToken)
Sets application token that owns identity, therefore defining the applications that will be able to m...
Definition: identityinfo.cpp:112
SignOn::IdentityInfo::type
CredentialsType type() const
Retrieves the identity type from identity info.
Definition: identityinfo.cpp:169
SignOn::IdentityInfo::~IdentityInfo
~IdentityInfo()
Destructor.
Definition: identityinfo.cpp:66
SignOn::IdentityInfo::setId
void setId(const quint32 id)
Sets the numeric identifier for the credentials record.
Definition: identityinfo.cpp:72
SignOn::IdentityInfo::secret
QString secret() const
Gets the secret.
Definition: identityinfo.cpp:132
SignOn::IdentityInfo::setRealms
void setRealms(const QStringList &realms)
Sets the realms, e.g.
Definition: identityinfo.cpp:102
SignOn::IdentityInfo::removeMethod
void removeMethod(const MethodName &method)
Removes a method from identity info.
Definition: identityinfo.cpp:159
SignOn::IdentityInfo
Contains identity information.
Definition: identityinfo.h:58
SignOn::MechanismsList
QStringList MechanismsList
Defines a string list as a list of mechanisms.
Definition: identityinfo.h:48
SignOn::IdentityInfo::realms
QStringList realms() const
Gets the realms, e.g.
Definition: identityinfo.cpp:107
SignOn::IdentityInfo::setCaption
void setCaption(const QString &caption)
Sets a human readable caption of the identity.
Definition: identityinfo.cpp:92
SignOn::IdentityInfo::refCount
qint32 refCount() const
Retrieves the refcount from identity info.
Definition: identityinfo.cpp:191
SignOn::IdentityInfo::setStoreSecret
void setStoreSecret(const bool storeSecret)
Sets whether the secret is stored or not.
Definition: identityinfo.cpp:148
SignOn::IdentityInfo::id
quint32 id() const
Returns the identity identifier.
Definition: identityinfo.cpp:77
SignOn::MethodName
QString MethodName
Defines a string as an authentication method.
Definition: identityinfo.h:42
SignOn
Definition: async-dbus-proxy.cpp:41
SignOn::IdentityInfo::mechanisms
MechanismsList mechanisms(const MethodName &method) const
Lists the all mechanisms for certain method in identity info.
Definition: identityinfo.cpp:179
SignOn::IdentityInfo::setUserName
void setUserName(const QString &userName)
Sets the username.
Definition: identityinfo.cpp:82
SignOn::IdentityInfo::isStoringSecret
bool isStoringSecret() const
Returns whether secret is to be stored.
Definition: identityinfo.cpp:143
SignOn::IdentityInfo::owner
QString owner() const
Gets the owner application token that is defining the applications that are able to modify this speci...
Definition: identityinfo.cpp:117
SignOn::IdentityInfo::accessControlList
QStringList accessControlList() const
Gets the list of access control application tokens defining the applications that are able to access ...
Definition: identityinfo.cpp:127
SignOn::IdentityInfo::setMethod
void setMethod(const MethodName &method, const MechanismsList &mechanismsList)
Sets the method into identity info.
Definition: identityinfo.cpp:153
SignOn::IdentityInfo::setSecret
void setSecret(const QString &secret, const bool storeSecret=true)
Sets the secret.
Definition: identityinfo.cpp:137
SignOn::IdentityInfo::operator=
IdentityInfo & operator=(const IdentityInfo &other)
Assignment operator.
Definition: identityinfo.cpp:50
SignOn::IdentityInfo::setType
void setType(CredentialsType type)
Sets the type into identity info.
Definition: identityinfo.cpp:164
SignOn::IdentityInfo::methods
QList< MethodName > methods() const
Lists all methods in identity info.
Definition: identityinfo.cpp:174
SignOn::IdentityInfo::setAccessControlList
void setAccessControlList(const QStringList &accessControlList)
Sets the list of access control application tokens, therefore defining the applications that will be ...
Definition: identityinfo.cpp:122