00001 // $Id: HTTP_BasicAuthentication.h 91132 2010-07-20 05:28:27Z mcorino $ 00002 00003 /** 00004 * @file HTTP_BasicAuthentication.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_HTTP_BASIC_AUTHENTICATION_H 00010 #define ACE_HTTP_BASIC_AUTHENTICATION_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include /**/ "ace/config-all.h" 00015 00016 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00017 # pragma once 00018 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00019 00020 #include "ace/INet/INet_Export.h" 00021 #include "ace/INet/HTTP_Request.h" 00022 00023 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00024 00025 namespace ACE 00026 { 00027 namespace HTTP 00028 { 00029 /** 00030 * @class ACE_HTTP_BasicAuthentication 00031 * 00032 * @brief Provides support for HTTP Basic Authentication credentials. 00033 * 00034 */ 00035 class ACE_INET_Export BasicAuthentication 00036 { 00037 public: 00038 /// Constructor 00039 BasicAuthentication(); 00040 00041 /// Constructor. Sets user id and password. 00042 BasicAuthentication(const ACE_CString& user, const ACE_CString& passwd); 00043 00044 /// Constructor. Decodes cedentials from request (if any). 00045 BasicAuthentication(const Request& request); 00046 00047 /// Destructor 00048 virtual ~BasicAuthentication(); 00049 00050 /// Set user id. 00051 void user (const ACE_CString& user); 00052 00053 /// Get user id. 00054 const ACE_CString& user () const; 00055 00056 /// Set password. 00057 void password (const ACE_CString& passwd); 00058 00059 /// Get password. 00060 const ACE_CString& password () const; 00061 00062 /// Add authentication header with encoded credentials to request. 00063 void set_credentials (Request& request) const; 00064 00065 static const char* SCHEME; 00066 00067 private: 00068 // prevent copying 00069 BasicAuthentication(const BasicAuthentication&); 00070 BasicAuthentication& operator =(BasicAuthentication&); 00071 00072 ACE_CString user_; 00073 ACE_CString passwd_; 00074 }; 00075 } 00076 } 00077 00078 ACE_END_VERSIONED_NAMESPACE_DECL 00079 00080 #if defined (__ACE_INLINE__) 00081 #include "ace/INet/HTTP_BasicAuthentication.inl" 00082 #endif 00083 00084 #include /**/ "ace/post.h" 00085 #endif /* ACE_HTTP_BASIC_AUTHENTICATION_H */