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 
45 namespace 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 
63 public:
70  UnknownError = 1,
71  InternalServerError = 2,
72  InternalCommunicationError = 3,
73  PermissionDeniedError = 4,
74  AuthSessionErr = 300, /* placeholder to rearrange enumeration */
86  UserInteractionError
87  };
88 
96  SessionNotStarted = 0,
108  MaxState,
109  };
110 
111 protected:
115  AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
116  ~AuthSession();
117 
118 public:
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 
229 Q_SIGNALS:
240  void error(const SignOn::Error &err);
241 
248  void mechanismsAvailable(const QStringList &mechanisms);
249 
262  void response(const SignOn::SessionData &sessionData);
263 
271  const QString &message);
272 
273 private:
274  class AuthSessionImpl *impl;
275 };
276 
277 } // namespace SignOn
278 
279 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
280 
281 #endif // AUTHSESSION_H
Represents a session to authentication plugin/server.
Definition: authsession.h:55
void signMessage(const SessionData &params, const QString &mechanism=QString())
Signs message by using secret stored into identity.
Definition: authsession.h:224
AuthSessionError
Codes for errors that may be reported by AuthSession objects.
Definition: authsession.h:69
void response(const SignOn::SessionData &sessionData)
Authentication response generated by the authentication service.
void error(const SignOn::Error &err)
Emitted when an error occurs while performing an operation.
void challenge(const SessionData &sessionData, const QString &mechanism=QString())
Sends a challenge to the authentication service.
Definition: authsession.h:183
void request(const SessionData &sessionData, const QString &mechanism=QString())
Sends a request to the authentication service.
Definition: authsession.h:201
AuthSessionState
Codes for the states of the AuthSession object.
Definition: authsession.h:95
void mechanismsAvailable(const QStringList &mechanisms)
Emitted when the list of available mechanisms have been obtained for identity.
void stateChanged(AuthSession::AuthSessionState state, const QString &message)
Provides the information about the state of the authentication request.
definition for Signon error handling.
Definition: signonerror.h:53
Data container to hold values for authentication session.
Definition: sessiondata.h:92