2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 #include "ace/SString.h"
7 const ACE_TCHAR
*ior_output_file
= 0;
8 const char *cert_file
= "cacert.pem";
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 ACE_CString
env ("SSL_CERT_FILE=");
42 ACE_OS::putenv (env
.c_str ());
45 CORBA::ORB_init (argc
, argv
);
47 CORBA::Object_var obj
=
48 orb
->resolve_initial_references ("RootPOA");
50 if (CORBA::is_nil (obj
.in ()))
51 ACE_ERROR_RETURN ((LM_ERROR
,
52 "(%P|%t) ERROR: Unable to initialize the "
56 PortableServer::POA_var root_poa
=
57 PortableServer::POA::_narrow (obj
.in ());
59 PortableServer::POAManager_var poa_manager
=
60 root_poa
->the_POAManager ();
62 if (parse_args (argc
, argv
) != 0)
66 orb
->resolve_initial_references ("SecurityLevel3:SecurityCurrent");
68 SecurityLevel3::SecurityCurrent_var security_current
=
69 SecurityLevel3::SecurityCurrent::_narrow (obj
.in ());
71 if (CORBA::is_nil (security_current
.in ()))
72 ACE_ERROR_RETURN ((LM_ERROR
,
73 "(%P|%t) ERROR: SecurityCurrent reference "
77 Foo_i
*server_impl
= 0;
79 ACE_NEW_RETURN (server_impl
,
81 security_current
.in ()),
84 PortableServer::ServantBase_var
owner_transfer (server_impl
);
87 server_impl
->_this ();
89 // Sanity check on SSLIOP profile equivalence.
90 // Since the POA is reference counting the servants, this
91 // implementation must still exist when the POA is destroyed.
92 Foo_i
server_impl2 (orb
.in (), security_current
.in ());
93 Foo::Bar_var server2
=
94 server_impl2
._this ();
96 const CORBA::Boolean equivalent
=
97 server
->_is_equivalent (server2
.in ());
101 ACE_ERROR ((LM_ERROR
,
102 "(%P|%t) ERROR: SSLIOP profile equivalence "
106 CORBA::String_var ior
=
107 orb
->object_to_string (server
.in ());
109 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
111 // If the ior_output_file exists, output the ior to it
112 if (ior_output_file
!= 0)
114 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
115 if (output_file
== 0)
116 ACE_ERROR_RETURN ((LM_ERROR
,
117 "Cannot open output file for writing IOR: %s",
120 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
121 ACE_OS::fclose (output_file
);
124 poa_manager
->activate ();
126 // Clear the STDERR flags so that the first expected
127 // failed connection attempt by the client doesn't trigger an
128 // error on the scoreboard. The flag is also set in the
129 // Foo_i::baz() method since the connection has been successfully
130 // made by that time.
131 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::STDERR
);
133 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::STDERR
);
135 ACE_DEBUG ((LM_DEBUG
,
137 "Event loop finished.\n"));
139 root_poa
->destroy (true, true);
143 catch (const CORBA::Exception
& ex
)
145 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::STDERR
);
146 ex
._tao_print_exception ("Caught exception:");