00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef HTTPDIGESTAUTHORIZATION_H
00020 #define HTTPDIGESTAUTHORIZATION_H
00021
00022 #include "pandabase.h"
00023
00024
00025
00026
00027
00028 #ifdef HAVE_SSL
00029
00030 #include "httpAuthorization.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039 class HTTPDigestAuthorization : public HTTPAuthorization {
00040 public:
00041 HTTPDigestAuthorization(const Tokens &tokens, const URLSpec &url,
00042 bool is_proxy);
00043 virtual ~HTTPDigestAuthorization();
00044
00045 virtual const string &get_mechanism() const;
00046 virtual bool is_valid();
00047
00048 virtual string generate(HTTPEnum::Method method, const string &request_path,
00049 const string &username, const string &body);
00050
00051 public:
00052 enum Algorithm {
00053 A_unknown,
00054 A_md5,
00055 A_md5_sess,
00056 };
00057 enum Qop {
00058
00059 Q_unused = 0x000,
00060 Q_auth = 0x001,
00061 Q_auth_int = 0x002,
00062 };
00063
00064 private:
00065 static int match_qop_token(const string &token);
00066
00067 string calc_request_digest(const string &username, const string &password,
00068 HTTPEnum::Method method,
00069 const string &request_path, const string &body);
00070 string calc_h(const string &data) const;
00071 string calc_kd(const string &secret, const string &data) const;
00072 string get_a1(const string &username, const string &password);
00073 string get_a2(HTTPEnum::Method method, const string &request_path,
00074 const string &body);
00075 string get_hex_nonce_count() const;
00076
00077 static string calc_md5(const string &source);
00078 INLINE static char hexdigit(int value);
00079
00080 string _cnonce;
00081 string _nonce;
00082 int _nonce_count;
00083 string _opaque;
00084
00085 Algorithm _algorithm;
00086 string _a1;
00087
00088 int _qop;
00089 Qop _chosen_qop;
00090
00091 static const string _mechanism;
00092 };
00093
00094 ostream &operator << (ostream &out, HTTPDigestAuthorization::Algorithm algorithm);
00095 ostream &operator << (ostream &out, HTTPDigestAuthorization::Qop qop);
00096
00097 #include "httpDigestAuthorization.I"
00098
00099 #endif // HAVE_SSL
00100
00101 #endif
00102