summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.h
blob: 61b9b9eb86f1605f7c051a67fbb4d6adca18a34d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// -*- C++ -*-

//=============================================================================
/**
 *  @file    SSLIOP_Connection_Handler.h
 *
 *  $Id$
 *
 *  @author  Carlos O'Ryan <coryan@uci.edu>
 *  @author  Ossama Othman <ossama@uci.edu>
 */
//=============================================================================


#ifndef TAO_SSLIOP_CONNECTION_HANDLER_H
#define TAO_SSLIOP_CONNECTION_HANDLER_H

#include /**/ "ace/pre.h"

#include "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "SSLIOP_Transport.h"
#include "SSLIOP_Current.h"

#include "tao/Connection_Handler.h"
#include "tao/IIOPC.h"

#include "ace/Reactor.h"

class TAO_IIOP_Properties;

namespace TAO
{
  namespace SSLIOP
  {

    /**
     * @class Connection_Handler
     *
     * @brief  Handles requests on a single connection.
     *
     * The Connection handler which is common for the Acceptor and
     * the Connector
     */
    class Connection_Handler
      : public SVC_HANDLER,
        public TAO_Connection_Handler
    {
    public:

      Connection_Handler (ACE_Thread_Manager* t = 0);

      /// Constructor.
      /**
       * @param arg Parameter is used by the Acceptor to pass the
       *        protocol configuration properties for this
       *        connection.
       */
      Connection_Handler (TAO_ORB_Core *orb_core,
                          CORBA::Boolean flag,
                          void *arg);

      /// Destructor.
      ~Connection_Handler (void);

      /**
       * @name Connection Handler overloads
       *
       * Connection Handler overloads.
       */
      //@{
      virtual int open_handler (void *);
      //@}

      /// Close called by the Acceptor or Connector when connection
      /// establishment fails.
      int close (u_long = 0);

      //@{
      /** @name Event Handler overloads
       */
      virtual int resume_handler (void);
      virtual int close_connection (void);
      virtual int handle_input (ACE_HANDLE);
      virtual int handle_output (ACE_HANDLE);
      virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
      virtual int handle_timeout (const ACE_Time_Value &current_time,
                                  const void *act = 0);
      virtual int open (void *);
      //@}

      /// Add ourselves to cache.
      int add_transport_to_cache (void);

      /// Process the @a listen_list.
      int process_listen_point_list (IIOP::ListenPointList &listen_list);

      /// Make the SSL session state available to the SSLIOP::Current
      /// object.
      int setup_ssl_state (TAO::SSLIOP::Current_Impl *&previous_current_impl,
                           TAO::SSLIOP::Current_Impl *new_current_impl,
                           bool &setup_done);

      /// Teardown the SSL session state.
      void teardown_ssl_state (
        TAO::SSLIOP::Current_Impl *previous_current_impl,
        bool &setup_done);

    protected:

      //@{
      /**
       * @name TAO_Connection Handler overloads
       */
      virtual int release_os_resources (void);
      virtual void pos_io_hook (int & return_value);
      //@}

    protected:

      /// Reference to the SSLIOP::Current object (downcast to gain
      /// access to the low-level management methods).
      TAO::SSLIOP::Current_var current_;

    private:

      /// TCP configuration for this connection.
      TAO_IIOP_Properties *tcp_properties_;

    };

    // ****************************************************************

    class Connection_Handler_State
    {
    public:

      /// TCP configuration for the connection associated with the
      /// connection handler.
      TAO_IIOP_Properties *tcp_properties;

      /// Reference to the (downcast) SSLIOP::Current object.
      TAO::SSLIOP::Current_var ssliop_current;

    };

    // ****************************************************************

    /**
     * @class State_Guard
     *
     * @brief This Class that sets up TSS SSL states upon
     *        instantiation, and tears down the TSS SSL state when
     *        that instance goes out of scope.
     *
     * This guard is used to make TSS SSL state configuration and
     * deconfiguration during an upcall exception safe.  Exceptions
     * are not supposed to be propagated up to the scope this guard is
     * used in, so this guard may be unnecessary.  However, since
     * proper TSS SSL state configuration/deconfiguration is critical
     * to proper security support, this guard is used to ensure that
     * configuration/deconfiguration is exception safe.
     */
    class State_Guard
    {
    public:

      /// Constructor that sets up the TSS SSL state.
      State_Guard (TAO::SSLIOP::Connection_Handler *handler,
                   int &result);

      /// Destructor that tears down the TSS SSL state.
      ~State_Guard (void);

    private:

      /// Pointer to the connection handler currently handling the
      /// request/upcall.
      Connection_Handler *handler_;

      /// The SSLIOP::Current implementation that was previously
      /// associated with the current thread and invocation.
      /**
       * It is stored here until the invocation completes, after which it
       * placed back into TSS.
       */
      Current_Impl *previous_current_impl_;

      /// The SSLIOP::Current implementation to be associated with the
      /// current invocation.
      Current_Impl current_impl_;

      /// Flag that specifies whether or not setup of the SSLIOP::Current
      /// object completed for the current thread and invocation.
      bool setup_done_;

    };

  }  // End SSLIOP namespace.
}  // End TAO namespace.


#if defined (__ACE_INLINE__)
#include "SSLIOP_Connection_Handler.i"
#endif /* __ACE_INLINE__ */


#include /**/ "ace/post.h"

#endif /* TAO_SSLIOP_CONNECTION_HANDLER_H */