Panda3D
 All Classes Functions Variables Enumerations
httpAuthorization.h
1 // Filename: httpAuthorization.h
2 // Created by: drose (22Oct02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef HTTPAUTHORIZATION_H
16 #define HTTPAUTHORIZATION_H
17 
18 #include "pandabase.h"
19 
20 // This module requires OpenSSL to compile, even though it doesn't
21 // actually use any OpenSSL code, because it is a support module for
22 // HTTPChannel, which *does* use OpenSSL code.
23 
24 #ifdef HAVE_OPENSSL
25 
26 #include "referenceCount.h"
27 #include "httpEnum.h"
28 #include "pmap.h"
29 
30 class URLSpec;
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : HTTPAuthorization
34 // Description : A base class for storing information used to fulfill
35 // authorization requests in the past, which can
36 // possibly be re-used for future requests to the same
37 // server.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDAEXPRESS HTTPAuthorization : public ReferenceCount {
40 public:
41  typedef pmap<string, string> Tokens;
42  typedef pmap<string, Tokens> AuthenticationSchemes;
43 
44 protected:
45  HTTPAuthorization(const Tokens &tokens, const URLSpec &url,
46  bool is_proxy);
47 public:
48  virtual ~HTTPAuthorization();
49 
50  virtual const string &get_mechanism() const=0;
51  virtual bool is_valid();
52 
53  INLINE const string &get_realm() const;
54  INLINE const vector_string &get_domain() const;
55 
56  virtual string generate(HTTPEnum::Method method, const string &request_path,
57  const string &username, const string &body)=0;
58 
59  static void parse_authentication_schemes(AuthenticationSchemes &schemes,
60  const string &field_value);
61  static URLSpec get_canonical_url(const URLSpec &url);
62  static string base64_encode(const string &s);
63  static string base64_decode(const string &s);
64 
65 protected:
66  static size_t scan_quoted_or_unquoted_string(string &result,
67  const string &source,
68  size_t start);
69 
70 protected:
71  string _realm;
72  vector_string _domain;
73 };
74 
75 #include "httpAuthorization.I"
76 
77 #endif // HAVE_OPENSSL
78 
79 #endif
80 
A container for a URL, e.g.
Definition: urlSpec.h:29
A base class for all things that want to be reference-counted.