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