00001 // $Id: HTTPS_Session.h 91122 2010-07-19 08:50:12Z mcorino $ 00002 00003 /** 00004 * @file HTTPS_Session.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_HTTPS_SESSION_H 00010 #define ACE_HTTPS_SESSION_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include "ace/SSL/SSL_SOCK_Connector.h" 00015 #include "ace/INet/HTTP_SessionBase.h" 00016 #include "ace/INet/StreamHandler.h" 00017 #include "ace/INet/SSLSock_IOStream.h" 00018 #include "ace/INet/HTTPS_Context.h" 00019 00020 // we need OpenSSL > v0.9.8e to get support for SSL_set_SSL_CTX 00021 #define OPENSSL_VERSION_098E 0x0090805fL 00022 #if OPENSSL_VERSION_NUMBER > OPENSSL_VERSION_098E 00023 # define SSL_HAS_SSL_set_SSL_CTX 1 00024 #else 00025 # define SSL_HAS_SSL_set_SSL_CTX 0 00026 #endif 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 namespace ACE 00031 { 00032 namespace HTTPS 00033 { 00034 /** 00035 * @class ACE_HTTPS_Session 00036 * 00037 * @brief Encapsulates HTTPS session. 00038 * 00039 */ 00040 template <ACE_SYNCH_DECL> 00041 class Session_T : public ACE::HTTP::SessionBase 00042 { 00043 public: 00044 typedef ACE::IOS::StreamHandler<ACE_SSL_SOCK_Stream, ACE_SYNCH_USE> connection_type; 00045 00046 Session_T (bool keep_alive = true 00047 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1) 00048 , Context* ctx = 0 00049 #endif 00050 ); 00051 00052 Session_T (const ACE_Time_Value& timeout, 00053 bool keep_alive = true, 00054 const ACE_Time_Value* alive_timeout = 0 00055 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1) 00056 , Context* ctx = 0 00057 #endif 00058 ); 00059 00060 virtual ~Session_T (); 00061 00062 virtual bool is_connected () const; 00063 00064 bool attach_connection (connection_type* connection); 00065 00066 protected: 00067 00068 void close_connection (); 00069 00070 virtual bool connect_i (const ACE_Synch_Options& sync_opt); 00071 00072 virtual void close_i (); 00073 00074 virtual std::iostream& sock_stream (); 00075 00076 private: 00077 typedef ACE::IOS::SSLSock_IOStreamBase<ACE_SYNCH_USE> sock_stream_type; 00078 00079 connection_type* connection_; 00080 sock_stream_type* sock_stream_; 00081 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1) 00082 Context* context_; 00083 #endif 00084 }; 00085 00086 typedef Session_T<ACE_NULL_SYNCH> Session; 00087 } 00088 } 00089 00090 ACE_END_VERSIONED_NAMESPACE_DECL 00091 00092 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00093 #include "ace/INet/HTTPS_Session.cpp" 00094 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00095 00096 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00097 #pragma implementation ("HTTPS_Session.cpp") 00098 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00099 00100 #include /**/ "ace/post.h" 00101 #endif /* ACE_HTTPS_SESSION_H */