summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Util.cpp
blob: 17f3c2aa201730e0b2cf96221b82ea8c969127d3 (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
// -*- C++ -*-

#include "SSLIOP_Util.h"


ACE_RCSID (TAO_SSLIOP,
           SSLIOP_Util,
           "$Id$")


#include "SSLIOP_Connection_Handler.h"
#include "SSLIOP_Current.h"

#include "tao/ORB_Core.h"


int
TAO_SSLIOP_Util::setup_handler_state (TAO_ORB_Core *orb_core,
                                      TAO_IIOP_Properties *tcp_properties,
                                      TAO_SSLIOP_Connection_Handler_State &s)
{
  TAO_ENV_DECLARE_NEW_ENV;
  ACE_TRY
    {
      // Go straight to the object_ref_table in the ORB Core to avoid
      // the ORB::resolve_initial_references() mechanism's complaints
      // about the fact that the ORB isn't fully initialized yet
      // (happens on the client side).
      CORBA::Object_var obj =
        orb_core->object_ref_table ().resolve_initial_references (
          "SSLIOPCurrent"
          TAO_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      SSLIOP::Current_var current =
        SSLIOP::Current::_narrow (obj.in ()
                                  TAO_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (current.in ()))
        ACE_TRY_THROW (CORBA::INV_OBJREF ());

      TAO_SSLIOP_Current_var tao_current =
        TAO_SSLIOP_Current::_narrow (current.in ()
                                     TAO_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (tao_current.in ()))
        ACE_TRY_THROW (CORBA::INV_OBJREF ());


      s.tcp_properties = tcp_properties;
      s.ssliop_current = tao_current;
    }
  ACE_CATCHANY
    {
      if (TAO_debug_level > 0)
        ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                             "Could not resolve "
                             "\"SSLIOPCurrent\" object");

      return -1;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (-1);

  return 0;
}