authsession.h
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  * Copyright (C) 2011-2015 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  */
29 #ifndef AUTHSESSION_H
30 #define AUTHSESSION_H
31 
32 #include <QObject>
33 #include <QString>
34 #include <QStringList>
35 #include <QByteArray>
36 #include <QVariant>
37 
38 #include "libsignoncommon.h"
39 #include "sessiondata.h"
40 #include "signonerror.h"
41 
42 namespace SignOnTests {
43  class AccessControlTest;
44 }
45 
46 namespace SignOn {
47 
55 class SIGNON_EXPORT AuthSession: public QObject
56 {
57  Q_OBJECT
58  Q_DISABLE_COPY(AuthSession)
59 
60  friend class IdentityImpl;
61  friend class AuthSessionImpl;
62  friend class SignOnTests::AccessControlTest;
63 
64 public:
71  UnknownError = 1,
72  InternalServerError = 2,
73  InternalCommunicationError = 3,
74  PermissionDeniedError = 4,
75  AuthSessionErr = 300, /* placeholder to rearrange enumeration */
87  UserInteractionError
88  };
89 
97  SessionNotStarted = 0,
109  MaxState,
110  };
111 
112 protected:
116  AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
117  ~AuthSession();
118 
119 public:
125  const QString name() const;
126 
137  void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
138 
168  void process(const SessionData &sessionData,
169  const QString &mechanism = QString());
170 
184  void challenge(const SessionData& sessionData,
185  const QString &mechanism = QString()) {
186  process(sessionData, mechanism);
187  }
188 
202  void request(const SessionData &sessionData,
203  const QString &mechanism = QString()) {
204  process(sessionData, mechanism);
205  }
206 
215  void cancel();
216 
225  void signMessage(const SessionData &params,
226  const QString &mechanism = QString()) {
227  process(params, mechanism);
228  }
229 
230 Q_SIGNALS:
241  void error(const SignOn::Error &err);
242 
249  void mechanismsAvailable(const QStringList &mechanisms);
250 
263  void response(const SignOn::SessionData &sessionData);
264 
271  void stateChanged(AuthSession::AuthSessionState state,
272  const QString &message);
273 
274 private:
275  class AuthSessionImpl *impl;
276 };
277 
278 } // namespace SignOn
279 
280 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
281 
282 #endif // AUTHSESSION_H
Data container to hold values for authentication session.
Definition: sessiondata.h:90
AuthSessionError
Codes for errors that may be reported by AuthSession objects.
Definition: authsession.h:70
void request(const SessionData &sessionData, const QString &mechanism=QString())
Sends a request to the authentication service.
Definition: authsession.h:202
void challenge(const SessionData &sessionData, const QString &mechanism=QString())
Sends a challenge to the authentication service.
Definition: authsession.h:184
definition for Signon error handling.
Definition: signonerror.h:49
AuthSessionState
Codes for the states of the AuthSession object.
Definition: authsession.h:96
void signMessage(const SessionData &params, const QString &mechanism=QString())
Signs message by using secret stored into identity.
Definition: authsession.h:225
Represents a session to authentication plugin/server.
Definition: authsession.h:55