Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / protocols / ace / INet / HTTPS_Session.h
blobe08d9dd61cd6e1d508d0636b1a9c40a3af025a77
1 /**
2 * @file HTTPS_Session.h
4 * @author Martin Corino <mcorino@remedy.nl>
5 */
7 #ifndef ACE_HTTPS_SESSION_H
8 #define ACE_HTTPS_SESSION_H
10 #include /**/ "ace/pre.h"
12 #include "ace/SSL/SSL_SOCK_Connector.h"
13 #include "ace/INet/HTTP_SessionBase.h"
14 #include "ace/INet/StreamHandler.h"
15 #include "ace/INet/SSLSock_IOStream.h"
16 #include "ace/INet/HTTPS_Context.h"
18 // we need OpenSSL > v0.9.8e to get support for SSL_set_SSL_CTX
19 #define OPENSSL_VERSION_098E 0x0090805fL
20 #if OPENSSL_VERSION_NUMBER > OPENSSL_VERSION_098E
21 # define SSL_HAS_SSL_set_SSL_CTX 1
22 #else
23 # define SSL_HAS_SSL_set_SSL_CTX 0
24 #endif
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 namespace ACE
30 namespace HTTPS
32 /**
33 * @class ACE_HTTPS_Session
35 * @brief Encapsulates HTTPS session.
38 template <ACE_SYNCH_DECL>
39 class Session_T : public ACE::HTTP::SessionBase
41 public:
42 typedef ACE::IOS::StreamHandler<ACE_SSL_SOCK_Stream, ACE_SYNCH_USE> connection_type;
44 Session_T (bool keep_alive = true
45 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1)
46 , Context* ctx = 0
47 #endif
50 Session_T (const ACE_Time_Value& timeout,
51 bool keep_alive = true,
52 const ACE_Time_Value* alive_timeout = 0
53 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1)
54 , Context* ctx = 0
55 #endif
58 virtual ~Session_T ();
60 virtual bool is_connected () const;
62 bool attach_connection (connection_type* connection);
64 protected:
65 void close_connection ();
67 virtual bool connect_i (const ACE_Synch_Options& sync_opt);
69 virtual void close_i ();
71 virtual std::iostream& sock_stream ();
73 private:
74 typedef ACE::IOS::SSLSock_IOStreamBase<ACE_SYNCH_USE> sock_stream_type;
76 connection_type* connection_;
77 sock_stream_type* sock_stream_;
78 #if defined (SSL_HAS_SSL_set_SSL_CTX) && (SSL_HAS_SSL_set_SSL_CTX == 1)
79 Context* context_;
80 #endif
83 typedef Session_T<ACE_NULL_SYNCH> Session;
87 ACE_END_VERSIONED_NAMESPACE_DECL
89 #include "ace/INet/HTTPS_Session.cpp"
91 #include /**/ "ace/post.h"
92 #endif /* ACE_HTTPS_SESSION_H */