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 namespace SignOnTests {
00042 class AccessControlTest;
00043 }
00044
00045 namespace SignOn {
00046
00054 class SIGNON_EXPORT AuthSession: public QObject
00055 {
00056 Q_OBJECT
00057 Q_DISABLE_COPY(AuthSession)
00058
00059 friend class IdentityImpl;
00060 friend class AuthSessionImpl;
00061 friend class SignOnTests::AccessControlTest;
00062
00063 public:
00069 enum AuthSessionError {
00070 UnknownError = 1,
00071 InternalServerError = 2,
00072 InternalCommunicationError = 3,
00073 PermissionDeniedError = 4,
00074 AuthSessionErr = 300,
00075 MechanismNotAvailableError,
00076 MissingDataError,
00077 InvalidCredentialsError,
00078 WrongStateError,
00079 OperationNotSupportedError,
00080 NoConnectionError,
00081 NetworkError,
00082 SslError,
00083 RuntimeError,
00084 CanceledError,
00085 TimedOutError,
00086 UserInteractionError
00087 };
00088
00095 enum AuthSessionState {
00096 SessionNotStarted = 0,
00097 HostResolving,
00098 ServerConnecting,
00099 DataSending,
00100 ReplyWaiting,
00101 UserPending,
00102 UiRefreshing,
00103 ProcessPending,
00104 SessionStarted,
00105 ProcessCanceling,
00106 ProcessDone,
00107 CustomState,
00108 MaxState,
00109 };
00110
00111 protected:
00115 AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
00116 ~AuthSession();
00117
00118 public:
00124 const QString name() const;
00125
00136 void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
00137
00167 void process(const SessionData &sessionData,
00168 const QString &mechanism = QString());
00169
00183 void challenge(const SessionData& sessionData,
00184 const QString &mechanism = QString()) {
00185 process(sessionData, mechanism);
00186 }
00187
00201 void request(const SessionData &sessionData,
00202 const QString &mechanism = QString()) {
00203 process(sessionData, mechanism);
00204 }
00205
00214 void cancel();
00215
00224 void signMessage(const SessionData ¶ms,
00225 const QString &mechanism = QString()) {
00226 process(params, mechanism);
00227 }
00228
00229 Q_SIGNALS:
00240 void error(const SignOn::Error &err);
00241
00248 void mechanismsAvailable(const QStringList &mechanisms);
00249
00262 void response(const SignOn::SessionData &sessionData);
00263
00270 void stateChanged(AuthSession::AuthSessionState state,
00271 const QString &message);
00272
00273 private:
00274 class AuthSessionImpl *impl;
00275 };
00276
00277 }
00278
00279 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
00280
00281 #endif // AUTHSESSION_H