Panda3D
httpBasicAuthorization.cxx
1 // Filename: httpBasicAuthorization.cxx
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 #include "httpBasicAuthorization.h"
16 
17 #ifdef HAVE_OPENSSL
18 
19 const string HTTPBasicAuthorization::_mechanism = "basic";
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: HTTPBasicAuthorization::Constructor
23 // Access: Protected
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 HTTPBasicAuthorization::
27 HTTPBasicAuthorization(const HTTPAuthorization::Tokens &tokens,
28  const URLSpec &url, bool is_proxy) :
29  HTTPAuthorization(tokens, url, is_proxy)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: HTTPBasicAuthorization::Destructor
35 // Access: Public, Virtual
36 // Description:
37 ////////////////////////////////////////////////////////////////////
38 HTTPBasicAuthorization::
39 ~HTTPBasicAuthorization() {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: HTTPBasicAuthorization::get_mechanism
44 // Access: Public, Virtual
45 // Description: Returns the type of authorization mechanism,
46 // represented as a string, e.g. "basic".
47 ////////////////////////////////////////////////////////////////////
48 const string &HTTPBasicAuthorization::
49 get_mechanism() const {
50  return _mechanism;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: HTTPBasicAuthorization::generate
55 // Access: Public, Virtual
56 // Description: Generates a suitable authorization string to send
57 // to the server, based on the data stored within this
58 // object, for retrieving the indicated URL with the
59 // given username:password.
60 ////////////////////////////////////////////////////////////////////
61 string HTTPBasicAuthorization::
62 generate(HTTPEnum::Method, const string &,
63  const string &username, const string &) {
64  return "Basic " + base64_encode(username);
65 }
66 
67 #endif // HAVE_OPENSSL
A container for a URL, e.g.
Definition: urlSpec.h:29