00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef AUTHSESSION_H
00029 #define AUTHSESSION_H
00030
00031 #include <QObject>
00032 #include <QString>
00033 #include <QStringList>
00034 #include <QByteArray>
00035 #include <QVariant>
00036
00037 #include "libsignoncommon.h"
00038 #include "sessiondata.h"
00039 #include "signonerror.h"
00040
00041
00042 namespace SignOn {
00043
00051 class SIGNON_EXPORT AuthSession: public QObject
00052 {
00053 Q_OBJECT
00054 Q_DISABLE_COPY(AuthSession)
00055
00056 friend class IdentityImpl;
00057 friend class AuthSessionImpl;
00058
00059 public:
00065 enum AuthSessionError {
00066 UnknownError = 1,
00067 InternalServerError = 2,
00068 InternalCommunicationError = 3,
00069 PermissionDeniedError = 4,
00070 AuthSessionErr = 300,
00071 MechanismNotAvailableError,
00072 MissingDataError,
00073 InvalidCredentialsError,
00074 WrongStateError,
00075 OperationNotSupportedError,
00076 NoConnectionError,
00077 NetworkError,
00078 SslError,
00079 RuntimeError,
00080 CanceledError,
00081 TimedOutError,
00082 UserInteractionError
00083 };
00084
00091 enum AuthSessionState {
00092 SessionNotStarted = 0,
00093 HostResolving,
00094 ServerConnecting,
00095 DataSending,
00096 ReplyWaiting,
00097 UserPending,
00098 UiRefreshing,
00099 ProcessPending,
00100 SessionStarted,
00101 ProcessCanceling,
00102 ProcessDone,
00103 CustomState,
00104 MaxState,
00105 };
00106
00107 protected:
00111 AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
00112 ~AuthSession();
00113
00114 public:
00120 const QString name() const;
00121
00132 void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
00133
00163 void process(const SessionData &sessionData,
00164 const QString &mechanism = QString());
00165
00179 void challenge(const SessionData& sessionData,
00180 const QString &mechanism = QString()) {
00181 process(sessionData, mechanism);
00182 }
00183
00197 void request(const SessionData &sessionData,
00198 const QString &mechanism = QString()) {
00199 process(sessionData, mechanism);
00200 }
00201
00210 void cancel();
00211
00220 void signMessage(const SessionData ¶ms,
00221 const QString &mechanism = QString()) {
00222 process(params, mechanism);
00223 }
00224
00225 Q_SIGNALS:
00236 void error(const SignOn::Error &err);
00237
00244 void mechanismsAvailable(const QStringList &mechanisms);
00245
00258 void response(const SignOn::SessionData &sessionData);
00259
00266 void stateChanged(AuthSession::AuthSessionState state,
00267 const QString &message);
00268
00269 private:
00270 class AuthSessionImpl *impl;
00271 };
00272
00273 }
00274
00275 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
00276
00277 #endif // AUTHSESSION_H