signon 8.54

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

signonidentity.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of signon
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation.
5 * Copyright (C) 2011 Intel Corporation.
6 * Copyright (C) 2013 Canonical Ltd.
7 *
8 * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
9 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
10 * Contact: Jussi Laako <jussi.laako@linux.intel.com>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * version 2.1 as published by the Free Software Foundation.
15 *
16 * This library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 * 02110-1301 USA
25 */
26
27 #include <iostream>
28 #include <QVariantMap>
29
30 #include "signond-common.h"
31 #include "signonidentity.h"
32 #include "signonui_interface.h"
33 #include "SignOn/uisessiondata.h"
34 #include "SignOn/uisessiondata_priv.h"
35 #include "signoncommon.h"
36
37 #include "accesscontrolmanagerhelper.h"
38 #include "signonidentityadaptor.h"
39
40 #define SIGNON_RETURN_IF_CAM_UNAVAILABLE(_ret_arg_) do { \
41 if (!(CredentialsAccessManager::instance()->credentialsSystemOpened())) { \
42 sendErrorReply(internalServerErrName, \
43 internalServerErrStr + \
44 QLatin1String("Could not access Signon Database."));\
45 return _ret_arg_; \
46 } \
47 } while(0)
48
49 namespace SignonDaemonNS {
50
51 const QString internalServerErrName = SIGNOND_INTERNAL_SERVER_ERR_NAME;
52 const QString internalServerErrStr = SIGNOND_INTERNAL_SERVER_ERR_STR;
53
54 class PendingCallWatcherWithContext: public QDBusPendingCallWatcher
55 {
56 Q_OBJECT
57
58 public:
59 PendingCallWatcherWithContext(const QDBusPendingCall &call,
60 SignonIdentity *parent):
61 QDBusPendingCallWatcher(call, parent),
62 m_connection(parent->connection()),
63 m_message(parent->message())
64 {
65 }
66
67 PendingCallWatcherWithContext(const QDBusPendingCall &call,
68 const QDBusConnection &connection,
69 const QDBusMessage &message,
70 SignonIdentity *parent):
71 QDBusPendingCallWatcher(call, parent),
72 m_connection(connection),
73 m_message(message)
74 {
75 }
76
77 const QDBusConnection &connection() const { return m_connection; }
78 const QDBusMessage &message() const { return m_message; }
79
80 private:
81 QDBusConnection m_connection;
82 QDBusMessage m_message;
83 };
84
85 SignonIdentity::SignonIdentity(quint32 id, int timeout,
86 SignonDaemon *parent):
87 SignonDisposable(timeout, parent),
88 m_pInfo(NULL)
89 {
90 m_id = id;
91
92 (void)new SignonIdentityAdaptor(this);
93
94 /*
95 * creation of unique name for the given identity
96 * */
97 static quint32 incr = 0;
98 QString objectName = SIGNOND_DAEMON_OBJECTPATH + QLatin1String("/Identity_")
99 + QString::number(incr++, 16);
100 setObjectName(objectName);
101
102 m_signonui = new SignonUiAdaptor(SIGNON_UI_SERVICE,
103 SIGNON_UI_DAEMON_OBJECTPATH,
104 QDBusConnection::sessionBus(),
105 this);
106 }
107
108 SignonIdentity::~SignonIdentity()
109 {
110 emit unregistered();
111
112 delete m_signonui;
113 delete m_pInfo;
114 }
115
116 SignonIdentity *SignonIdentity::createIdentity(quint32 id, SignonDaemon *parent)
117 {
118 return new SignonIdentity(id, parent->identityTimeout(), parent);
119 }
120
121 void SignonIdentity::destroy()
122 {
123 deleteLater();
124 }
125
126 SignonIdentityInfo SignonIdentity::queryInfo(bool &ok, bool queryPassword)
127 {
128 ok = true;
129
130 bool needLoadFromDB = true;
131 if (m_pInfo) {
132 needLoadFromDB = false;
133 if (queryPassword && m_pInfo->password().isEmpty()) {
134 needLoadFromDB = true;
135 }
136 }
137
138 if (needLoadFromDB) {
139 if (m_pInfo != 0) {
140 delete m_pInfo;
141 }
142
143 CredentialsDB *db =
144 CredentialsAccessManager::instance()->credentialsDB();
145 m_pInfo = new SignonIdentityInfo(db->credentials(m_id, queryPassword));
146
147 if (db->lastError().isValid()) {
148 ok = false;
149 delete m_pInfo;
150 m_pInfo = NULL;
151 return SignonIdentityInfo();
152 }
153 }
154
155 /* Make sure that we clear the password, if the caller doesn't need it */
156 SignonIdentityInfo info = *m_pInfo;
157 if (!queryPassword) {
158 info.setPassword(QString());
159 }
160 return info;
161 }
162
163 bool SignonIdentity::addReference(const QString &reference)
164 {
165 TRACE() << "addReference: " << reference;
166
167 SIGNON_RETURN_IF_CAM_UNAVAILABLE(false);
168
169 CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
170 if (db == NULL) {
171 BLAME() << "NULL database handler object.";
172 return false;
173 }
174 const QDBusContext &context = static_cast<QDBusContext>(*this);
175 QString appId =
176 AccessControlManagerHelper::instance()->appIdOfPeer(
177 context.connection(),
178 context.message());
179 keepInUse();
180 return db->addReference(m_id, appId, reference);
181 }
182
183 bool SignonIdentity::removeReference(const QString &reference)
184 {
185 TRACE() << "removeReference: " << reference;
186
187 SIGNON_RETURN_IF_CAM_UNAVAILABLE(false);
188
189 CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
190 if (db == NULL) {
191 BLAME() << "NULL database handler object.";
192 return false;
193 }
194 const QDBusContext &context = static_cast<QDBusContext>(*this);
195 QString appId =
196 AccessControlManagerHelper::instance()->appIdOfPeer(
197 context.connection(),
198 context.message());
199 keepInUse();
200 return db->removeReference(m_id, appId, reference);
201 }
202
203 quint32 SignonIdentity::requestCredentialsUpdate(const QString &displayMessage)
204 {
205 SIGNON_RETURN_IF_CAM_UNAVAILABLE(SIGNOND_NEW_IDENTITY);
206
207 bool ok;
208 SignonIdentityInfo info = queryInfo(ok, false);
209
210 if (!ok) {
211 BLAME() << "Identity not found.";
212 sendErrorReply(SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME,
213 SIGNOND_IDENTITY_NOT_FOUND_ERR_STR);
214 return SIGNOND_NEW_IDENTITY;
215 }
216 if (!info.storePassword()) {
217 BLAME() << "Password cannot be stored.";
218 sendErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
219 SIGNOND_STORE_FAILED_ERR_STR);
220 return SIGNOND_NEW_IDENTITY;
221 }
222
223 //delay dbus reply, ui interaction might take long time to complete
224 setDelayedReply(true);
225
226 //create ui request to ask password
227 QVariantMap uiRequest;
228 uiRequest.insert(SSOUI_KEY_QUERYPASSWORD, true);
229 uiRequest.insert(SSOUI_KEY_USERNAME, info.userName());
230 uiRequest.insert(SSOUI_KEY_MESSAGE, displayMessage);
231 uiRequest.insert(SSOUI_KEY_CAPTION, info.caption());
232
233 TRACE() << "Waiting for reply from signon-ui";
234 PendingCallWatcherWithContext *watcher =
235 new PendingCallWatcherWithContext(m_signonui->queryDialog(uiRequest),
236 this);
237 connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
238 this, SLOT(queryUiSlot(QDBusPendingCallWatcher*)));
239
240 setAutoDestruct(false);
241 return 0;
242 }
243
244 QVariantMap SignonIdentity::getInfo()
245 {
246 TRACE() << "QUERYING INFO";
247
248 SIGNON_RETURN_IF_CAM_UNAVAILABLE(QVariantMap());
249
250 bool ok;
251 SignonIdentityInfo info = queryInfo(ok, false);
252
253 if (!ok) {
254 TRACE();
255 sendErrorReply(SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME,
256 SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_STR +
257 QLatin1String("Database querying error occurred."));
258 return QVariantMap();
259 }
260
261 if (info.isNew()) {
262 TRACE();
263 sendErrorReply(SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME,
264 SIGNOND_IDENTITY_NOT_FOUND_ERR_STR);
265 return QVariantMap();
266 }
267
268 keepInUse();
269 return info.toMap();
270 }
271
272 void SignonIdentity::queryUserPassword(const QVariantMap &params,
273 const QDBusConnection &connection,
274 const QDBusMessage &message)
275 {
276 TRACE() << "Waiting for reply from signon-ui";
277 PendingCallWatcherWithContext *watcher =
278 new PendingCallWatcherWithContext(m_signonui->queryDialog(params),
279 connection, message, this);
280 connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this,
281 SLOT(verifyUiSlot(QDBusPendingCallWatcher*)));
282
283 setAutoDestruct(false);
284 }
285
286 bool SignonIdentity::verifyUser(const QVariantMap &params)
287 {
288 SIGNON_RETURN_IF_CAM_UNAVAILABLE(false);
289
290 bool ok;
291 SignonIdentityInfo info = queryInfo(ok, true);
292
293 if (!ok) {
294 BLAME() << "Identity not found.";
295 sendErrorReply(SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME,
296 SIGNOND_IDENTITY_NOT_FOUND_ERR_STR);
297 return false;
298 }
299 if (!info.storePassword() || info.password().isEmpty()) {
300 BLAME() << "Password is not stored.";
301 sendErrorReply(SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME,
302 SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_STR);
303 return false;
304 }
305
306 //delay dbus reply, ui interaction might take long time to complete
307 setDelayedReply(true);
308
309 //create ui request to ask password
310 QVariantMap uiRequest;
311 uiRequest.unite(params);
312 uiRequest.insert(SSOUI_KEY_QUERYPASSWORD, true);
313 uiRequest.insert(SSOUI_KEY_USERNAME, info.userName());
314 uiRequest.insert(SSOUI_KEY_CAPTION, info.caption());
315
316 queryUserPassword(uiRequest, connection(), message());
317 return false;
318 }
319
320 bool SignonIdentity::verifySecret(const QString &secret)
321 {
322 SIGNON_RETURN_IF_CAM_UNAVAILABLE(false);
323
324 bool ok;
325 queryInfo(ok);
326 if (!ok) {
327 TRACE();
328 sendErrorReply(SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME,
329 SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_STR +
330 QLatin1String("Database querying error occurred."));
331 return false;
332 }
333
334 CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
335 bool ret = db->checkPassword(m_pInfo->id(), m_pInfo->userName(), secret);
336
337 keepInUse();
338 return ret;
339 }
340
341 void SignonIdentity::remove()
342 {
343 SIGNON_RETURN_IF_CAM_UNAVAILABLE();
344
345 CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
346 if ((db == 0) || !db->removeCredentials(m_id)) {
347 TRACE() << "Error occurred while inserting/updating credentials.";
348 sendErrorReply(SIGNOND_REMOVE_FAILED_ERR_NAME,
349 SIGNOND_REMOVE_FAILED_ERR_STR +
350 QLatin1String("Database error occurred."));
351 return;
352 }
353 setDelayedReply(true);
354 setAutoDestruct(false);
355 PendingCallWatcherWithContext *watcher =
356 new PendingCallWatcherWithContext(m_signonui->removeIdentityData(m_id),
357 this);
358 connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
359 this, SLOT(removeCompleted(QDBusPendingCallWatcher*)));
360 keepInUse();
361 }
362
363 void SignonIdentity::removeCompleted(QDBusPendingCallWatcher *call)
364 {
365 Q_ASSERT(call != NULL);
366
367 setAutoDestruct(true);
368 call->deleteLater();
369
370 PendingCallWatcherWithContext *context =
371 qobject_cast<PendingCallWatcherWithContext*>(call);
372 QDBusPendingReply<> signOnUiReply = *call;
373 bool ok = !signOnUiReply.isError();
374 TRACE() << (ok ? "removeIdentityData succeeded" : "removeIdentityData failed");
375
376 emit infoUpdated((int)SignOn::IdentityRemoved);
377
378 QDBusMessage reply = context->message().createReply();
379 context->connection().send(reply);
380 }
381
382 bool SignonIdentity::signOut()
383 {
384 TRACE() << "Signout request. Identity ID: " << id();
385 /*
386 * - If the identity is stored (thus registered here)
387 * signal 'sign out' to all identities subsribed to this object,
388 * otherwise the only identity subscribed to this is the newly
389 * created client side identity, which called this method.
390 * - This is just a safety check, as the client identity - if it is a new
391 * one - should not inform server side to sign out.
392 */
393 if (id() != SIGNOND_NEW_IDENTITY) {
394 //clear stored sessiondata
395 CredentialsDB *db =
396 CredentialsAccessManager::instance()->credentialsDB();
397 if ((db == 0) || !db->removeData(m_id)) {
398 TRACE() << "clear data failed";
399 }
400
401 setDelayedReply(true);
402 setAutoDestruct(false);
403 PendingCallWatcherWithContext *watcher =
404 new PendingCallWatcherWithContext(m_signonui->removeIdentityData(m_id),
405 this);
406 connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
407 this, SLOT(signOutCompleted(QDBusPendingCallWatcher*)));
408 }
409 keepInUse();
410 return true;
411 }
412
413 void SignonIdentity::signOutCompleted(QDBusPendingCallWatcher *call)
414 {
415 Q_ASSERT(call != NULL);
416
417 setAutoDestruct(true);
418 call->deleteLater();
419
420 PendingCallWatcherWithContext *context =
421 qobject_cast<PendingCallWatcherWithContext*>(call);
422 QDBusPendingReply<> signOnUiReply = *call;
423 bool ok = !signOnUiReply.isError();
424 TRACE() << (ok ? "removeIdentityData succeeded" : "removeIdentityData failed");
425
426 emit infoUpdated((int)SignOn::IdentitySignedOut);
427
428 QDBusMessage reply = context->message().createReply();
429 reply << ok;
430 context->connection().send(reply);
431 }
432
433 quint32 SignonIdentity::store(const QVariantMap &info)
434 {
435 keepInUse();
436 SIGNON_RETURN_IF_CAM_UNAVAILABLE(SIGNOND_NEW_IDENTITY);
437
438 QString secret = info.value(SIGNOND_IDENTITY_INFO_SECRET).toString();
439 const QDBusContext &context = static_cast<QDBusContext>(*this);
440 QString appId =
441 AccessControlManagerHelper::instance()->appIdOfPeer(
442 context.connection(),
443 context.message());
444
445 bool storeSecret = info.value(SIGNOND_IDENTITY_INFO_STORESECRET).toBool();
446 QVariant container = info.value(SIGNOND_IDENTITY_INFO_AUTHMETHODS);
447 MethodMap methods =
448 qdbus_cast<MethodMap>(container.value<QDBusArgument>());
449
450 //Add creator to owner list if it has AID
451 QStringList ownerList =
452 info.value(SIGNOND_IDENTITY_INFO_OWNER).toStringList();
453 if (!appId.isNull())
454 ownerList.append(appId);
455
456 if (m_pInfo == 0) {
457 m_pInfo = new SignonIdentityInfo(info);
458 m_pInfo->setMethods(methods);
459 m_pInfo->setOwnerList(ownerList);
460 } else {
461 QString userName =
462 info.value(SIGNOND_IDENTITY_INFO_USERNAME).toString();
463 QString caption =
464 info.value(SIGNOND_IDENTITY_INFO_CAPTION).toString();
465 QStringList realms =
466 info.value(SIGNOND_IDENTITY_INFO_REALMS).toStringList();
467 QStringList accessControlList =
468 info.value(SIGNOND_IDENTITY_INFO_ACL).toStringList();
469 int type = info.value(SIGNOND_IDENTITY_INFO_TYPE).toInt();
470
471 m_pInfo->setUserName(userName);
472 m_pInfo->setCaption(caption);
473 m_pInfo->setMethods(methods);
474 m_pInfo->setRealms(realms);
475 m_pInfo->setAccessControlList(accessControlList);
476 m_pInfo->setOwnerList(ownerList);
477 m_pInfo->setType(type);
478 }
479
480 m_pInfo->setPassword(secret);
481 m_pInfo->setStorePassword(storeSecret);
482 m_id = storeCredentials(*m_pInfo);
483
484 if (m_id == SIGNOND_NEW_IDENTITY) {
485 sendErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
486 SIGNOND_STORE_FAILED_ERR_STR);
487 }
488
489 return m_id;
490 }
491
492 quint32 SignonIdentity::storeCredentials(const SignonIdentityInfo &info)
493 {
494 CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
495 if (db == NULL) {
496 BLAME() << "NULL database handler object.";
497 return SIGNOND_NEW_IDENTITY;
498 }
499
500 bool newIdentity = info.isNew();
501
502 if (newIdentity)
503 m_id = db->insertCredentials(info);
504 else
505 db->updateCredentials(info);
506
507 if (db->errorOccurred()) {
508 if (newIdentity)
509 m_id = SIGNOND_NEW_IDENTITY;
510
511 TRACE() << "Error occurred while inserting/updating credentials.";
512 } else {
513 if (m_pInfo) {
514 delete m_pInfo;
515 m_pInfo = NULL;
516 }
517 Q_EMIT stored(this);
518
519 TRACE() << "FRESH, JUST STORED CREDENTIALS ID:" << m_id;
520 emit infoUpdated((int)SignOn::IdentityDataUpdated);
521 }
522 return m_id;
523 }
524
525 void SignonIdentity::queryUiSlot(QDBusPendingCallWatcher *call)
526 {
527 TRACE();
528 Q_ASSERT(call != NULL);
529
530 setAutoDestruct(true);
531
532 PendingCallWatcherWithContext *context =
533 qobject_cast<PendingCallWatcherWithContext*>(call);
534 const QDBusMessage &message = context->message();
535 const QDBusConnection &connection = context->connection();
536
537 QDBusMessage errReply;
538 QDBusPendingReply<QVariantMap> reply = *call;
539 call->deleteLater();
540
541 QVariantMap resultParameters;
542 if (!reply.isError() && reply.count()) {
543 resultParameters = reply.argumentAt<0>();
544 } else {
545 errReply = message.createErrorReply(
546 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
547 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
548 connection.send(errReply);
549 return;
550 }
551
552 if (!resultParameters.contains(SSOUI_KEY_ERROR)) {
553 //no reply code
554 errReply = message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
555 SIGNOND_INTERNAL_SERVER_ERR_STR);
556 connection.send(errReply);
557 return;
558 }
559
560 int errorCode = resultParameters.value(SSOUI_KEY_ERROR).toInt();
561 TRACE() << "error: " << errorCode;
562 if (errorCode != QUERY_ERROR_NONE) {
563 if (errorCode == QUERY_ERROR_CANCELED)
564 errReply =
565 message.createErrorReply(
566 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
567 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
568 else
569 errReply =
570 message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
571 QString(QLatin1String("signon-ui call returned error %1")).
572 arg(errorCode));
573
574 connection.send(errReply);
575 return;
576 }
577
578 if (resultParameters.contains(SSOUI_KEY_PASSWORD)) {
579 CredentialsDB *db =
580 CredentialsAccessManager::instance()->credentialsDB();
581 if (db == NULL) {
582 BLAME() << "NULL database handler object.";
583 errReply = message.createErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
584 SIGNOND_STORE_FAILED_ERR_STR);
585 connection.send(errReply);
586 return;
587 }
588
589 //store new password
590 if (m_pInfo) {
591 m_pInfo->setPassword(resultParameters[SSOUI_KEY_PASSWORD].toString());
592
593 quint32 ret = db->updateCredentials(*m_pInfo);
594 delete m_pInfo;
595 m_pInfo = NULL;
596 if (ret != SIGNOND_NEW_IDENTITY) {
597 QDBusMessage dbusreply = message.createReply();
598 dbusreply << quint32(m_id);
599 connection.send(dbusreply);
600 return;
601 } else{
602 BLAME() << "Error during update";
603 }
604 }
605 }
606
607 //this should not happen, return error
608 errReply = message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
609 SIGNOND_INTERNAL_SERVER_ERR_STR);
610 connection.send(errReply);
611 return;
612 }
613
614 void SignonIdentity::verifyUiSlot(QDBusPendingCallWatcher *call)
615 {
616 TRACE();
617 Q_ASSERT(call != NULL);
618
619 setAutoDestruct(true);
620
621 PendingCallWatcherWithContext *context =
622 qobject_cast<PendingCallWatcherWithContext*>(call);
623 const QDBusMessage &message = context->message();
624 const QDBusConnection &connection = context->connection();
625
626 QDBusMessage errReply;
627 QDBusPendingReply<QVariantMap> reply = *call;
628 call->deleteLater();
629 QVariantMap resultParameters;
630 if (!reply.isError() && reply.count()) {
631 resultParameters = reply.argumentAt<0>();
632 } else {
633 errReply =
634 message.createErrorReply(
635 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
636 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
637 connection.send(errReply);
638 return;
639 }
640
641 if (!resultParameters.contains(SSOUI_KEY_ERROR)) {
642 //no reply code
643 errReply = message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
644 SIGNOND_INTERNAL_SERVER_ERR_STR);
645 connection.send(errReply);
646 return;
647 }
648
649 int errorCode = resultParameters.value(SSOUI_KEY_ERROR).toInt();
650 TRACE() << "error: " << errorCode;
651 if (errorCode != QUERY_ERROR_NONE) {
652 if (errorCode == QUERY_ERROR_CANCELED)
653 errReply = message.createErrorReply(
654 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
655 SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
656 else if (errorCode == QUERY_ERROR_FORGOT_PASSWORD)
657 errReply = message.createErrorReply(
658 SIGNOND_FORGOT_PASSWORD_ERR_NAME,
659 SIGNOND_FORGOT_PASSWORD_ERR_STR);
660 else
661 errReply = message.createErrorReply(
662 SIGNOND_INTERNAL_SERVER_ERR_NAME,
663 QString(QLatin1String("signon-ui call "
664 "returned error %1")).
665 arg(errorCode));
666
667 connection.send(errReply);
668 return;
669 }
670
671 if (resultParameters.contains(SSOUI_KEY_PASSWORD)) {
672 CredentialsDB *db =
673 CredentialsAccessManager::instance()->credentialsDB();
674 if (db == NULL) {
675 BLAME() << "NULL database handler object.";
676 errReply = message.createErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
677 SIGNOND_STORE_FAILED_ERR_STR);
678 connection.send(errReply);
679 return;
680 }
681
682 //compare passwords
683 if (m_pInfo) {
684 bool ret =
685 m_pInfo->password() == resultParameters[SSOUI_KEY_PASSWORD].
686 toString();
687
688 if (!ret && resultParameters.contains(SSOUI_KEY_CONFIRMCOUNT)) {
689 int count = resultParameters[SSOUI_KEY_CONFIRMCOUNT].toInt();
690 TRACE() << "retry count:" << count;
691 if (count > 0) { //retry
692 resultParameters[SSOUI_KEY_CONFIRMCOUNT] = (count-1);
693 resultParameters[SSOUI_KEY_MESSAGEID] =
694 QUERY_MESSAGE_NOT_AUTHORIZED;
695 queryUserPassword(resultParameters, connection, message);
696 return;
697 } else {
698 //TODO show error note here if needed
699 }
700 }
701 delete m_pInfo;
702 m_pInfo = NULL;
703 QDBusMessage dbusreply = message.createReply();
704 dbusreply << ret;
705 connection.send(dbusreply);
706 return;
707 }
708 }
709 //this should not happen, return error
710 errReply = message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
711 SIGNOND_INTERNAL_SERVER_ERR_STR);
712 connection.send(errReply);
713 return;
714 }
715
716 } //namespace SignonDaemonNS
717
718 #include "signonidentity.moc"
SignonDaemonNS::CredentialsDB::removeData
bool removeData(const quint32 id, const QString &method=QString())
Definition: credentialsdb.cpp:1494
SignonDaemonNS::SignonIdentity::infoUpdated
void infoUpdated(int)
SignonDaemonNS::internalServerErrName
const QString internalServerErrName
Definition: signondaemon.cpp:244
SignonDaemonNS::SignonIdentityInfo::setRealms
void setRealms(const QStringList &realms)
Definition: signonidentityinfo.h:85
SIGNON_RETURN_IF_CAM_UNAVAILABLE
#define SIGNON_RETURN_IF_CAM_UNAVAILABLE(_ret_arg_)
Definition: signonidentity.cpp:40
SignonDaemonNS::SignonIdentity::id
quint32 id() const
Definition: signonidentity.h:62
SignonDaemonNS::AccessControlManagerHelper::appIdOfPeer
QString appIdOfPeer(const QDBusConnection &peerConnection, const QDBusMessage &peerMessage)
Looks up for the application identifier of a specific client process.
Definition: accesscontrolmanagerhelper.cpp:137
SignonDaemonNS::SignonIdentity::requestCredentialsUpdate
quint32 requestCredentialsUpdate(const QString &message)
Definition: signonidentity.cpp:203
SignonDaemonNS::SignonIdentityInfo::storePassword
bool storePassword() const
Definition: signonidentityinfo.h:80
BLAME
#define BLAME()
Definition: debug.h:32
SignonDaemonNS::AccessControlManagerHelper::instance
static AccessControlManagerHelper * instance()
Definition: accesscontrolmanagerhelper.cpp:44
SignonDaemonNS::SignonIdentity::addReference
bool addReference(const QString &reference)
Definition: signonidentity.cpp:163
SignonDaemonNS::SignonIdentityInfo::caption
QString caption() const
Definition: signonidentityinfo.h:83
SignonDaemonNS::SignonIdentityInfo::setStorePassword
void setStorePassword(bool storePassword)
Definition: signonidentityinfo.h:77
SignonDaemonNS::SignonIdentityInfo::setMethods
void setMethods(const MethodMap &methods)
Definition: signonidentityinfo.h:88
SignonDaemonNS::SignonIdentity::destroy
void destroy()
Performs any predestruction operations and the destruction itself.
Definition: signonidentity.cpp:121
SignonDaemonNS::SignonIdentityInfo::password
QString password() const
Definition: signonidentityinfo.h:76
SignonDaemonNS::SignonIdentity::verifyUiSlot
void verifyUiSlot(QDBusPendingCallWatcher *call)
Definition: signonidentity.cpp:614
SignonDaemonNS::SignonIdentity::PendingCallWatcherWithContext
friend class PendingCallWatcherWithContext
Definition: signonidentity.h:54
SignonDaemonNS::SignonIdentityInfo::id
quint32 id() const
Definition: signonidentityinfo.h:68
SignonDaemonNS::CredentialsDB::insertCredentials
quint32 insertCredentials(const SignonIdentityInfo &info)
Definition: credentialsdb.cpp:1397
SignonDaemonNS::CredentialsDB::updateCredentials
quint32 updateCredentials(const SignonIdentityInfo &info)
Definition: credentialsdb.cpp:1405
SignonDaemonNS::SignonIdentityInfo::setType
void setType(const int type)
Definition: signonidentityinfo.h:99
SignonDaemonNS::CredentialsDB::lastError
SignOn::CredentialsDBError lastError() const
Definition: credentialsdb.cpp:1335
signond-common.h
SignonDaemonNS::SignonIdentity::verifySecret
bool verifySecret(const QString &secret)
Definition: signonidentity.cpp:320
SignonDaemonNS::SignonDaemon
Daemon core.
Definition: signondaemon.h:105
SignonDaemonNS::SignonIdentityInfo::setCaption
void setCaption(const QString &caption)
Definition: signonidentityinfo.h:82
SignonDaemonNS::SignonIdentityInfo::setOwnerList
void setOwnerList(const QStringList &owner)
Definition: signonidentityinfo.h:102
SignonDaemonNS::CredentialsDB::addReference
bool addReference(const quint32 id, const QString &token, const QString &reference)
Definition: credentialsdb.cpp:1532
SignonDaemonNS::SignonIdentity::verifyUser
bool verifyUser(const QVariantMap &params)
Definition: signonidentity.cpp:286
SignonDaemonNS::SignonIdentityInfo::userName
QString userName() const
Definition: signonidentityinfo.h:71
SignonDaemonNS::CredentialsDB::removeCredentials
bool removeCredentials(const quint32 id)
Definition: credentialsdb.cpp:1427
SignonDaemonNS::SignonIdentity::createIdentity
static SignonIdentity * createIdentity(quint32 id, SignonDaemon *parent)
Definition: signonidentity.cpp:116
SignonDaemonNS::SignonIdentity::signOut
bool signOut()
Definition: signonidentity.cpp:382
SignonDaemonNS::CredentialsAccessManager::instance
static CredentialsAccessManager * instance()
Returns CAM instance.
Definition: credentialsaccessmanager.cpp:160
SIGNON_UI_SERVICE
#define SIGNON_UI_SERVICE
Definition: signond-common.h:56
SignonDaemonNS::SignonIdentity::unregistered
void unregistered()
SignonDaemonNS::SignonIdentityInfo::setPassword
void setPassword(const QString &password)
Definition: signonidentityinfo.h:75
SignonDaemonNS::SignonIdentity::queryUiSlot
void queryUiSlot(QDBusPendingCallWatcher *call)
Definition: signonidentity.cpp:525
SignonDaemonNS::CredentialsDB::credentials
SignonIdentityInfo credentials(const quint32 id, bool queryPassword=true)
Definition: credentialsdb.cpp:1362
SignonDaemonNS::SignonIdentityInfo::setAccessControlList
void setAccessControlList(const QStringList &acl)
Definition: signonidentityinfo.h:92
SignonUiAdaptor
Definition: signonui_interface.h:41
SignonDaemonNS::SignonIdentity::remove
void remove()
Definition: signonidentity.cpp:341
SignonUiAdaptor::queryDialog
QDBusPendingCall queryDialog(const QVariantMap &parameters)
Definition: signonui_interface.cpp:49
SignonDaemonNS::CredentialsDB::removeReference
bool removeReference(const quint32 id, const QString &token, const QString &reference=QString())
Definition: credentialsdb.cpp:1540
signonidentityadaptor.h
SignonDaemonNS::internalServerErrStr
const QString internalServerErrStr
Definition: signondaemon.cpp:245
SignonUiAdaptor::removeIdentityData
QDBusPendingCall removeIdentityData(quint32 id)
Definition: signonui_interface.cpp:84
SignonDaemonNS::SignonIdentity::store
quint32 store(const QVariantMap &info)
Definition: signonidentity.cpp:433
TRACE
#define TRACE()
Definition: debug.h:28
SignonDaemonNS::CredentialsDB::errorOccurred
bool errorOccurred() const
Definition: credentialsdb.h:103
SignonDaemonNS::SignonIdentity::removeReference
bool removeReference(const QString &reference)
Definition: signonidentity.cpp:183
SignonDaemonNS::SignonIdentity::getInfo
QVariantMap getInfo()
Definition: signonidentity.cpp:244
SignonDaemonNS::SignonIdentity
Daemon side representation of identity.
Definition: signonidentity.h:50
signonidentity.h
SignonDaemonNS::SignonIdentity::stored
void stored(SignonIdentity *identity)
SignonDaemonNS::SignonIdentityInfo::isNew
bool isNew() const
Definition: signonidentityinfo.h:66
SignonDaemonNS::SignonIdentityInfo
Daemon side representation of identity information.
Definition: signonidentityinfo.h:43
signonui_interface.h
SignonDaemonNS::CredentialsDB::checkPassword
bool checkPassword(const quint32 id, const QString &username, const QString &password)
Definition: credentialsdb.cpp:1347
SignonDaemonNS::CredentialsAccessManager::credentialsDB
CredentialsDB * credentialsDB() const
Definition: credentialsaccessmanager.cpp:524
SignonDaemonNS::CredentialsDB
Manages the credentials I/O.
Definition: credentialsdb.h:66
accesscontrolmanagerhelper.h
Helper class for access control-related functionality.
SIGNON_UI_DAEMON_OBJECTPATH
#define SIGNON_UI_DAEMON_OBJECTPATH
Definition: signond-common.h:57
SignonDaemonNS::SignonIdentity::storeCredentials
quint32 storeCredentials(const SignonIdentityInfo &info)
Definition: signonidentity.cpp:492
SignonDaemonNS::SignonIdentityInfo::setUserName
void setUserName(const QString &userName)
Definition: signonidentityinfo.h:70
SignonDaemonNS::SignonDisposable::setAutoDestruct
void setAutoDestruct(bool value=true) const
Mark the object as used.
Definition: signondisposable.cpp:75
SignonDaemonNS::SignonIdentity::queryInfo
SignonIdentityInfo queryInfo(bool &ok, bool queryPassword=true)
Definition: signonidentity.cpp:126
SignonDaemonNS::SignonIdentityInfo::toMap
const QVariantMap toMap() const
Definition: signonidentityinfo.cpp:107
SignonDaemonNS::SignonDisposable::keepInUse
void keepInUse() const
Mark the object as used.
Definition: signondisposable.cpp:57
QMap< MethodName, MechanismsList >
SignonDaemonNS::SignonDaemon::identityTimeout
int identityTimeout() const
Returns the number of seconds of inactivity after which identity objects might be automatically delet...
Definition: signondaemon.cpp:603