signon 8.54

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

- File List
- File Members

signondaemon.h
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) 2012-2013 Canonical Ltd.
6 *
7 * Contact: Aurel Popirtac <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
25 #ifndef SIGNONDAEMON_H_
26 #define SIGNONDAEMON_H_
27
28 extern "C" {
29 #include <signal.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <stdio.h>
33 #include <sys/types.h>
34 }
35
36 #include <QtCore>
37 #include <QtDBus>
38
39 #include "credentialsaccessmanager.h"
40
41 #ifndef SIGNOND_PLUGINS_DIR
42 #define SIGNOND_PLUGINS_DIR "/usr/lib/signon"
43 #endif
44
45 #ifndef SIGNOND_PLUGIN_PREFIX
46 #define SIGNOND_PLUGIN_PREFIX QLatin1String("lib")
47 #endif
48
49 #ifndef SIGNOND_PLUGIN_SUFFIX
50 #define SIGNOND_PLUGIN_SUFFIX QLatin1String("plugin.so")
51 #endif
52
53 class QSocketNotifier;
54
55 namespace SignonDaemonNS {
56
62 class SignonDaemonConfiguration
63 {
64 public:
65 SignonDaemonConfiguration();
66 ~SignonDaemonConfiguration();
67
68 const CAMConfiguration &camConfiguration() const {
69 return m_camConfiguration;
70 }
71 void setEncryptionPassphrase(const QByteArray &passphrase) {
72 m_camConfiguration.m_encryptionPassphrase = passphrase;
73 }
74
75 void load();
76
77 QString pluginsDir() const { return m_pluginsDir; }
78 QString extensionsDir() const { return m_extensionsDir; }
79 QString busAddress() const { return m_busAddress; }
80 uint daemonTimeout() const { return m_daemonTimeout; }
81 uint identityTimeout() const { return m_identityTimeout; }
82 uint authSessionTimeout() const { return m_authSessionTimeout; }
83
84 private:
85 QString m_pluginsDir;
86 QString m_extensionsDir;
87 QString m_busAddress;
88
89 // storage configuration
90 CAMConfiguration m_camConfiguration;
91
92 //object timeouts
93 uint m_daemonTimeout;
94 uint m_identityTimeout;
95 uint m_authSessionTimeout;
96 };
97
98 class SignonIdentity;
99
105 class SignonDaemon: public QObject, protected QDBusContext
106 {
107 Q_OBJECT
108
109 friend class SignonSessionCore;
110 friend class SignonDaemonAdaptor;
111
112 public:
113 static SignonDaemon *instance();
114 virtual ~SignonDaemon();
115
116 Q_INVOKABLE void init();
117
122 int identityTimeout() const;
123 int authSessionTimeout() const;
124
125 public:
126 QObject *registerNewIdentity();
127 QObject *getIdentity(const quint32 id, QVariantMap &identityData);
128 QObject *getAuthSession(const quint32 id, const QString type,
129 pid_t ownerPid);
130
131 QStringList queryMethods();
132 QStringList queryMechanisms(const QString &method);
133 QList<QVariantMap> queryIdentities(const QVariantMap &filter);
134 bool clear();
135
136 QString lastErrorName() const { return m_lastErrorName; }
137 QString lastErrorMessage() const { return m_lastErrorMessage; }
138 bool lastErrorIsValid() const { return !m_lastErrorName.isEmpty(); }
139
140 private Q_SLOTS:
141 void onDisconnected();
142 void onNewConnection(const QDBusConnection &connection);
143 void onIdentityStored(SignonIdentity *identity);
144 void onIdentityDestroyed();
145
146 public Q_SLOTS: // backup METHODS
147 uchar backupStarts();
148 uchar backupFinished();
149 uchar restoreStarts();
150 uchar restoreFinished();
151
152 private:
153 SignonDaemon(QObject *parent);
154 void initExtensions();
155 void initExtension(const QString &filePath);
156 bool initStorage();
157
158 void watchIdentity(SignonIdentity *identity);
159 void setupSignalHandlers();
160
161 void eraseBackupDir() const;
162 bool copyToBackupDir(const QStringList &fileNames) const;
163 bool copyFromBackupDir(const QStringList &fileNames) const;
164 bool createStorageFileTree(const QStringList &fileNames) const;
165
166 void setLastError(const QString &name, const QString &msg);
167 void clearLastError();
168
169 private:
170 /*
171 * The list of created SignonIdentities
172 * */
173 QMap<quint32, SignonIdentity *> m_storedIdentities;
174
175 SignonDaemonConfiguration *m_configuration;
176
177 /*
178 * The instance of CAM
179 * */
180 CredentialsAccessManager *m_pCAMManager;
181
182 bool m_backup;
183
184 int m_identityTimeout;
185 int m_authSessionTimeout;
186
187 QDBusServer *m_dbusServer;
188
189 QString m_lastErrorName;
190 QString m_lastErrorMessage;
191
192 /*
193 * UNIX signals handling related
194 * */
195 public:
196 static void signalHandler(int signal);
197 Q_INVOKABLE void handleUnixSignal();
198
199 private:
200 QSocketNotifier *m_sigSn;
201 static SignonDaemon *m_instance;
202 }; //class SignonDaemon
203
204 } //namespace SignonDaemonNS
205
206 #endif /* SIGNONDAEMON_H_ */
SignonDaemonNS::SignonDaemon::queryIdentities
QList< QVariantMap > queryIdentities(const QVariantMap &filter)
Definition: signondaemon.cpp:705
SignonDaemonNS::SignonDaemon::backupStarts
uchar backupStarts()
Definition: signondaemon.cpp:928
SignonDaemonNS::SignonDaemon::handleUnixSignal
Q_INVOKABLE void handleUnixSignal()
Definition: signondaemon.cpp:317
SignonDaemonNS::SignonDaemon::instance
static SignonDaemon * instance()
Definition: signondaemon.cpp:364
SignonDaemonNS::SignonDaemonConfiguration::load
void load()
Definition: signondaemon.cpp:107
SignonDaemonNS::SignonDaemon::~SignonDaemon
virtual ~SignonDaemon()
Definition: signondaemon.cpp:265
SignonDaemonNS::SignonDaemonAdaptor
Definition: signondaemonadaptor.h:39
SignonDaemonNS::SignonSessionCore
Daemon side representation of authentication session.
Definition: signonsessioncore.h:50
SignonDaemonNS::SignonDaemon::backupFinished
uchar backupFinished()
Definition: signondaemon.cpp:975
SignonDaemonNS::SignonDaemonConfiguration::identityTimeout
uint identityTimeout() const
Definition: signondaemon.h:81
SignonDaemonNS::SignonDaemonConfiguration::camConfiguration
const CAMConfiguration & camConfiguration() const
Definition: signondaemon.h:68
SignonDaemonNS::SignonDaemonConfiguration::extensionsDir
QString extensionsDir() const
Definition: signondaemon.h:78
SignonDaemonNS::SignonDaemon::restoreStarts
uchar restoreStarts()
Definition: signondaemon.cpp:994
SignonDaemonNS::SignonDaemon::registerNewIdentity
QObject * registerNewIdentity()
Definition: signondaemon.cpp:588
SignonDaemonNS::SignonDaemonConfiguration::setEncryptionPassphrase
void setEncryptionPassphrase(const QByteArray &passphrase)
Definition: signondaemon.h:71
SignonDaemonNS::SignonDaemonConfiguration::daemonTimeout
uint daemonTimeout() const
Definition: signondaemon.h:80
SignonDaemonNS::SignonDaemon
Daemon core.
Definition: signondaemon.h:105
SignonDaemonNS::SignonDaemon::getIdentity
QObject * getIdentity(const quint32 id, QVariantMap &identityData)
Definition: signondaemon.cpp:617
SignonDaemonNS::SignonDaemonConfiguration::authSessionTimeout
uint authSessionTimeout() const
Definition: signondaemon.h:82
SignonDaemonNS::SignonDaemon::lastErrorIsValid
bool lastErrorIsValid() const
Definition: signondaemon.h:138
SignonDaemonNS::SignonDaemonConfiguration::~SignonDaemonConfiguration
~SignonDaemonConfiguration()
Definition: signondaemon.cpp:84
SignonDaemonNS::SignonDaemon::lastErrorMessage
QString lastErrorMessage() const
Definition: signondaemon.h:137
SignonDaemonNS::CredentialsAccessManager
Main singleton and manager object of the credentials database system.
Definition: credentialsaccessmanager.h:193
SignonDaemonNS::SignonDaemon::getAuthSession
QObject * getAuthSession(const quint32 id, const QString type, pid_t ownerPid)
Definition: signondaemon.cpp:764
SignonDaemonNS::SignonDaemon::authSessionTimeout
int authSessionTimeout() const
Definition: signondaemon.cpp:610
SignonDaemonNS::SignonDaemon::clear
bool clear()
Definition: signondaemon.cpp:742
credentialsaccessmanager.h
Definition of the CredentialsAccessManager object.
SignonDaemonNS::SignonIdentity
Daemon side representation of identity.
Definition: signonidentity.h:50
SignonDaemonNS::SignonDaemonConfiguration::busAddress
QString busAddress() const
Definition: signondaemon.h:79
SignonDaemonNS::SignonDaemon::signalHandler
static void signalHandler(int signal)
Definition: signondaemon.cpp:311
SignonDaemonNS::SignonDaemonConfiguration::SignonDaemonConfiguration
SignonDaemonConfiguration()
Definition: signondaemon.cpp:75
SignonDaemonNS::CAMConfiguration
Configuration object for the CredentialsAccessManager - CAM.
Definition: credentialsaccessmanager.h:104
SignonDaemonNS::SignonDaemon::init
Q_INVOKABLE void init()
Definition: signondaemon.cpp:380
SignonDaemonNS::CAMConfiguration::m_encryptionPassphrase
QByteArray m_encryptionPassphrase
Passphrase used for opening encrypted FS.
Definition: credentialsaccessmanager.h:149
SignonDaemonNS::SignonDaemon::restoreFinished
uchar restoreFinished()
Definition: signondaemon.cpp:1000
SignonDaemonNS::SignonDaemonConfiguration
The daemon&#39;s configuration object; loads date from the daemon configuration file. ...
Definition: signondaemon.h:62
SignonDaemonNS::SignonDaemon::queryMethods
QStringList queryMethods()
Definition: signondaemon.cpp:654
SignonDaemonNS::SignonDaemon::queryMechanisms
QStringList queryMechanisms(const QString &method)
Definition: signondaemon.cpp:676
SignonDaemonNS::SignonDaemon::lastErrorName
QString lastErrorName() const
Definition: signondaemon.h:136
SignonDaemonNS::SignonDaemonConfiguration::pluginsDir
QString pluginsDir() const
Definition: signondaemon.h:77
QMap
Definition: backupifadaptor.h:19
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
QList
Definition: backupifadaptor.h:18