authsession.h
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  *
6  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
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 
42 namespace SignOn {
43 
51 class SIGNON_EXPORT AuthSession: public QObject
52 {
53  Q_OBJECT
54  Q_DISABLE_COPY(AuthSession)
55 
56  friend class IdentityImpl;
57  friend class AuthSessionImpl;
58 
59 public:
66  UnknownError = 1,
67  InternalServerError = 2,
68  InternalCommunicationError = 3,
69  PermissionDeniedError = 4,
70  AuthSessionErr = 300, /* placeholder to rearrange enumeration */
82  UserInteractionError
83  };
84 
92  SessionNotStarted = 0,
104  MaxState,
105  };
106 
107 protected:
111  AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
112  ~AuthSession();
113 
114 public:
120  const QString name() const;
121 
132  void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
133 
163  void process(const SessionData &sessionData,
164  const QString &mechanism = QString());
165 
179  void challenge(const SessionData& sessionData,
180  const QString &mechanism = QString()) {
181  process(sessionData, mechanism);
182  }
183 
197  void request(const SessionData &sessionData,
198  const QString &mechanism = QString()) {
199  process(sessionData, mechanism);
200  }
201 
210  void cancel();
211 
220  void signMessage(const SessionData &params,
221  const QString &mechanism = QString()) {
222  process(params, mechanism);
223  }
224 
225 Q_SIGNALS:
236  void error(const SignOn::Error &err);
237 
244  void mechanismsAvailable(const QStringList &mechanisms);
245 
258  void response(const SignOn::SessionData &sessionData);
259 
266  void stateChanged(AuthSession::AuthSessionState state,
267  const QString &message);
268 
269 private:
270  class AuthSessionImpl *impl;
271 };
272 
273 } // namespace SignOn
274 
275 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
276 
277 #endif // AUTHSESSION_H