authsession.h
/*
* This file is part of signon
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2011-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef AUTHSESSION_H
#define AUTHSESSION_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <QByteArray>
#include <QVariant>
#include "libsignoncommon.h"
#include "sessiondata.h"
#include "signonerror.h"
namespace SignOnTests {
class AccessControlTest;
}
namespace SignOn {
class SIGNON_EXPORT AuthSession: public QObject
{
Q_OBJECT
Q_DISABLE_COPY(AuthSession)
friend class IdentityImpl;
friend class AuthSessionImpl;
friend class SignOnTests::AccessControlTest;
public:
enum AuthSessionError {
UnknownError = 1,
InternalServerError = 2,
InternalCommunicationError = 3,
PermissionDeniedError = 4,
AuthSessionErr = 300, /* placeholder to rearrange enumeration */
MechanismNotAvailableError,
MissingDataError,
InvalidCredentialsError,
WrongStateError,
OperationNotSupportedError,
NoConnectionError,
NetworkError,
SslError,
RuntimeError,
CanceledError,
TimedOutError,
UserInteractionError
};
enum AuthSessionState {
SessionNotStarted = 0,
HostResolving,
ServerConnecting,
DataSending,
ReplyWaiting,
UserPending,
UiRefreshing,
ProcessPending,
SessionStarted,
ProcessCanceling,
ProcessDone,
CustomState,
MaxState,
};
protected:
AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
~AuthSession();
public:
const QString name() const;
void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
void process(const SessionData &sessionData,
const QString &mechanism = QString());
void challenge(const SessionData& sessionData,
const QString &mechanism = QString()) {
process(sessionData, mechanism);
}
void request(const SessionData &sessionData,
const QString &mechanism = QString()) {
process(sessionData, mechanism);
}
void cancel();
void signMessage(const SessionData &params,
const QString &mechanism = QString()) {
process(params, mechanism);
}
Q_SIGNALS:
void error(const SignOn::Error &err);
void mechanismsAvailable(const QStringList &mechanisms);
void response(const SignOn::SessionData &sessionData);
void stateChanged(AuthSession::AuthSessionState state,
const QString &message);
private:
class AuthSessionImpl *impl;
};
} // namespace SignOn
Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
#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