00001 // Filename: httpBasicAuthorization.cxx 00002 // Created by: drose (22Oct02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "httpBasicAuthorization.h" 00020 00021 #ifdef HAVE_SSL 00022 00023 const string HTTPBasicAuthorization::_mechanism = "basic"; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: HTTPBasicAuthorization::Constructor 00027 // Access: Protected 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 HTTPBasicAuthorization:: 00031 HTTPBasicAuthorization(const HTTPAuthorization::Tokens &tokens, 00032 const URLSpec &url, bool is_proxy) : 00033 HTTPAuthorization(tokens, url, is_proxy) 00034 { 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: HTTPBasicAuthorization::Destructor 00039 // Access: Public, Virtual 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 HTTPBasicAuthorization:: 00043 ~HTTPBasicAuthorization() { 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: HTTPBasicAuthorization::get_mechanism 00048 // Access: Public, Virtual 00049 // Description: Returns the type of authorization mechanism, 00050 // represented as a string, e.g. "basic". 00051 //////////////////////////////////////////////////////////////////// 00052 const string &HTTPBasicAuthorization:: 00053 get_mechanism() const { 00054 return _mechanism; 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: HTTPBasicAuthorization::generate 00059 // Access: Public, Virtual 00060 // Description: Generates a suitable authorization string to send 00061 // to the server, based on the data stored within this 00062 // object, for retrieving the indicated URL with the 00063 // given username:password. 00064 //////////////////////////////////////////////////////////////////// 00065 string HTTPBasicAuthorization:: 00066 generate(HTTPEnum::Method, const string &, 00067 const string &username, const string &) { 00068 return "Basic " + base64_encode(username); 00069 } 00070 00071 #endif // HAVE_SSL