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