- Main Page
- Related Pages
- Classes
- Files

- File List

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
33 IdentityInfo::IdentityInfo():
34 impl(new IdentityInfoImpl(this))
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 impl->m_id = 0;
43 impl->m_storeSecret = false;
44 }
45
46 IdentityInfo::IdentityInfo(const IdentityInfo &other):
47 impl(new IdentityInfoImpl(this))
48 {
49 impl->copy(*(other.impl));
50 }
51
52 IdentityInfo &IdentityInfo::operator=(const IdentityInfo &other)
53 {
54 impl->copy(*(other.impl));
55 return *this;
56 }
57
58 IdentityInfo::IdentityInfo(const QString &caption,
59 const QString &userName,
60 const QMap<MethodName, MechanismsList> &methods):
61 impl(new IdentityInfoImpl(this))
62 {
63 impl->m_caption = caption;
64 impl->m_userName = userName;
65 impl->m_isEmpty = false;
66 impl->m_authMethods = methods;
67 }
68
69 IdentityInfo::~IdentityInfo()
70 {
71 if (impl) delete impl;
72 impl = 0;
73 }
74
75 void IdentityInfo::setId(const quint32 id)
76 {
77 impl->m_id = id;
78 }
79
80 quint32 IdentityInfo::id() const
81 {
82 return impl->m_id;
83 }
84
85 void IdentityInfo::setUserName(const QString &userName)
86 {
87 impl->m_userName = userName;
88 impl->m_isEmpty = false;
89 }
90
91 const QString IdentityInfo::userName() const
92 {
93 return impl->m_userName;
94 }
95
96 void IdentityInfo::setCaption(const QString &caption)
97 {
98 impl->m_caption = caption;
99 impl->m_isEmpty = false;
100 }
101
102 const QString IdentityInfo::caption() const
103 {
104 return impl->m_caption;
105 }
106
107 void IdentityInfo::setRealms(const QStringList &realms)
108 {
109 impl->m_realms = realms;
110 }
111
112 QStringList IdentityInfo::realms() const
113 {
114 return impl->m_realms;
115 }
116
117 void IdentityInfo::setOwner(const QString &ownerToken)
118 {
119 impl->m_owner = ownerToken;
120 }
121
122 QString IdentityInfo::owner() const
123 {
124 return impl->m_owner;
125 }
126
127 void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
128 {
129 impl->m_accessControlList = accessControlList;
130 impl->m_isEmpty = false;
131 }
132
133 QStringList IdentityInfo::accessControlList() const
134 {
135 return impl->m_accessControlList;
136 }
137
138 QString IdentityInfo::secret() const
139 {
140 return impl->m_secret;
141 }
142
143 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
144 {
145 impl->m_secret = secret;
146 impl->m_storeSecret = storeSecret;
147 impl->m_isEmpty = false;
148 }
149
150 bool IdentityInfo::isStoringSecret() const
151 {
152 return impl->m_storeSecret;
153 }
154
155 void IdentityInfo::setStoreSecret(const bool storeSecret)
156 {
157 impl->m_storeSecret = storeSecret;
158 }
159
160 void IdentityInfo::setMethod(const MethodName &method,
161 const MechanismsList &mechanismsList)
162 {
163 if (impl->hasMethod(method))
164 impl->updateMethod(method, mechanismsList);
165 else
166 impl->addMethod(method, mechanismsList);
167 }
168
169 void IdentityInfo::removeMethod(const MethodName &method)
170 {
171 impl->removeMethod(method);
172 }
173
174 void IdentityInfo::setType(IdentityInfo::CredentialsType type)
175 {
176 impl->setType(type);
177 }
178
179 IdentityInfo::CredentialsType IdentityInfo::type() const
180 {
181 return impl->type();
182 }
183
184 QList<MethodName> IdentityInfo::methods() const
185 {
186 return impl->m_authMethods.keys();
187 }
188
189 MechanismsList IdentityInfo::mechanisms(const MethodName &method) const
190 {
191 return impl->m_authMethods.value(method, QStringList());
192 }
193
194 void IdentityInfo::setRefCount(qint32 refCount)
195 {
196 impl->setRefCount(refCount);
197 }
198
199 qint32 IdentityInfo::refCount() const
200 {
201 return impl->refCount();
202 }
203
204 } //namespace SignOn
SignOn::MechanismsList
QStringList MechanismsList
Defines a string list as a list of mechanisms.
Definition: identityinfo.h:48
SignOn::IdentityInfo::caption
const QString caption() const
Returns a human-readable representation of the identity.
Definition: identityinfo.cpp:102
SignOn::MethodName
QString MethodName
Defines a string as an authentication method.
Definition: identityinfo.h:42
SignOn::IdentityInfo::CredentialsType
CredentialsType
Values used to describe the type of the identity.
Definition: identityinfo.h:69
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:133
SignOn::IdentityInfo::id
quint32 id() const
Returns the identity identifier.
Definition: identityinfo.cpp:80
SignOn::IdentityInfo::setUserName
void setUserName(const QString &userName)
Sets the username.
Definition: identityinfo.cpp:85
SignOn::IdentityInfo::IdentityInfo
IdentityInfo()
Creates a new empty IdentityInfo object.
Definition: identityinfo.cpp:33
SignOn::IdentityInfo::setSecret
void setSecret(const QString &secret, const bool storeSecret=true)
Sets the secret.
Definition: identityinfo.cpp:143
SignOn::IdentityInfo::setMethod
void setMethod(const MethodName &method, const MechanismsList &mechanismsList)
Sets the method into identity info.
Definition: identityinfo.cpp:160
SignOn::IdentityInfo::userName
const QString userName() const
Returns the username.
Definition: identityinfo.cpp:91
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:122
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:127
SignOn::IdentityInfo::isStoringSecret
bool isStoringSecret() const
Returns whether secret is to be stored.
Definition: identityinfo.cpp:150
SignOn::IdentityInfo::operator=
IdentityInfo & operator=(const IdentityInfo &other)
Assignment operator.
Definition: identityinfo.cpp:52
SignOn::IdentityInfo
Contains identity information.
Definition: identityinfo.h:57
SignOn::IdentityInfo::setType
void setType(CredentialsType type)
Sets the type into identity info.
Definition: identityinfo.cpp:174
SignOn::IdentityInfo::secret
QString secret() const
Gets the secret.
Definition: identityinfo.cpp:138
SignOn::IdentityInfo::setCaption
void setCaption(const QString &caption)
Sets a human readable caption of the identity.
Definition: identityinfo.cpp:96
SignOn::IdentityInfo::setRefCount
void setRefCount(qint32 refCount)
Sets the refcount into identity info.
Definition: identityinfo.cpp:194
SignOn::IdentityInfo::mechanisms
MechanismsList mechanisms(const MethodName &method) const
Lists the all mechanisms for certain method in identity info.
Definition: identityinfo.cpp:189
SignOn::IdentityInfo::methods
QList< MethodName > methods() const
Lists all methods in identity info.
Definition: identityinfo.cpp:184
SignOn::IdentityInfo::refCount
qint32 refCount() const
Retrieves the refcount from identity info.
Definition: identityinfo.cpp:199
SignOn::IdentityInfo::~IdentityInfo
~IdentityInfo()
Destructor.
Definition: identityinfo.cpp:69
SignOn::IdentityInfo::realms
QStringList realms() const
Gets the realms, e.g.
Definition: identityinfo.cpp:112
SignOn::IdentityInfo::removeMethod
void removeMethod(const MethodName &method)
Removes a method from identity info.
Definition: identityinfo.cpp:169
SignOn::IdentityInfo::type
CredentialsType type() const
Retrieves the identity type from identity info.
Definition: identityinfo.cpp:179
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:117
SignOn::IdentityInfo::setRealms
void setRealms(const QStringList &realms)
Sets the realms, e.g.
Definition: identityinfo.cpp:107
SignOn::IdentityInfo::setId
void setId(const quint32 id)
Sets the numeric identifier for the credentials record.
Definition: identityinfo.cpp:75
SignOn::IdentityInfo::setStoreSecret
void setStoreSecret(const bool storeSecret)
Sets whether the secret is stored or not.
Definition: identityinfo.cpp:155