00001 #include "orbsvcs/SSLIOP/SSLIOP_ORBInitializer.h"
00002
00003
00004 ACE_RCSID (SSLIOP,
00005 SSLIOP_ORBInitializer,
00006 "SSLIOP_ORBInitializer.cpp,v 1.21 2006/03/14 06:14:35 jtc Exp")
00007
00008
00009 #include "orbsvcs/SSLIOP/SSLIOP_Current.h"
00010 #include "orbsvcs/SSLIOP/SSLIOP_Invocation_Interceptor.h"
00011
00012 #include "orbsvcs/SSLIOP/SSLIOP_CredentialsAcquirerFactory.h"
00013
00014 #include "orbsvcs/Security/SL3_SecurityCurrent.h"
00015 #include "orbsvcs/Security/SL3_CredentialsCurator.h"
00016
00017 #include "orbsvcs/SSLIOPC.h"
00018 #include "orbsvcs/CSIIOPC.h"
00019
00020 #include "tao/Exception.h"
00021 #include "tao/PI/ORBInitInfo.h"
00022 #include "tao/debug.h"
00023
00024 #include "ace/Auto_Ptr.h"
00025
00026
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 TAO::SSLIOP::ORBInitializer::ORBInitializer (
00030 ::Security::QOP qop,
00031 CSIIOP::AssociationOptions csiv2_target_supports,
00032 CSIIOP::AssociationOptions csiv2_target_requires)
00033 : qop_ (qop),
00034 csiv2_target_supports_ (csiv2_target_supports),
00035 csiv2_target_requires_ (csiv2_target_requires)
00036 {
00037 }
00038
00039 void
00040 TAO::SSLIOP::ORBInitializer::pre_init (
00041 PortableInterceptor::ORBInitInfo_ptr info
00042 ACE_ENV_ARG_DECL)
00043 ACE_THROW_SPEC ((CORBA::SystemException))
00044 {
00045 TAO_ORBInitInfo_var tao_info =
00046 TAO_ORBInitInfo::_narrow (info
00047 ACE_ENV_ARG_PARAMETER);
00048 ACE_CHECK;
00049
00050 if (CORBA::is_nil (tao_info.in ()))
00051 ACE_THROW (CORBA::INV_OBJREF ());
00052
00053
00054
00055
00056 TAO_ORB_Core *orb_core = tao_info->orb_core ();
00057
00058
00059
00060
00061
00062
00063 SSLIOP::Current_ptr current;
00064 ACE_NEW_THROW_EX (current,
00065 TAO::SSLIOP::Current (orb_core),
00066 CORBA::NO_MEMORY (
00067 CORBA::SystemException::_tao_minor_code (
00068 TAO::VMCID,
00069 ENOMEM),
00070 CORBA::COMPLETED_NO));
00071 ACE_CHECK;
00072
00073 SSLIOP::Current_var ssliop_current = current;
00074
00075
00076 info->register_initial_reference ("SSLIOPCurrent",
00077 ssliop_current.in ()
00078 ACE_ENV_ARG_PARAMETER);
00079 ACE_CHECK;
00080 }
00081
00082 void
00083 TAO::SSLIOP::ORBInitializer::post_init (
00084 PortableInterceptor::ORBInitInfo_ptr info
00085 ACE_ENV_ARG_DECL)
00086 ACE_THROW_SPEC ((CORBA::SystemException))
00087 {
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 CORBA::Object_var obj =
00099 info->resolve_initial_references ("SSLIOPCurrent"
00100 ACE_ENV_ARG_PARAMETER);
00101 ACE_CHECK;
00102
00103 SSLIOP::Current_var ssliop_current =
00104 SSLIOP::Current::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
00105 ACE_CHECK;
00106
00107 if (!CORBA::is_nil (ssliop_current.in ()))
00108 {
00109 TAO::SSLIOP::Current *tao_current =
00110 dynamic_cast<TAO::SSLIOP::Current *> (ssliop_current.in ());
00111
00112 if (tao_current != 0)
00113 {
00114 const size_t slot =
00115 this->get_tss_slot_id (info ACE_ENV_ARG_PARAMETER);
00116 ACE_CHECK;
00117
00118 tao_current->tss_slot (slot);
00119 }
00120 else
00121 ACE_THROW (CORBA::INTERNAL ());
00122 }
00123
00124
00125 PortableInterceptor::ServerRequestInterceptor_ptr si =
00126 PortableInterceptor::ServerRequestInterceptor::_nil ();
00127 ACE_NEW_THROW_EX (si,
00128 TAO::SSLIOP::Server_Invocation_Interceptor (
00129 ssliop_current.in (),
00130 this->qop_),
00131 CORBA::NO_MEMORY (
00132 CORBA::SystemException::_tao_minor_code (
00133 TAO::VMCID,
00134 ENOMEM),
00135 CORBA::COMPLETED_NO));
00136 ACE_CHECK;
00137
00138 PortableInterceptor::ServerRequestInterceptor_var si_interceptor =
00139 si;
00140
00141
00142
00143 info->add_server_request_interceptor (si_interceptor.in ()
00144 ACE_ENV_ARG_PARAMETER);
00145 ACE_CHECK;
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 obj = info->resolve_initial_references ("SecurityLevel3:SecurityManager"
00182 ACE_ENV_ARG_PARAMETER);
00183 ACE_CHECK;
00184
00185 SecurityLevel3::SecurityManager_var manager =
00186 SecurityLevel3::SecurityManager::_narrow (obj.in ()
00187 ACE_ENV_ARG_PARAMETER);
00188 ACE_CHECK;
00189
00190 SecurityLevel3::CredentialsCurator_var curator =
00191 manager->credentials_curator (ACE_ENV_SINGLE_ARG_PARAMETER);
00192 ACE_CHECK;
00193
00194 TAO::SL3::CredentialsCurator_var tao_curator =
00195 TAO::SL3::CredentialsCurator::_narrow (curator.in ()
00196 ACE_ENV_ARG_PARAMETER);
00197 ACE_CHECK;
00198
00199 TAO::SSLIOP::CredentialsAcquirerFactory * factory;
00200 ACE_NEW_THROW_EX (factory,
00201 TAO::SSLIOP::CredentialsAcquirerFactory,
00202 CORBA::NO_MEMORY ());
00203 ACE_CHECK;
00204
00205 auto_ptr<TAO::SSLIOP::CredentialsAcquirerFactory> safe_factory;
00206
00207 tao_curator->register_acquirer_factory ("SL3TLS",
00208 factory
00209 ACE_ENV_ARG_PARAMETER);
00210 ACE_CHECK;
00211
00212 (void) safe_factory.release ();
00213
00214 }
00215
00216 size_t
00217 TAO::SSLIOP::ORBInitializer::get_tss_slot_id (
00218 PortableInterceptor::ORBInitInfo_ptr info
00219 ACE_ENV_ARG_DECL)
00220 {
00221
00222
00223 CORBA::Object_var obj =
00224 info->resolve_initial_references ("SecurityLevel3:SecurityCurrent"
00225 ACE_ENV_ARG_PARAMETER);
00226 ACE_CHECK_RETURN (0);
00227
00228 SecurityLevel3::SecurityCurrent_var current =
00229 SecurityLevel3::SecurityCurrent::_narrow (obj.in ()
00230 ACE_ENV_ARG_PARAMETER);
00231 ACE_CHECK_RETURN (0);
00232
00233 TAO::SL3::SecurityCurrent * security_current =
00234 dynamic_cast<TAO::SL3::SecurityCurrent *> (current.in ());
00235
00236 if (security_current == 0)
00237 {
00238 ACE_DEBUG ((LM_DEBUG,
00239 "Unable to obtain TSS slot ID from "
00240 "\"SecurityCurrent\" object.\n"));
00241
00242 ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
00243 }
00244
00245 return security_current->tss_slot ();
00246 }
00247
00248 TAO_END_VERSIONED_NAMESPACE_DECL