00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00029 #ifndef AUTHSESSION_H
00030 #define AUTHSESSION_H
00031
00032 #include <QObject>
00033 #include <QString>
00034 #include <QStringList>
00035 #include <QByteArray>
00036 #include <QVariant>
00037
00038 #include "libsignoncommon.h"
00039 #include "sessiondata.h"
00040 #include "signonerror.h"
00041
00042 namespace SignOnTests {
00043 class AccessControlTest;
00044 }
00045
00046 namespace SignOn {
00047
00055 class SIGNON_EXPORT AuthSession: public QObject
00056 {
00057 Q_OBJECT
00058 Q_DISABLE_COPY(AuthSession)
00059
00060 friend class IdentityImpl;
00061 friend class AuthSessionImpl;
00062 friend class SignOnTests::AccessControlTest;
00063
00064 public:
00070 enum AuthSessionError {
00071 UnknownError = 1,
00072 InternalServerError = 2,
00073 InternalCommunicationError = 3,
00074 PermissionDeniedError = 4,
00075 AuthSessionErr = 300,
00076 MechanismNotAvailableError,
00077 MissingDataError,
00078 InvalidCredentialsError,
00079 WrongStateError,
00080 OperationNotSupportedError,
00081 NoConnectionError,
00082 NetworkError,
00083 SslError,
00084 RuntimeError,
00085 CanceledError,
00086 TimedOutError,
00087 UserInteractionError
00088 };
00089
00096 enum AuthSessionState {
00097 SessionNotStarted = 0,
00098 HostResolving,
00099 ServerConnecting,
00100 DataSending,
00101 ReplyWaiting,
00102 UserPending,
00103 UiRefreshing,
00104 ProcessPending,
00105 SessionStarted,
00106 ProcessCanceling,
00107 ProcessDone,
00108 CustomState,
00109 MaxState,
00110 };
00111
00112 protected:
00116 AuthSession(quint32 id, const QString &methodName, QObject *parent = 0);
00117 ~AuthSession();
00118
00119 public:
00125 const QString name() const;
00126
00137 void queryAvailableMechanisms(const QStringList &wantedMechanisms = QStringList());
00138
00168 void process(const SessionData &sessionData,
00169 const QString &mechanism = QString());
00170
00184 void challenge(const SessionData& sessionData,
00185 const QString &mechanism = QString()) {
00186 process(sessionData, mechanism);
00187 }
00188
00202 void request(const SessionData &sessionData,
00203 const QString &mechanism = QString()) {
00204 process(sessionData, mechanism);
00205 }
00206
00215 void cancel();
00216
00225 void signMessage(const SessionData ¶ms,
00226 const QString &mechanism = QString()) {
00227 process(params, mechanism);
00228 }
00229
00230 Q_SIGNALS:
00241 void error(const SignOn::Error &err);
00242
00249 void mechanismsAvailable(const QStringList &mechanisms);
00250
00263 void response(const SignOn::SessionData &sessionData);
00264
00271 void stateChanged(AuthSession::AuthSessionState state,
00272 const QString &message);
00273
00274 private:
00275 class AuthSessionImpl *impl;
00276 };
00277
00278 }
00279
00280 Q_DECLARE_METATYPE(SignOn::AuthSession::AuthSessionState)
00281
00282 #endif // AUTHSESSION_H