My Project: authsession.h Source File

My Project

authsession.h
1/*
2 * This file is part of signon
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation.
5 * Copyright (C) 2011-2016 Canonical Ltd.
6 *
7 * Contact: 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 */
28#ifndef AUTHSESSION_H
29#define AUTHSESSION_H
30
31#include <QObject>
32#include <QString>
33#include <QStringList>
34#include <QByteArray>
35#include <QVariant>
36
37#include "libsignoncommon.h"
38#include "sessiondata.h"
39#include "signonerror.h"
40
41 namespace SignOnTests {
42 class AccessControlTest;
43}
44
45namespace SignOn {
46
54 class SIGNON_EXPORT AuthSession: public QObject
55{
56 Q_OBJECT
57 Q_DISABLE_COPY(AuthSession)
58
59 friend class IdentityImpl;
60 friend class AuthSessionImpl;
61 friend class SignOnTests::AccessControlTest;
62
63public:
69 enum AuthSessionError {
70 UnknownError = 1,
71 InternalServerError = 2,
72 InternalCommunicationError = 3,
73 PermissionDeniedError = 4,
74 AuthSessionErr = 300, /* placeholder to rearrange enumeration */
75 MechanismNotAvailableError,
76 MissingDataError,
77 InvalidCredentialsError,
78 WrongStateError,
79 OperationNotSupportedError,
80 NoConnectionError,
81 NetworkError,
82 SslError,
83 RuntimeError,
84 CanceledError,
85 TimedOutError,
86 UserInteractionError
87 };
88
95 enum AuthSessionState {
96 SessionNotStarted = 0,
97 HostResolving,
98 ServerConnecting,
99 DataSending,
100 ReplyWaiting,
101 UserPending,
102 UiRefreshing,
103 ProcessPending,
104 SessionStarted,
105 ProcessCanceling,
106 ProcessDone,
107 CustomState,
108 MaxState,
109 };
110
111protected:
115 AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
116 ~AuthSession();
117
118public:
124 const QString name() const;
125
136 void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
137
167 void process(const SessionData &sessionData,
168 const QString &mechanism = QString());
169
183 void challenge(const SessionData& sessionData,
184 const QString &mechanism = QString()) {
185 process(sessionData, mechanism);
186 }
187
201 void request(const SessionData &sessionData,
202 const QString &mechanism = QString()) {
203 process(sessionData, mechanism);
204 }
205
214 void cancel();
215
224 void signMessage(const SessionData &params,
225 const QString &mechanism = QString()) {
226 process(params, mechanism);
227 }
228
229Q_SIGNALS:
240 void error(const SignOn::Error &err);
241
248 void mechanismsAvailable(const QStringList &mechanisms);
249
262 void response(const SignOn::SessionData &sessionData);
263
270 void stateChanged(AuthSession::AuthSessionState state,
271 const QString &message);
272
273private:
274 class AuthSessionImpl *impl;
275};
276
277} // namespace SignOn
278
279Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
280
281#endif // AUTHSESSION_H
SignOn::AuthSession
Represents a session to authentication plugin/server.
Definition authsession.h:55
SignOn::AuthSession::signMessage
void signMessage(const SessionData &params, const QString &mechanism=QString())
Signs message by using secret stored into identity.
Definition authsession.h:224
SignOn::AuthSession::AuthSessionError
AuthSessionError
Codes for errors that may be reported by AuthSession objects.
Definition authsession.h:69
SignOn::AuthSession::MissingDataError
@ MissingDataError
Definition authsession.h:76
SignOn::AuthSession::CanceledError
@ CanceledError
Definition authsession.h:84
SignOn::AuthSession::WrongStateError
@ WrongStateError
Definition authsession.h:78
SignOn::AuthSession::InvalidCredentialsError
@ InvalidCredentialsError
Definition authsession.h:77
SignOn::AuthSession::TimedOutError
@ TimedOutError
Definition authsession.h:85
SignOn::AuthSession::NetworkError
@ NetworkError
Definition authsession.h:81
SignOn::AuthSession::SslError
@ SslError
Definition authsession.h:82
SignOn::AuthSession::RuntimeError
@ RuntimeError
Definition authsession.h:83
SignOn::AuthSession::MechanismNotAvailableError
@ MechanismNotAvailableError
Definition authsession.h:75
SignOn::AuthSession::OperationNotSupportedError
@ OperationNotSupportedError
Definition authsession.h:79
SignOn::AuthSession::NoConnectionError
@ NoConnectionError
Definition authsession.h:80
SignOn::AuthSession::response
void response(const SignOn::SessionData &sessionData)
Authentication response generated by the authentication service.
SignOn::AuthSession::error
void error(const SignOn::Error &err)
Emitted when an error occurs while performing an operation.
SignOn::AuthSession::challenge
void challenge(const SessionData &sessionData, const QString &mechanism=QString())
Sends a challenge to the authentication service.
Definition authsession.h:183
SignOn::AuthSession::request
void request(const SessionData &sessionData, const QString &mechanism=QString())
Sends a request to the authentication service.
Definition authsession.h:201
SignOn::AuthSession::AuthSessionState
AuthSessionState
Codes for the states of the AuthSession object.
Definition authsession.h:95
SignOn::AuthSession::ProcessDone
@ ProcessDone
Definition authsession.h:106
SignOn::AuthSession::UiRefreshing
@ UiRefreshing
Definition authsession.h:102
SignOn::AuthSession::SessionStarted
@ SessionStarted
Definition authsession.h:104
SignOn::AuthSession::CustomState
@ CustomState
Definition authsession.h:107
SignOn::AuthSession::ServerConnecting
@ ServerConnecting
Definition authsession.h:98
SignOn::AuthSession::DataSending
@ DataSending
Definition authsession.h:99
SignOn::AuthSession::ReplyWaiting
@ ReplyWaiting
Definition authsession.h:100
SignOn::AuthSession::ProcessPending
@ ProcessPending
Definition authsession.h:103
SignOn::AuthSession::HostResolving
@ HostResolving
Definition authsession.h:97
SignOn::AuthSession::UserPending
@ UserPending
Definition authsession.h:101
SignOn::AuthSession::ProcessCanceling
@ ProcessCanceling
Definition authsession.h:105
SignOn::AuthSession::mechanismsAvailable
void mechanismsAvailable(const QStringList &mechanisms)
Emitted when the list of available mechanisms have been obtained for identity.
SignOn::AuthSession::stateChanged
void stateChanged(AuthSession::AuthSessionState state, const QString &message)
Provides the information about the state of the authentication request.
SignOn::Error
definition for Signon error handling.
Definition signonerror.h:53
SignOn::SessionData
Data container to hold values for authentication session.
Definition sessiondata.h:92
SignOnTests
Definition authsession.h:41
SignOn
Definition async-dbus-proxy.cpp:41