signon 8.54

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

- File List
- File Members

signonauthsession.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) 2013 Canonical Ltd.
6 *
7 * Conta 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 "signond-common.h"
25 #include "signonauthsession.h"
26 #include "signonauthsessionadaptor.h"
27
28 using namespace SignonDaemonNS;
29
30 SignonAuthSession::SignonAuthSession(quint32 id,
31 const QString &method,
32 pid_t ownerPid):
33 m_id(id),
34 m_method(method),
35 m_ownerPid(ownerPid)
36 {
37 TRACE();
38
39 (void)new SignonAuthSessionAdaptor(this);
40
41 static quint32 incr = 0;
42 QString objectName = SIGNOND_DAEMON_OBJECTPATH +
43 QLatin1String("/AuthSession_") + QString::number(incr++, 16);
44 TRACE() << objectName;
45
46 setObjectName(objectName);
47 }
48
49 SignonAuthSession::~SignonAuthSession()
50 {
51 Q_EMIT unregistered();
52 TRACE();
53 }
54
55 SignonAuthSession *SignonAuthSession::createAuthSession(const quint32 id,
56 const QString &method,
57 SignonDaemon *parent,
58 pid_t ownerPid)
59 {
60 TRACE();
61 SignonAuthSession *sas = new SignonAuthSession(id, method, ownerPid);
62
63 SignonSessionCore *core = SignonSessionCore::sessionCore(id, method, parent);
64 if (!core) {
65 TRACE() << "Cannot retrieve proper tasks queue";
66 delete sas;
67 return NULL;
68 }
69
70 sas->setParent(core);
71
72 connect(core, SIGNAL(stateChanged(const QString&, int, const QString&)),
73 sas, SLOT(stateChangedSlot(const QString&, int, const QString&)));
74
75 TRACE() << "SignonAuthSession created successfully:" << sas->objectName();
76 return sas;
77 }
78
79 void SignonAuthSession::stopAllAuthSessions()
80 {
81 SignonSessionCore::stopAllAuthSessions();
82 }
83
84 quint32 SignonAuthSession::id() const
85 {
86 return m_id;
87 }
88
89 QString SignonAuthSession::method() const
90 {
91 return m_method;
92 }
93
94 pid_t SignonAuthSession::ownerPid() const
95 {
96 return m_ownerPid;
97 }
98
99 QStringList
100 SignonAuthSession::queryAvailableMechanisms(const QStringList &wantedMechanisms)
101 {
102 return parent()->queryAvailableMechanisms(wantedMechanisms);
103 }
104
105 QVariantMap SignonAuthSession::process(const QVariantMap &sessionDataVa,
106 const QString &mechanism)
107 {
108 setDelayedReply(true);
109 parent()->process(connection(),
110 message(),
111 sessionDataVa,
112 mechanism,
113 objectName());
114 return QVariantMap();
115 }
116
117 void SignonAuthSession::cancel()
118 {
119 TRACE();
120 parent()->cancel(objectName());
121 }
122
123 void SignonAuthSession::setId(quint32 id)
124 {
125 m_id = id;
126 parent()->setId(id);
127 }
128
129 void SignonAuthSession::objectUnref()
130 {
131 //TODO - remove the `objectUnref` functionality from the DBus API
132 TRACE();
133 cancel();
134
135 deleteLater();
136 }
137
138 void SignonAuthSession::stateChangedSlot(const QString &sessionKey,
139 int state,
140 const QString &message)
141 {
142 TRACE();
143
144 if (sessionKey == objectName())
145 emit stateChanged(state, message);
146 }
SignonDaemonNS::SignonSessionCore::process
void process(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap &sessionDataVa, const QString &mechanism, const QString &cancelKey)
Definition: signonsessioncore.cpp:237
SignonDaemonNS::SignonAuthSession::setId
void setId(quint32 id)
Definition: signonauthsession.cpp:123
SignonDaemonNS::SignonAuthSession::method
QString method() const
Definition: signonauthsession.cpp:89
SignonDaemonNS::SignonAuthSession
Daemon side representation of authentication session.
Definition: signonauthsession.h:45
SignonDaemonNS::SignonSessionCore
Daemon side representation of authentication session.
Definition: signonsessioncore.h:50
signonauthsessionadaptor.h
SignonDaemonNS::SignonAuthSession::stopAllAuthSessions
static void stopAllAuthSessions()
Definition: signonauthsession.cpp:79
SignonDaemonNS::SignonAuthSession::id
quint32 id() const
Definition: signonauthsession.cpp:84
SignonDaemonNS::SignonAuthSession::ownerPid
pid_t ownerPid() const
Definition: signonauthsession.cpp:94
signond-common.h
SignonDaemonNS::SignonDaemon
Daemon core.
Definition: signondaemon.h:105
SignonDaemonNS::SignonAuthSession::cancel
void cancel()
Definition: signonauthsession.cpp:117
SignonDaemonNS::SignonSessionCore::queryAvailableMechanisms
QStringList queryAvailableMechanisms(const QStringList &wantedMechanisms)
Definition: signonsessioncore.cpp:226
SignonDaemonNS::SignonAuthSession::objectUnref
void objectUnref()
Definition: signonauthsession.cpp:129
SignonDaemonNS::SignonAuthSession::parent
SignonSessionCore * parent() const
Definition: signonauthsession.h:50
SignonDaemonNS::SignonSessionCore::stopAllAuthSessions
static void stopAllAuthSessions()
Definition: signonsessioncore.cpp:201
SignonDaemonNS::SignonAuthSession::~SignonAuthSession
virtual ~SignonAuthSession()
Definition: signonauthsession.cpp:49
SignonDaemonNS::SignonSessionCore::sessionCore
static SignonSessionCore * sessionCore(const quint32 id, const QString &method, SignonDaemon *parent)
Definition: signonsessioncore.cpp:108
SignonDaemonNS::SignonAuthSession::SignonAuthSession
SignonAuthSession(quint32 id, const QString &method, pid_t ownerPid)
Definition: signonauthsession.cpp:30
TRACE
#define TRACE()
Definition: debug.h:28
SignonDaemonNS::SignonAuthSession::queryAvailableMechanisms
QStringList queryAvailableMechanisms(const QStringList &wantedMechanisms)
Definition: signonauthsession.cpp:100
SignonDaemonNS::SignonSessionCore::setId
void setId(quint32 id)
Definition: signonsessioncore.cpp:301
signonauthsession.h
SignonDaemonNS::SignonAuthSession::process
QVariantMap process(const QVariantMap &sessionDataVa, const QString &mechanism)
Definition: signonauthsession.cpp:105
SignonDaemonNS::SignonAuthSession::stateChanged
void stateChanged(int state, const QString &message)
SignonDaemonNS::SignonAuthSession::SignonAuthSessionAdaptor
friend class SignonAuthSessionAdaptor
Definition: signonauthsession.h:55
SignonDaemonNS::SignonAuthSession::unregistered
void unregistered()
SignonDaemonNS::SignonAuthSession::createAuthSession
static SignonAuthSession * createAuthSession(const quint32 id, const QString &method, SignonDaemon *parent, pid_t ownerPid)
Definition: signonauthsession.cpp:55
SignonDaemonNS::SignonSessionCore::cancel
void cancel(const QString &cancelKey)
Definition: signonsessioncore.cpp:254