signon 8.54

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

- File List
- File Members

credentialsaccessmanager.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 *
7 * Contact: Aurel Popirtac <mailto:ext-Aurel.Popirtac@nokia.com>
8 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * version 2.1 as published by the Free Software Foundation.
13 *
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
31 #ifndef CREDENTIALS_ACCESS_MANAGER_H
32 #define CREDENTIALS_ACCESS_MANAGER_H
33
34 #include "accesscontrolmanagerhelper.h"
35 #include "credentialsdb.h"
36 #include "signonui_interface.h"
37
38 #include <QObject>
39 #include <QPointer>
40 #include <QFlags>
41 #include <QStringList>
42 #include <QVariantMap>
43
44 #include "SignOn/AbstractAccessControlManager"
45 #include "SignOn/AbstractCryptoManager"
46 #include "SignOn/AbstractKeyAuthorizer"
47 #include "SignOn/AbstractKeyManager"
48 #include "SignOn/AbstractSecretsStorage"
49 #include "SignOn/KeyHandler"
50
58 #define SIGNON_SECURE_STORAGE_NOT_AVAILABLE (QEvent::User + 1001)
59
66 #define SIGNON_SECURE_STORAGE_AVAILABLE (QEvent::User + 1002)
67
72 namespace SignonDaemonNS {
73
77 typedef QPointer<QObject> EventSender;
78
91 class SecureStorageEvent: public QEvent
92 {
93 public:
94 SecureStorageEvent(QEvent::Type type): QEvent(type), m_sender(0) {}
95
96 EventSender m_sender;
97 };
98
104 struct CAMConfiguration
105 {
110 CAMConfiguration();
111
116 void serialize(QIODevice *device);
117
121 QString metadataDBPath() const;
122
126 QString cryptoManagerName() const;
127
131 QString accessControlManagerName() const;
132
133 bool useEncryption() const;
134
138 QString secretsStorageName() const;
139
140 void setStoragePath(const QString &storagePath);
141
142 void addSetting(const QString &key, const QVariant &value) {
143 m_settings.insert(key, value);
144 }
145
146 QString m_storagePath;
147 QString m_dbName;
148 QString m_secretsDbName;
149 QByteArray m_encryptionPassphrase;
152 QVariantMap m_settings;
153 };
154
158 enum CredentialsAccessError {
159 NoError = 0,
160 NotInitialized,
161 AlreadyInitialized,
162 AccessCodeHandlerInitFailed,
163 AccessCodeNotReady,
164 FailedToFetchAccessCode,
165 AccessCodeInvalid,
166 EncryptionInUse,
167 CredentialsDbSetupFailed,
168 CredentialsDbMountFailed,
169 CredentialsDbUnmountFailed,
170 CredentialsDbDeletionFailed,
171 CredentialsDbAlreadyDeployed,
172 CredentialsDbAlreadyMounted,
173 CredentialsDbNotMounted,
174 CredentialsDbConnectionError,
175 CredentialsDbSqlError,
176 UnknownError
177 };
178
193 class CredentialsAccessManager: public QObject
194 {
195 Q_OBJECT
196
214 enum KeySwapAuthorizingMech {
215 Disabled = 0,
216 AuthorizedKeyRemovedFirst,
217 UnauthorizedKeyRemovedFirst
218 };
219
225 enum StorageUiCleanupFlag {
226 NoFlags = 0,
227 DisableCoreKeyAuthorization
231 };
232 Q_DECLARE_FLAGS(StorageUiCleanupFlags, StorageUiCleanupFlag)
233
234 public:
240 CredentialsAccessManager(const CAMConfiguration &configuration,
241 QObject *parent = 0);
242
249 ~CredentialsAccessManager();
250
254 static CredentialsAccessManager *instance();
255
262 bool init();
263
269 void finalize();
270
275 void addKeyManager(SignOn::AbstractKeyManager *keyManager);
276
283 bool initExtension(QObject *object);
284
285 QStringList backupFiles() const;
286
297 bool openCredentialsSystem();
298
308 bool closeCredentialsSystem();
309
320 bool deleteCredentialsSystem();
321
326 bool credentialsSystemOpened() const { return m_systemOpened; }
327
336 bool isCredentialsSystemReady() const;
337
341 CredentialsDB *credentialsDB() const;
342
346 const CAMConfiguration &configuration() const { return m_CAMConfiguration; }
347
352 CredentialsAccessError lastError() const { return m_error; }
353
358 bool keysAvailable() const;
359
360 Q_SIGNALS:
364 void credentialsSystemReady();
365
366 private Q_SLOTS:
367 void onKeyInserted(const SignOn::Key key);
368 void onLastAuthorizedKeyRemoved(const SignOn::Key key);
369 void onKeyRemoved(const SignOn::Key key);
370 void onKeyAuthorizationQueried(const SignOn::Key, int);
371 void onEncryptedFSMounted();
372 void onEncryptedFSUnmounting();
373
374 protected:
375 void customEvent(QEvent *event);
376
377 private:
378 bool createStorageDir();
379 bool openSecretsDB();
380 bool isSecretsDBOpen();
381 bool closeSecretsDB();
382 bool openMetaDataDB();
383 void closeMetaDataDB();
384 void replyToSecureStorageEventNotifiers();
385
386 private:
387 static CredentialsAccessManager *m_pInstance;
388
389 bool m_isInitialized;
390 bool m_systemOpened;
391 /* Flag indicating whether the system is ready or not.
392 * Currently the system is ready when all of the key managers have
393 * successfully reported all of the inserted keys.
394 */
395 mutable CredentialsAccessError m_error;
396 QList<SignOn::AbstractKeyManager *> keyManagers;
397
398 CredentialsDB *m_pCredentialsDB;
399 SignOn::AbstractCryptoManager *m_cryptoManager;
400 SignOn::KeyHandler *m_keyHandler;
401 SignOn::AbstractKeyAuthorizer *m_keyAuthorizer;
402 SignOn::AbstractSecretsStorage *m_secretsStorage;
403 CAMConfiguration m_CAMConfiguration;
404 SignOn::AbstractAccessControlManager *m_acManager;
405 AccessControlManagerHelper *m_acManagerHelper;
406
407 /* List of all the senders of a SecureStorageEvent. */
408 QList<EventSender> m_secureStorageEventNotifiers;
409 };
410
411 } //namespace SignonDaemonNS
412
413 #endif // CREDENTIALS_ACCESS_MANAGER_H
SignonDaemonNS::EncryptionInUse
Definition: credentialsaccessmanager.h:166
SignonDaemonNS::CAMConfiguration::CAMConfiguration
CAMConfiguration()
Constructs a CAMConfiguration object with the default configuration - encryption in use...
Definition: credentialsaccessmanager.cpp:56
SignonDaemonNS::NotInitialized
Definition: credentialsaccessmanager.h:160
SignonDaemonNS::CredentialsDbSetupFailed
Definition: credentialsaccessmanager.h:167
credentialsdb.h
Definition of the CredentialsDB object.
SignonDaemonNS::CAMConfiguration::metadataDBPath
QString metadataDBPath() const
Returns the path to the metadata DB.
Definition: credentialsaccessmanager.cpp:87
SignonDaemonNS::CredentialsDbMountFailed
Definition: credentialsaccessmanager.h:168
SignonDaemonNS::AccessCodeHandlerInitFailed
Definition: credentialsaccessmanager.h:162
SignonDaemonNS::CredentialsAccessManager::deleteCredentialsSystem
bool deleteCredentialsSystem()
Deletes the credentials system.
Definition: credentialsaccessmanager.cpp:511
SignonDaemonNS::CAMConfiguration::addSetting
void addSetting(const QString &key, const QVariant &value)
Definition: credentialsaccessmanager.h:142
SignonDaemonNS::CredentialsDbNotMounted
Definition: credentialsaccessmanager.h:173
SignonDaemonNS::CAMConfiguration::serialize
void serialize(QIODevice *device)
Serializes the CAMConfiguration object as string to a specific IODevice.
Definition: credentialsaccessmanager.cpp:64
SignonDaemonNS::CredentialsAccessManager::closeCredentialsSystem
bool closeCredentialsSystem()
Closes the credentials system.
Definition: credentialsaccessmanager.cpp:493
SignonDaemonNS::CAMConfiguration::m_dbName
QString m_dbName
The database file name.
Definition: credentialsaccessmanager.h:147
SignonDaemonNS::CredentialsAccessManager::initExtension
bool initExtension(QObject *object)
Initializes know objects from an extension plugin.
Definition: credentialsaccessmanager.cpp:280
SignonDaemonNS::CredentialsAccessManager::credentialsSystemOpened
bool credentialsSystemOpened() const
For convenience method.
Definition: credentialsaccessmanager.h:326
SignonDaemonNS::CredentialsAccessError
CredentialsAccessError
Definition: credentialsaccessmanager.h:158
SignonDaemonNS::CredentialsAccessManager::configuration
const CAMConfiguration & configuration() const
Definition: credentialsaccessmanager.h:346
SignonDaemonNS::CredentialsDbSqlError
Definition: credentialsaccessmanager.h:175
SignonDaemonNS::UnknownError
Definition: credentialsaccessmanager.h:176
SignonDaemonNS::CredentialsDbAlreadyDeployed
Definition: credentialsaccessmanager.h:171
SignonDaemonNS::CredentialsAccessManager::CredentialsAccessManager
CredentialsAccessManager(const CAMConfiguration &configuration, QObject *parent=0)
Constructs a CredentialsAccessManager object with the given parent.
Definition: credentialsaccessmanager.cpp:127
SignonDaemonNS::CredentialsDbAlreadyMounted
Definition: credentialsaccessmanager.h:172
SignonDaemonNS::CAMConfiguration::m_secretsDbName
QString m_secretsDbName
The credentials database file name.
Definition: credentialsaccessmanager.h:148
SignonDaemonNS::CredentialsAccessManager::customEvent
void customEvent(QEvent *event)
Definition: credentialsaccessmanager.cpp:616
SignonDaemonNS::CAMConfiguration::useEncryption
bool useEncryption() const
Definition: credentialsaccessmanager.cpp:104
SignonDaemonNS::SecureStorageEvent
Any object in the signon framework that needs the CredentialsAccessManager - CAM - secure storage in ...
Definition: credentialsaccessmanager.h:91
SignonDaemonNS::CredentialsDbUnmountFailed
Definition: credentialsaccessmanager.h:169
SignonDaemonNS::CredentialsAccessManager::addKeyManager
void addKeyManager(SignOn::AbstractKeyManager *keyManager)
Adds a key manager.
Definition: credentialsaccessmanager.cpp:274
SignonDaemonNS::CAMConfiguration::setStoragePath
void setStoragePath(const QString &storagePath)
Definition: credentialsaccessmanager.cpp:115
SignonDaemonNS::CredentialsAccessManager::instance
static CredentialsAccessManager * instance()
Returns CAM instance.
Definition: credentialsaccessmanager.cpp:160
SignonDaemonNS::CAMConfiguration::m_storagePath
QString m_storagePath
The base directory for storage.
Definition: credentialsaccessmanager.h:146
SignonDaemonNS::AlreadyInitialized
Definition: credentialsaccessmanager.h:161
SignonDaemonNS::CredentialsAccessManager
Main singleton and manager object of the credentials database system.
Definition: credentialsaccessmanager.h:193
SignonDaemonNS::CredentialsAccessManager::isCredentialsSystemReady
bool isCredentialsSystemReady() const
The creadentials system is ready when all of the subscribed key managers have successfully reported a...
Definition: credentialsaccessmanager.cpp:531
SignonDaemonNS::CredentialsDbConnectionError
Definition: credentialsaccessmanager.h:174
SignonDaemonNS::CredentialsAccessManager::credentialsSystemReady
void credentialsSystemReady()
Is emitted when the credentials system becomes ready.
SignonDaemonNS::CredentialsAccessManager::init
bool init()
Initializes the CAM instance.
Definition: credentialsaccessmanager.cpp:180
SignonDaemonNS::CAMConfiguration::secretsStorageName
QString secretsStorageName() const
Returns the name of the SecretsStorage to use.
Definition: credentialsaccessmanager.cpp:109
SignonDaemonNS::EventSender
QPointer< QObject > EventSender
Definition: credentialsaccessmanager.h:77
SignonDaemonNS::FailedToFetchAccessCode
Definition: credentialsaccessmanager.h:164
SignonDaemonNS::CredentialsAccessManager::keysAvailable
bool keysAvailable() const
The CAM manages the encryption keys collection.
Definition: credentialsaccessmanager.cpp:585
SignonDaemonNS::CredentialsAccessManager::~CredentialsAccessManager
~CredentialsAccessManager()
Destroys a CredentialsAccessManager.
Definition: credentialsaccessmanager.cpp:153
SignonDaemonNS::NoError
Definition: credentialsaccessmanager.h:159
SignonDaemonNS::SecureStorageEvent::SecureStorageEvent
SecureStorageEvent(QEvent::Type type)
Definition: credentialsaccessmanager.h:94
SignonDaemonNS::CAMConfiguration::m_settings
QVariantMap m_settings
Definition: credentialsaccessmanager.h:152
SignonDaemonNS::CredentialsAccessManager::finalize
void finalize()
Finalizes the CAM instance, this could include, closing the credentials system and resetting the conf...
Definition: credentialsaccessmanager.cpp:165
SignonDaemonNS::SecureStorageEvent::m_sender
EventSender m_sender
Definition: credentialsaccessmanager.h:96
signonui_interface.h
SignonDaemonNS::CredentialsAccessManager::lastError
CredentialsAccessError lastError() const
Definition: credentialsaccessmanager.h:352
SignonDaemonNS::CredentialsDbDeletionFailed
Definition: credentialsaccessmanager.h:170
SignonDaemonNS::CredentialsAccessManager::credentialsDB
CredentialsDB * credentialsDB() const
Definition: credentialsaccessmanager.cpp:524
SignonDaemonNS::CredentialsDB
Manages the credentials I/O.
Definition: credentialsdb.h:66
SignonDaemonNS::CAMConfiguration::accessControlManagerName
QString accessControlManagerName() const
Returns the name of the AccessControlManager to use.
Definition: credentialsaccessmanager.cpp:98
SignonDaemonNS::CAMConfiguration
Configuration object for the CredentialsAccessManager - CAM.
Definition: credentialsaccessmanager.h:104
SignonDaemonNS::AccessCodeInvalid
Definition: credentialsaccessmanager.h:165
accesscontrolmanagerhelper.h
Helper class for access control-related functionality.
SignonDaemonNS::CAMConfiguration::m_encryptionPassphrase
QByteArray m_encryptionPassphrase
Passphrase used for opening encrypted FS.
Definition: credentialsaccessmanager.h:149
SignonDaemonNS::CredentialsAccessManager::openCredentialsSystem
bool openCredentialsSystem()
Opens the credentials system, creates the CreadentialsDB object; if encryption is configured this wil...
Definition: credentialsaccessmanager.cpp:466
SignonDaemonNS::CAMConfiguration::cryptoManagerName
QString cryptoManagerName() const
Returns the name of the CryptoManager to use.
Definition: credentialsaccessmanager.cpp:92
SignonDaemonNS::CredentialsAccessManager::backupFiles
QStringList backupFiles() const
Definition: credentialsaccessmanager.cpp:379
SignonDaemonNS::AccessControlManagerHelper
Contains helper functions related to Access Control.
Definition: accesscontrolmanagerhelper.h:51
SignonDaemonNS::AccessCodeNotReady
Definition: credentialsaccessmanager.h:163
QList< SignOn::AbstractKeyManager * >