Panda3D
 All Classes Functions Variables Enumerations
httpAuthorization.h
00001 // Filename: httpAuthorization.h
00002 // Created by:  drose (22Oct02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef HTTPAUTHORIZATION_H
00016 #define HTTPAUTHORIZATION_H
00017 
00018 #include "pandabase.h"
00019 
00020 // This module requires OpenSSL to compile, even though it doesn't
00021 // actually use any OpenSSL code, because it is a support module for
00022 // HTTPChannel, which *does* use OpenSSL code.
00023 
00024 #ifdef HAVE_OPENSSL
00025 
00026 #include "referenceCount.h"
00027 #include "httpEnum.h"
00028 #include "pmap.h"
00029 
00030 class URLSpec;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : HTTPAuthorization
00034 // Description : A base class for storing information used to fulfill
00035 //               authorization requests in the past, which can
00036 //               possibly be re-used for future requests to the same
00037 //               server.
00038 //
00039 //               This class does not need to be exported from the DLL
00040 //               because it has no public interface; it is simply a
00041 //               helper class for HTTPChannel.
00042 ////////////////////////////////////////////////////////////////////
00043 class HTTPAuthorization : public ReferenceCount {
00044 public:
00045   typedef pmap<string, string> Tokens;
00046   typedef pmap<string, Tokens> AuthenticationSchemes;
00047 
00048 protected:
00049   HTTPAuthorization(const Tokens &tokens, const URLSpec &url,
00050                     bool is_proxy);
00051 public:
00052   virtual ~HTTPAuthorization();
00053 
00054   virtual const string &get_mechanism() const=0;
00055   virtual bool is_valid();
00056 
00057   INLINE const string &get_realm() const;
00058   INLINE const vector_string &get_domain() const;
00059 
00060   virtual string generate(HTTPEnum::Method method, const string &request_path,
00061                           const string &username, const string &body)=0;
00062 
00063   static void parse_authentication_schemes(AuthenticationSchemes &schemes,
00064                                            const string &field_value);
00065   static URLSpec get_canonical_url(const URLSpec &url);
00066   static string base64_encode(const string &s);
00067   static string base64_decode(const string &s);
00068 
00069 protected:
00070   static size_t scan_quoted_or_unquoted_string(string &result, 
00071                                                const string &source, 
00072                                                size_t start);
00073 
00074 protected:
00075   string _realm;
00076   vector_string _domain;
00077 };
00078 
00079 #include "httpAuthorization.I"
00080 
00081 #endif  // HAVE_OPENSSL
00082 
00083 #endif
00084 
 All Classes Functions Variables Enumerations