00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file SSLIOP_Connection_Handler.h 00006 * 00007 * $Id: SSLIOP_Connection_Handler.h 78931 2007-07-18 09:59:36Z johnnyw $ 00008 * 00009 * @author Carlos O'Ryan <coryan@uci.edu> 00010 * @author Ossama Othman <ossama@uci.edu> 00011 */ 00012 //============================================================================= 00013 00014 00015 #ifndef TAO_SSLIOP_CONNECTION_HANDLER_H 00016 #define TAO_SSLIOP_CONNECTION_HANDLER_H 00017 00018 #include /**/ "ace/pre.h" 00019 00020 #include "ace/config-all.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 #pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include "orbsvcs/SSLIOP/SSLIOP_Current.h" 00027 #include "orbsvcs/SSLIOP/SSLIOP_Transport.h" 00028 00029 #include "tao/Connection_Handler.h" 00030 #include "tao/IIOPC.h" 00031 00032 #include "ace/Reactor.h" 00033 00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00035 00036 class TAO_IIOP_Properties; 00037 00038 namespace TAO 00039 { 00040 namespace SSLIOP 00041 { 00042 00043 /** 00044 * @class Connection_Handler 00045 * 00046 * @brief Handles requests on a single connection. 00047 * 00048 * The Connection handler which is common for the Acceptor and 00049 * the Connector 00050 */ 00051 class Connection_Handler 00052 : public SVC_HANDLER, 00053 public TAO_Connection_Handler 00054 { 00055 public: 00056 00057 Connection_Handler (ACE_Thread_Manager* t = 0); 00058 00059 /// Constructor. 00060 Connection_Handler (TAO_ORB_Core *orb_core); 00061 00062 /// Destructor. 00063 ~Connection_Handler (void); 00064 00065 /** 00066 * @name Connection Handler overloads 00067 * 00068 * Connection Handler overloads. 00069 */ 00070 //@{ 00071 virtual int open_handler (void *); 00072 //@} 00073 00074 /// Close called by the Acceptor or Connector when connection 00075 /// establishment fails. 00076 int close (u_long = 0); 00077 00078 //@{ 00079 /** @name Event Handler overloads 00080 */ 00081 virtual int resume_handler (void); 00082 virtual int close_connection (void); 00083 virtual int handle_input (ACE_HANDLE); 00084 virtual int handle_output (ACE_HANDLE); 00085 virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); 00086 virtual int handle_timeout (const ACE_Time_Value ¤t_time, 00087 const void *act = 0); 00088 virtual int open (void *); 00089 //@} 00090 00091 /// Add ourselves to cache. 00092 int add_transport_to_cache (void); 00093 00094 /// Process the @a listen_list. 00095 int process_listen_point_list (IIOP::ListenPointList &listen_list); 00096 00097 /// Make the SSL session state available to the SSLIOP::Current 00098 /// object. 00099 int setup_ssl_state (TAO::SSLIOP::Current_Impl *&previous_current_impl, 00100 TAO::SSLIOP::Current_Impl *new_current_impl, 00101 bool &setup_done); 00102 00103 /// Teardown the SSL session state. 00104 void teardown_ssl_state ( 00105 TAO::SSLIOP::Current_Impl *previous_current_impl, 00106 bool &setup_done); 00107 00108 protected: 00109 00110 //@{ 00111 /** 00112 * @name TAO_Connection Handler overloads 00113 */ 00114 virtual int release_os_resources (void); 00115 virtual void pos_io_hook (int & return_value); 00116 //@} 00117 00118 protected: 00119 00120 /// Reference to the SSLIOP::Current object (downcast to gain 00121 /// access to the low-level management methods). 00122 TAO::SSLIOP::Current_var current_; 00123 00124 private: 00125 00126 /// TCP configuration for this connection. 00127 TAO_IIOP_Properties *tcp_properties_; 00128 00129 }; 00130 00131 // **************************************************************** 00132 00133 /** 00134 * @class State_Guard 00135 * 00136 * @brief This Class that sets up TSS SSL states upon 00137 * instantiation, and tears down the TSS SSL state when 00138 * that instance goes out of scope. 00139 * 00140 * This guard is used to make TSS SSL state configuration and 00141 * deconfiguration during an upcall exception safe. Exceptions 00142 * are not supposed to be propagated up to the scope this guard is 00143 * used in, so this guard may be unnecessary. However, since 00144 * proper TSS SSL state configuration/deconfiguration is critical 00145 * to proper security support, this guard is used to ensure that 00146 * configuration/deconfiguration is exception safe. 00147 */ 00148 class State_Guard 00149 { 00150 public: 00151 00152 /// Constructor that sets up the TSS SSL state. 00153 State_Guard (TAO::SSLIOP::Connection_Handler *handler, 00154 int &result); 00155 00156 /// Destructor that tears down the TSS SSL state. 00157 ~State_Guard (void); 00158 00159 private: 00160 00161 /// Pointer to the connection handler currently handling the 00162 /// request/upcall. 00163 Connection_Handler *handler_; 00164 00165 /// The SSLIOP::Current implementation that was previously 00166 /// associated with the current thread and invocation. 00167 /** 00168 * It is stored here until the invocation completes, after which it 00169 * placed back into TSS. 00170 */ 00171 Current_Impl *previous_current_impl_; 00172 00173 /// The SSLIOP::Current implementation to be associated with the 00174 /// current invocation. 00175 Current_Impl current_impl_; 00176 00177 /// Flag that specifies whether or not setup of the SSLIOP::Current 00178 /// object completed for the current thread and invocation. 00179 bool setup_done_; 00180 00181 }; 00182 00183 } // End SSLIOP namespace. 00184 } // End TAO namespace. 00185 00186 TAO_END_VERSIONED_NAMESPACE_DECL 00187 00188 00189 #if defined (__ACE_INLINE__) 00190 #include "orbsvcs/SSLIOP/SSLIOP_Connection_Handler.inl" 00191 #endif /* __ACE_INLINE__ */ 00192 00193 00194 #include /**/ "ace/post.h" 00195 00196 #endif /* TAO_SSLIOP_CONNECTION_HANDLER_H */