signon 8.54

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

- File List
- File Members

credentialsdb.h
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of signon
4 *
5 * Copyright (C) 2009-2010 Nokia Corporation.
6 * Copyright (C) 2012 Canonical Ltd.
7 *
8 * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
9 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * version 2.1 as published by the Free Software Foundation.
14 *
15 * This library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
24 */
25
32 #ifndef CREDENTIALS_DB_H
33 #define CREDENTIALS_DB_H
34
35 #include <QObject>
36 #include <QtSql>
37
38 #include "SignOn/abstract-secrets-storage.h"
39 #include "signonidentityinfo.h"
40
41 #define SSO_MAX_TOKEN_STORAGE (4*1024) // 4 kB for token store/identity/method
42
43 class TestDatabase;
44
45 namespace SignonDaemonNS {
46
51 enum IdentityFlags {
52 Validated = 0x0001,
53 RememberPassword = 0x0002,
54 UserNameIsSecret = 0x0004,
55 };
56
57 class MetaDataDB;
58 class SecretsCache;
59
66 class CredentialsDB: public QObject
67 {
68 Q_OBJECT
69 Q_DISABLE_COPY(CredentialsDB)
70
71 friend class ::TestDatabase;
72
73 class ErrorMonitor
74 {
75 public:
76 /* The constructor clears the errors in CredentialsDB, MetaDataDB and
77 * SecretsDB. */
78 ErrorMonitor(CredentialsDB *db);
79 /* The destructor collects the errors and sets
80 * CredentialsDB::_lastError to the appropriate value. */
81 ~ErrorMonitor();
82 private:
83 CredentialsDB *_db;
84 };
85 friend class ErrorMonitor;
86
87 public:
88 CredentialsDB(const QString &metaDataDbName,
89 SignOn::AbstractSecretsStorage *secretsStorage);
90 ~CredentialsDB();
91
92 bool init();
98 bool openSecretsDB(const QString &secretsDbName);
99 bool isSecretsDBOpen();
100 void closeSecretsDB();
101
102 SignOn::CredentialsDBError lastError() const;
103 bool errorOccurred() const { return lastError().isValid(); };
104
105 QStringList methods(const quint32 id,
106 const QString &securityToken = QString());
107 bool checkPassword(const quint32 id,
108 const QString &username, const QString &password);
109 SignonIdentityInfo credentials(const quint32 id, bool queryPassword = true);
110 QList<SignonIdentityInfo> credentials(const QMap<QString, QString> &filter);
111
112 quint32 insertCredentials(const SignonIdentityInfo &info);
113 quint32 updateCredentials(const SignonIdentityInfo &info);
114 bool removeCredentials(const quint32 id);
115
116 bool clear();
117
118 QStringList accessControlList(const quint32 identityId);
119 QStringList ownerList(const quint32 identityId);
120 QString credentialsOwnerSecurityToken(const quint32 identityId);
121
122 QVariantMap loadData(const quint32 id, const QString &method);
123 bool storeData(const quint32 id,
124 const QString &method,
125 const QVariantMap &data);
126 bool removeData(const quint32 id, const QString &method = QString());
127
128 bool addReference(const quint32 id,
129 const QString &token,
130 const QString &reference);
131 bool removeReference(const quint32 id,
132 const QString &token,
133 const QString &reference = QString());
134 QStringList references(const quint32 id,
135 const QString &token = QString());
136
137 private:
138 SignOn::AbstractSecretsStorage *secretsStorage;
139 SecretsCache *m_secretsCache;
140 MetaDataDB *metaDataDB;
141 SignOn::CredentialsDBError _lastError;
142 SignOn::CredentialsDBError noSecretsDB;
143 };
144
145 } // namespace SignonDaemonNS
146
147 #endif // CREDENTIALSDB_H
SignonDaemonNS::CredentialsDB::removeData
bool removeData(const quint32 id, const QString &method=QString())
Definition: credentialsdb.cpp:1494
SignonDaemonNS::CredentialsDB::references
QStringList references(const quint32 id, const QString &token=QString())
Definition: credentialsdb.cpp:1548
SignonDaemonNS::UserNameIsSecret
Definition: credentialsdb.h:54
SignonDaemonNS::CredentialsDB::accessControlList
QStringList accessControlList(const quint32 identityId)
Definition: credentialsdb.cpp:1513
SignonDaemonNS::RememberPassword
Definition: credentialsdb.h:53
SignonDaemonNS::MetaDataDB
Definition: credentialsdb_p.h:246
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::SecretsCache
Caches credentials or BLOB authentication data.
Definition: credentialsdb_p.h:45
SignonDaemonNS::CredentialsDB::lastError
SignOn::CredentialsDBError lastError() const
Definition: credentialsdb.cpp:1335
SignonDaemonNS::Validated
Definition: credentialsdb.h:52
SignonDaemonNS::CredentialsDB::init
bool init()
Definition: credentialsdb.cpp:1305
SignonDaemonNS::CredentialsDB::storeData
bool storeData(const quint32 id, const QString &method, const QVariantMap &data)
Definition: credentialsdb.cpp:1469
SignonDaemonNS::CredentialsDB::addReference
bool addReference(const quint32 id, const QString &token, const QString &reference)
Definition: credentialsdb.cpp:1532
signonidentityinfo.h
SignonDaemonNS::CredentialsDB::removeCredentials
bool removeCredentials(const quint32 id)
Definition: credentialsdb.cpp:1427
SignonDaemonNS::CredentialsDB::loadData
QVariantMap loadData(const quint32 id, const QString &method)
Definition: credentialsdb.cpp:1451
SignonDaemonNS::CredentialsDB::closeSecretsDB
void closeSecretsDB()
Definition: credentialsdb.cpp:1330
SignonDaemonNS::CredentialsDB::credentialsOwnerSecurityToken
QString credentialsOwnerSecurityToken(const quint32 identityId)
Definition: credentialsdb.cpp:1525
SignonDaemonNS::CredentialsDB::credentials
SignonIdentityInfo credentials(const quint32 id, bool queryPassword=true)
Definition: credentialsdb.cpp:1362
SignonDaemonNS::IdentityFlags
IdentityFlags
Flags to be stored into database.
Definition: credentialsdb.h:51
SignonDaemonNS::CredentialsDB::isSecretsDBOpen
bool isSecretsDBOpen()
Definition: credentialsdb.cpp:1325
SignonDaemonNS::CredentialsDB::removeReference
bool removeReference(const quint32 id, const QString &token, const QString &reference=QString())
Definition: credentialsdb.cpp:1540
SignonDaemonNS::CredentialsDB::openSecretsDB
bool openSecretsDB(const QString &secretsDbName)
This method will open the DB file containing the user secrets.
Definition: credentialsdb.cpp:1310
SignonDaemonNS::CredentialsDB::CredentialsDB
CredentialsDB(const QString &metaDataDbName, SignOn::AbstractSecretsStorage *secretsStorage)
Definition: credentialsdb.cpp:1281
SignonDaemonNS::CredentialsDB::errorOccurred
bool errorOccurred() const
Definition: credentialsdb.h:103
SignonDaemonNS::CredentialsDB::methods
QStringList methods(const quint32 id, const QString &securityToken=QString())
Definition: credentialsdb.cpp:1340
SignonDaemonNS::SignonIdentityInfo
Daemon side representation of identity information.
Definition: signonidentityinfo.h:43
SignonDaemonNS::CredentialsDB::checkPassword
bool checkPassword(const quint32 id, const QString &username, const QString &password)
Definition: credentialsdb.cpp:1347
SignonDaemonNS::CredentialsDB::~CredentialsDB
~CredentialsDB()
Definition: credentialsdb.cpp:1292
SignonDaemonNS::CredentialsDB
Manages the credentials I/O.
Definition: credentialsdb.h:66
SignonDaemonNS::CredentialsDB::ownerList
QStringList ownerList(const quint32 identityId)
Definition: credentialsdb.cpp:1519
SignonDaemonNS::CredentialsDB::ErrorMonitor
friend class ErrorMonitor
Definition: credentialsdb.h:85
SignonDaemonNS::CredentialsDB::clear
bool clear()
Definition: credentialsdb.cpp:1439
QMap
Definition: backupifadaptor.h:19
QList
Definition: backupifadaptor.h:18