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