SSLIOP_Connection_Handler.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SSLIOP_Connection_Handler.h
00006  *
00007  *  SSLIOP_Connection_Handler.h,v 1.30 2006/03/14 06:14:35 jtc Exp
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       /**
00061        * @param arg Parameter is used by the Acceptor to pass the
00062        *        protocol configuration properties for this
00063        *        connection.
00064        */
00065       Connection_Handler (TAO_ORB_Core *orb_core,
00066                           CORBA::Boolean flag);
00067 
00068       /// Destructor.
00069       ~Connection_Handler (void);
00070 
00071       /**
00072        * @name Connection Handler overloads
00073        *
00074        * Connection Handler overloads.
00075        */
00076       //@{
00077       virtual int open_handler (void *);
00078       //@}
00079 
00080       /// Close called by the Acceptor or Connector when connection
00081       /// establishment fails.
00082       int close (u_long = 0);
00083 
00084       //@{
00085       /** @name Event Handler overloads
00086        */
00087       virtual int resume_handler (void);
00088       virtual int close_connection (void);
00089       virtual int handle_input (ACE_HANDLE);
00090       virtual int handle_output (ACE_HANDLE);
00091       virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
00092       virtual int handle_timeout (const ACE_Time_Value &current_time,
00093                                   const void *act = 0);
00094       virtual int open (void *);
00095       //@}
00096 
00097       /// Add ourselves to cache.
00098       int add_transport_to_cache (void);
00099 
00100       /// Process the @a listen_list.
00101       int process_listen_point_list (IIOP::ListenPointList &listen_list);
00102 
00103       /// Make the SSL session state available to the SSLIOP::Current
00104       /// object.
00105       int setup_ssl_state (TAO::SSLIOP::Current_Impl *&previous_current_impl,
00106                            TAO::SSLIOP::Current_Impl *new_current_impl,
00107                            bool &setup_done);
00108 
00109       /// Teardown the SSL session state.
00110       void teardown_ssl_state (
00111         TAO::SSLIOP::Current_Impl *previous_current_impl,
00112         bool &setup_done);
00113 
00114     protected:
00115 
00116       //@{
00117       /**
00118        * @name TAO_Connection Handler overloads
00119        */
00120       virtual int release_os_resources (void);
00121       virtual void pos_io_hook (int & return_value);
00122       //@}
00123 
00124     protected:
00125 
00126       /// Reference to the SSLIOP::Current object (downcast to gain
00127       /// access to the low-level management methods).
00128       TAO::SSLIOP::Current_var current_;
00129 
00130     private:
00131 
00132       /// TCP configuration for this connection.
00133       TAO_IIOP_Properties *tcp_properties_;
00134 
00135     };
00136 
00137     // ****************************************************************
00138 
00139     /**
00140      * @class State_Guard
00141      *
00142      * @brief This Class that sets up TSS SSL states upon
00143      *        instantiation, and tears down the TSS SSL state when
00144      *        that instance goes out of scope.
00145      *
00146      * This guard is used to make TSS SSL state configuration and
00147      * deconfiguration during an upcall exception safe.  Exceptions
00148      * are not supposed to be propagated up to the scope this guard is
00149      * used in, so this guard may be unnecessary.  However, since
00150      * proper TSS SSL state configuration/deconfiguration is critical
00151      * to proper security support, this guard is used to ensure that
00152      * configuration/deconfiguration is exception safe.
00153      */
00154     class State_Guard
00155     {
00156     public:
00157 
00158       /// Constructor that sets up the TSS SSL state.
00159       State_Guard (TAO::SSLIOP::Connection_Handler *handler,
00160                    int &result);
00161 
00162       /// Destructor that tears down the TSS SSL state.
00163       ~State_Guard (void);
00164 
00165     private:
00166 
00167       /// Pointer to the connection handler currently handling the
00168       /// request/upcall.
00169       Connection_Handler *handler_;
00170 
00171       /// The SSLIOP::Current implementation that was previously
00172       /// associated with the current thread and invocation.
00173       /**
00174        * It is stored here until the invocation completes, after which it
00175        * placed back into TSS.
00176        */
00177       Current_Impl *previous_current_impl_;
00178 
00179       /// The SSLIOP::Current implementation to be associated with the
00180       /// current invocation.
00181       Current_Impl current_impl_;
00182 
00183       /// Flag that specifies whether or not setup of the SSLIOP::Current
00184       /// object completed for the current thread and invocation.
00185       bool setup_done_;
00186 
00187     };
00188 
00189   }  // End SSLIOP namespace.
00190 }  // End TAO namespace.
00191 
00192 TAO_END_VERSIONED_NAMESPACE_DECL
00193 
00194 
00195 #if defined (__ACE_INLINE__)
00196 #include "orbsvcs/SSLIOP/SSLIOP_Connection_Handler.i"
00197 #endif /* __ACE_INLINE__ */
00198 
00199 
00200 #include /**/ "ace/post.h"
00201 
00202 #endif /* TAO_SSLIOP_CONNECTION_HANDLER_H */

Generated on Thu Nov 9 13:54:13 2006 for TAO_SSLIOP by doxygen 1.3.6