Security_ORBInitializer.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #include "orbsvcs/Security/Security_ORBInitializer.h"
00004 
00005 ACE_RCSID (Security,
00006            Security_ORBInitializer,
00007            "Security_ORBInitializer.cpp,v 1.18 2006/03/14 06:14:35 jtc Exp")
00008 
00009 
00010 // #include "Security_Current.h"
00011 #include "orbsvcs/Security/SL3_SecurityCurrent.h"
00012 #include "orbsvcs/Security/SL3_CredentialsCurator.h"
00013 #include "orbsvcs/Security/SL3_SecurityManager.h"
00014 
00015 #include "orbsvcs/SecurityC.h"
00016 
00017 #include "tao/PI/ORBInitInfo.h"
00018 #include "tao/ORB_Constants.h"
00019 #include "tao/debug.h"
00020 
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022 
00023 void
00024 TAO::Security::ORBInitializer::pre_init (
00025     PortableInterceptor::ORBInitInfo_ptr info
00026     ACE_ENV_ARG_DECL)
00027   ACE_THROW_SPEC ((CORBA::SystemException))
00028 {
00029   // Narrow to a TAO_ORBInitInfo object to get access to the
00030   // allocate_tss_slot_id() TAO extension.
00031   TAO_ORBInitInfo_var tao_info =
00032     TAO_ORBInitInfo::_narrow (info
00033                               ACE_ENV_ARG_PARAMETER);
00034   ACE_CHECK;
00035 
00036   if (CORBA::is_nil (tao_info.in ()))
00037     {
00038       if (TAO_debug_level > 0)
00039         ACE_ERROR ((LM_ERROR,
00040                     "(%P|%t) Security_ORBInitializer::pre_init:\n"
00041                     "(%P|%t)    Unable to narrow "
00042                     "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00043                     "(%P|%t)   \"TAO_ORBInitInfo_ptr.\"\n"));
00044 
00045       ACE_THROW (CORBA::INTERNAL ());
00046     }
00047 
00048 //   // Reserve a TSS slot in the ORB core internal TSS resources for the
00049 //   // thread-specific portion of Security::Current.
00050 //   size_t old_tss_slot = tao_info->allocate_tss_slot_id (0
00051 //                                                         ACE_ENV_ARG_PARAMETER);
00052 //   ACE_CHECK;
00053 
00054 //   CORBA::String_var orb_id = info->orb_id (ACE_ENV_SINGLE_ARG_PARAMETER);
00055 //   ACE_CHECK;
00056 
00057 //   // Create the SecurityLevel2::Current object.
00058 //   SecurityLevel2::Current_ptr current = SecurityLevel2::Current::_nil ();
00059 //   ACE_NEW_THROW_EX (current,
00060 //                     TAO_Security_Current (old_tss_slot, orb_id.in ()),
00061 //                     CORBA::NO_MEMORY (
00062 //                       CORBA::SystemException::_tao_minor_code (
00063 //                         TAO::VMCID,
00064 //                         ENOMEM),
00065 //                       CORBA::COMPLETED_NO));
00066 //   ACE_CHECK;
00067 
00068 //   SecurityLevel2::Current_var security_current = current;
00069 
00070 //   // Register the SecurityLevel2::Current object reference with the
00071 //   // ORB.
00072 //   info->register_initial_reference ("SecurityCurrent",
00073 //                                     security_current.in ()
00074 //                                     ACE_ENV_ARG_PARAMETER);
00075 //   ACE_CHECK;
00076 
00077   // Reserve a TSS slot in the ORB core internal TSS resources for the
00078   // thread-specific portion of SecurityLevel3::SecurityCurrent
00079   // object.
00080   size_t tss_slot = tao_info->allocate_tss_slot_id (0
00081                                                     ACE_ENV_ARG_PARAMETER);
00082   ACE_CHECK;
00083 
00084 
00085   // Create the SecurityLevel3::Current object.
00086   SecurityLevel3::SecurityCurrent_ptr current3;
00087   ACE_NEW_THROW_EX (current3,
00088                     TAO::SL3::SecurityCurrent (tss_slot,
00089                                                tao_info->orb_core ()),
00090                     CORBA::NO_MEMORY (
00091                       CORBA::SystemException::_tao_minor_code (
00092                         TAO::VMCID,
00093                         ENOMEM),
00094                       CORBA::COMPLETED_NO));
00095   ACE_CHECK;
00096 
00097   SecurityLevel3::SecurityCurrent_var security_current3 = current3;
00098 
00099   // Register the SecurityLevel2::Current object reference with the
00100   // ORB.
00101   info->register_initial_reference ("SecurityLevel3:SecurityCurrent",
00102                                     security_current3.in ()
00103                                     ACE_ENV_ARG_PARAMETER);
00104   ACE_CHECK;
00105 
00106   // Create the SecurityLevel3::CredentialsCurator object.
00107   SecurityLevel3::CredentialsCurator_ptr curator;
00108   ACE_NEW_THROW_EX (curator,
00109                     TAO::SL3::CredentialsCurator,
00110                     CORBA::NO_MEMORY (
00111                       CORBA::SystemException::_tao_minor_code (
00112                         TAO::VMCID,
00113                         ENOMEM),
00114                       CORBA::COMPLETED_NO));
00115   ACE_CHECK;
00116 
00117   SecurityLevel3::CredentialsCurator_var credentials_curator = curator;
00118 
00119   // Register the SecurityLevel3::CredentialsCurator object reference
00120   // with the ORB.
00121   info->register_initial_reference ("SecurityLevel3:CredentialsCurator",
00122                                     credentials_curator.in ()
00123                                     ACE_ENV_ARG_PARAMETER);
00124   ACE_CHECK;
00125 
00126   // Create the SecurityLevel3::SecurityManager object.
00127   SecurityLevel3::SecurityManager_ptr manager3;
00128   ACE_NEW_THROW_EX (manager3,
00129                     TAO::SL3::SecurityManager (credentials_curator.in ()),
00130                     CORBA::NO_MEMORY (
00131                       CORBA::SystemException::_tao_minor_code (
00132                         TAO::VMCID,
00133                         ENOMEM),
00134                       CORBA::COMPLETED_NO));
00135   ACE_CHECK;
00136 
00137   SecurityLevel3::SecurityManager_var security_manager3 = manager3;
00138 
00139   // Register the SecurityLevel3::SecurityManager object reference
00140   // with the ORB.
00141   info->register_initial_reference ("SecurityLevel3:SecurityManager",
00142                                     security_manager3.in ()
00143                                     ACE_ENV_ARG_PARAMETER);
00144   ACE_CHECK;
00145 }
00146 
00147 void
00148 TAO::Security::ORBInitializer::post_init (
00149     PortableInterceptor::ORBInitInfo_ptr info
00150     ACE_ENV_ARG_DECL)
00151   ACE_THROW_SPEC ((CORBA::SystemException))
00152 {
00153   this->register_policy_factories (info
00154                                    ACE_ENV_ARG_PARAMETER);
00155   ACE_CHECK;
00156 }
00157 
00158 void
00159 TAO::Security::ORBInitializer::register_policy_factories (
00160   PortableInterceptor::ORBInitInfo_ptr info
00161   ACE_ENV_ARG_DECL)
00162 {
00163   // Register the security policy factories.
00164 
00165   if (CORBA::is_nil (this->policy_factory_.in ()))
00166     {
00167       PortableInterceptor::PolicyFactory_ptr policy_factory;
00168       ACE_NEW_THROW_EX (policy_factory,
00169                         TAO::Security::PolicyFactory,
00170                           CORBA::NO_MEMORY (
00171                             CORBA::SystemException::_tao_minor_code (
00172                               TAO::VMCID,
00173                               ENOMEM),
00174                             CORBA::COMPLETED_NO));
00175       ACE_CHECK;
00176 
00177       this->policy_factory_ = policy_factory;
00178     }
00179 
00180   // Bind the same policy factory to all security related policy
00181   // types since a single policy factory is used to create each of
00182   // the different types of security policies.
00183 
00184   CORBA::PolicyType type;
00185 
00186   type = ::Security::SecQOPPolicy;
00187   info->register_policy_factory (type,
00188                                  this->policy_factory_.in ()
00189                                  ACE_ENV_ARG_PARAMETER);
00190   ACE_CHECK;
00191 
00192   type = ::Security::SecMechanismsPolicy;
00193   info->register_policy_factory (type,
00194                                  this->policy_factory_.in ()
00195                                  ACE_ENV_ARG_PARAMETER);
00196   ACE_CHECK;
00197 
00198   type = ::Security::SecInvocationCredentialsPolicy;
00199   info->register_policy_factory (type,
00200                                  this->policy_factory_.in ()
00201                                  ACE_ENV_ARG_PARAMETER);
00202   ACE_CHECK;
00203 
00204   type = ::Security::SecFeaturePolicy;   // Deprecated
00205   info->register_policy_factory (type,
00206                                  this->policy_factory_.in ()
00207                                  ACE_ENV_ARG_PARAMETER);
00208   ACE_CHECK;
00209 
00210   type = ::Security::SecDelegationDirectivePolicy;
00211   info->register_policy_factory (type,
00212                                  this->policy_factory_.in ()
00213                                  ACE_ENV_ARG_PARAMETER);
00214   ACE_CHECK;
00215 
00216   type = ::Security::SecEstablishTrustPolicy;
00217   info->register_policy_factory (type,
00218                                  this->policy_factory_.in ()
00219                                  ACE_ENV_ARG_PARAMETER);
00220   ACE_CHECK;
00221 
00222 
00223   type = SecurityLevel3::ContextEstablishmentPolicyType;
00224   info->register_policy_factory (type,
00225                                  this->policy_factory_.in ()
00226                                  ACE_ENV_ARG_PARAMETER);
00227   ACE_CHECK;
00228 
00229 
00230   type = SecurityLevel3::ObjectCredentialsPolicyType;
00231   info->register_policy_factory (type,
00232                                  this->policy_factory_.in ()
00233                                  ACE_ENV_ARG_PARAMETER);
00234   ACE_CHECK;
00235 
00236 
00237   // ----------------------------------------------------------------
00238 }
00239 
00240 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:50:47 2006 for TAO_Security by doxygen 1.3.6