00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef HTTPAUTHORIZATION_H
00016 #define HTTPAUTHORIZATION_H
00017
00018 #include "pandabase.h"
00019
00020
00021
00022
00023
00024 #ifdef HAVE_OPENSSL
00025
00026 #include "referenceCount.h"
00027 #include "httpEnum.h"
00028 #include "pmap.h"
00029
00030 class URLSpec;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class HTTPAuthorization : public ReferenceCount {
00044 public:
00045 typedef pmap<string, string> Tokens;
00046 typedef pmap<string, Tokens> AuthenticationSchemes;
00047
00048 protected:
00049 HTTPAuthorization(const Tokens &tokens, const URLSpec &url,
00050 bool is_proxy);
00051 public:
00052 virtual ~HTTPAuthorization();
00053
00054 virtual const string &get_mechanism() const=0;
00055 virtual bool is_valid();
00056
00057 INLINE const string &get_realm() const;
00058 INLINE const vector_string &get_domain() const;
00059
00060 virtual string generate(HTTPEnum::Method method, const string &request_path,
00061 const string &username, const string &body)=0;
00062
00063 static void parse_authentication_schemes(AuthenticationSchemes &schemes,
00064 const string &field_value);
00065 static URLSpec get_canonical_url(const URLSpec &url);
00066 static string base64_encode(const string &s);
00067 static string base64_decode(const string &s);
00068
00069 protected:
00070 static size_t scan_quoted_or_unquoted_string(string &result,
00071 const string &source,
00072 size_t start);
00073
00074 protected:
00075 string _realm;
00076 vector_string _domain;
00077 };
00078
00079 #include "httpAuthorization.I"
00080
00081 #endif // HAVE_OPENSSL
00082
00083 #endif
00084