KIOSlave
httpauthentication.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef HTTPAUTHENTICATION_H
00021 #define HTTPAUTHENTICATION_H
00022
00023 #include <config-gssapi.h>
00024
00025 #ifndef HTTP_H_ // if we're included from http.cpp all necessary headers are already included
00026 #include <QtCore/QByteArray>
00027 #include <QtCore/QString>
00028 #include <QtCore/QList>
00029 #include <kio/authinfo.h>
00030 #endif
00031
00032 namespace KIO {
00033 class AuthInfo;
00034 }
00035
00036 class KAbstractHttpAuthentication
00037 {
00038 public:
00039 KAbstractHttpAuthentication()
00040 {
00041 reset();
00042 }
00043
00044 static QByteArray bestOffer(const QList<QByteArray> &offers);
00045 static KAbstractHttpAuthentication *newAuth(const QByteArray &offer);
00046
00047 virtual ~KAbstractHttpAuthentication() {}
00048
00049
00050 void reset();
00051
00052 virtual QByteArray scheme() const = 0;
00053
00054 virtual void setChallenge(const QByteArray &c, const KUrl &resource, const QByteArray &httpMethod);
00055
00056
00057 bool needCredentials() const { return m_needCredentials; }
00058
00059
00060 virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const = 0;
00061
00062 virtual void generateResponse(const QString &user,
00063 const QString &password) = 0;
00064
00065
00066
00067
00068
00069 bool isError() const { return m_isError; }
00070
00071 bool forceKeepAlive() const { return m_forceKeepAlive; }
00072
00073 bool forceDisconnect() const { return m_forceDisconnect; }
00074
00075
00076 QString headerFragment() const { return m_headerFragment; }
00077
00078 QString realm() const;
00079
00080 protected:
00081 void authInfoBoilerplate(KIO::AuthInfo *a) const;
00082 void generateResponseCommon(const QString &user, const QString &password);
00083
00084 QByteArray m_scheme;
00085 QList<QByteArray> m_challenge;
00086 KUrl m_resource;
00087 QByteArray m_httpMethod;
00088
00089 bool m_isError;
00090 bool m_needCredentials;
00091 bool m_forceKeepAlive;
00092 bool m_forceDisconnect;
00093 QString m_headerFragment;
00094
00095 QString m_username;
00096 QString m_password;
00097 };
00098
00099
00100 class KHttpBasicAuthentication : public KAbstractHttpAuthentication
00101 {
00102 public:
00103 virtual QByteArray scheme() const;
00104 virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const;
00105 virtual void generateResponse(const QString &user, const QString &password);
00106 private:
00107 friend class KAbstractHttpAuthentication;
00108 KHttpBasicAuthentication()
00109 : KAbstractHttpAuthentication() {}
00110 };
00111
00112
00113 class KHttpDigestAuthentication : public KAbstractHttpAuthentication
00114 {
00115 public:
00116 virtual QByteArray scheme() const;
00117 virtual void setChallenge(const QByteArray &c, const KUrl &resource, const QByteArray &httpMethod);
00118 virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const;
00119 virtual void generateResponse(const QString &user, const QString &password);
00120 private:
00121 friend class KAbstractHttpAuthentication;
00122 KHttpDigestAuthentication()
00123 : KAbstractHttpAuthentication() {}
00124 };
00125
00126
00127 class KHttpNtlmAuthentication : public KAbstractHttpAuthentication
00128 {
00129 public:
00130 virtual QByteArray scheme() const;
00131 virtual void setChallenge(const QByteArray &c, const KUrl &resource, const QByteArray &httpMethod);
00132 virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const;
00133 virtual void generateResponse(const QString &user, const QString &password);
00134 private:
00135 friend class KAbstractHttpAuthentication;
00136 KHttpNtlmAuthentication()
00137 : KAbstractHttpAuthentication() {}
00138 };
00139
00140
00141 #ifdef HAVE_LIBGSSAPI
00142 class KHttpNegotiateAuthentication : public KAbstractHttpAuthentication
00143 {
00144 public:
00145 virtual QByteArray scheme() const;
00146 virtual void setChallenge(const QByteArray &c, const KUrl &resource, const QByteArray &httpMethod);
00147 virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const;
00148 virtual void generateResponse(const QString &user, const QString &password);
00149 private:
00150 friend class KAbstractHttpAuthentication;
00151 KHttpNegotiateAuthentication()
00152 : KAbstractHttpAuthentication() {}
00153 };
00154 #endif // HAVE_LIBGSSAPI
00155
00156 #endif // HTTPAUTHENTICATION_H