00001
00002
00003 #include "orbsvcs/Security/Security_ORBInitializer.h"
00004
00005 ACE_RCSID (Security,
00006 Security_ORBInitializer,
00007 "$Id: Security_ORBInitializer.cpp 79586 2007-09-06 09:25:00Z johnnyw $")
00008
00009
00010 #if 1
00011 #include "orbsvcs/Security/Security_Current.h"
00012 #include "orbsvcs/Security/SL2_SecurityManager.h"
00013 #endif
00014 #include "orbsvcs/Security/SL3_SecurityCurrent.h"
00015 #include "orbsvcs/Security/SL3_CredentialsCurator.h"
00016 #include "orbsvcs/Security/SL3_SecurityManager.h"
00017
00018 #include "orbsvcs/SecurityC.h"
00019
00020 #include "tao/PI/ORBInitInfo.h"
00021 #include "tao/ORB_Constants.h"
00022 #include "tao/debug.h"
00023
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026 void
00027 TAO::Security::ORBInitializer::pre_init (
00028 PortableInterceptor::ORBInitInfo_ptr info)
00029 {
00030
00031
00032 TAO_ORBInitInfo_var tao_info =
00033 TAO_ORBInitInfo::_narrow (info);
00034
00035 if (CORBA::is_nil (tao_info.in ()))
00036 {
00037 if (TAO_debug_level > 0)
00038 ACE_ERROR ((LM_ERROR,
00039 "(%P|%t) Security_ORBInitializer::pre_init:\n"
00040 "(%P|%t) Unable to narrow "
00041 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00042 "(%P|%t) \"TAO_ORBInitInfo_ptr.\"\n"));
00043
00044 throw CORBA::INTERNAL ();
00045 }
00046
00047
00048
00049 size_t tss_slot = tao_info->allocate_tss_slot_id (0 );
00050
00051 #if 1
00052
00053 #if 0 // why am I getting a BAD_OPERATION from no SSL context?!
00054 CORBA::String_var orb_id = info->orb_id ();
00055
00056
00057 SecurityLevel2::Current_ptr current = SecurityLevel2::Current::_nil ();
00058 ACE_NEW_THROW_EX (current,
00059 TAO_Security_Current (tss_slot, orb_id.in ()),
00060 CORBA::NO_MEMORY (
00061 CORBA::SystemException::_tao_minor_code (
00062 TAO::VMCID,
00063 ENOMEM),
00064 CORBA::COMPLETED_NO));
00065
00066 SecurityLevel2::Current_var security_current = current;
00067
00068
00069
00070 info->register_initial_reference ("SecurityCurrent",
00071 security_current.in ());
00072 #endif
00073
00074
00075
00076 SecurityLevel2::SecurityManager_ptr manager2;
00077 ACE_NEW_THROW_EX (manager2,
00078 TAO::Security::SecurityManager (),
00079 CORBA::NO_MEMORY (
00080 CORBA::SystemException::_tao_minor_code (
00081 TAO::VMCID,
00082 ENOMEM),
00083 CORBA::COMPLETED_NO));
00084
00085 SecurityLevel2::SecurityManager_var security_manager2 = manager2;
00086
00087
00088
00089 info->register_initial_reference ("SecurityLevel2:SecurityManager",
00090 security_manager2.in ());
00091
00092 #endif
00093
00094
00095
00096
00097
00098
00099
00100 SecurityLevel3::SecurityCurrent_ptr current3;
00101 ACE_NEW_THROW_EX (current3,
00102 TAO::SL3::SecurityCurrent (tss_slot,
00103 tao_info->orb_core ()),
00104 CORBA::NO_MEMORY (
00105 CORBA::SystemException::_tao_minor_code (
00106 TAO::VMCID,
00107 ENOMEM),
00108 CORBA::COMPLETED_NO));
00109
00110 SecurityLevel3::SecurityCurrent_var security_current3 = current3;
00111
00112
00113
00114 info->register_initial_reference ("SecurityLevel3:SecurityCurrent",
00115 security_current3.in ());
00116
00117
00118 SecurityLevel3::CredentialsCurator_ptr curator;
00119 ACE_NEW_THROW_EX (curator,
00120 TAO::SL3::CredentialsCurator,
00121 CORBA::NO_MEMORY (
00122 CORBA::SystemException::_tao_minor_code (
00123 TAO::VMCID,
00124 ENOMEM),
00125 CORBA::COMPLETED_NO));
00126
00127 SecurityLevel3::CredentialsCurator_var credentials_curator = curator;
00128
00129
00130
00131 info->register_initial_reference ("SecurityLevel3:CredentialsCurator",
00132 credentials_curator.in ());
00133
00134
00135 SecurityLevel3::SecurityManager_ptr manager3;
00136 ACE_NEW_THROW_EX (manager3,
00137 TAO::SL3::SecurityManager (credentials_curator.in ()),
00138 CORBA::NO_MEMORY (
00139 CORBA::SystemException::_tao_minor_code (
00140 TAO::VMCID,
00141 ENOMEM),
00142 CORBA::COMPLETED_NO));
00143
00144 SecurityLevel3::SecurityManager_var security_manager3 = manager3;
00145
00146
00147
00148 info->register_initial_reference ("SecurityLevel3:SecurityManager",
00149 security_manager3.in ());
00150 }
00151
00152 void
00153 TAO::Security::ORBInitializer::post_init (
00154 PortableInterceptor::ORBInitInfo_ptr info)
00155 {
00156 this->register_policy_factories (info);
00157 }
00158
00159 void
00160 TAO::Security::ORBInitializer::register_policy_factories (
00161 PortableInterceptor::ORBInitInfo_ptr info)
00162 {
00163
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
00176 this->policy_factory_ = policy_factory;
00177 }
00178
00179
00180
00181
00182
00183 CORBA::PolicyType type;
00184
00185 type = ::Security::SecQOPPolicy;
00186 info->register_policy_factory (type, this->policy_factory_.in ());
00187
00188 type = ::Security::SecMechanismsPolicy;
00189 info->register_policy_factory (type, this->policy_factory_.in ());
00190
00191 type = ::Security::SecInvocationCredentialsPolicy;
00192 info->register_policy_factory (type, this->policy_factory_.in ());
00193
00194 type = ::Security::SecFeaturePolicy;
00195 info->register_policy_factory (type, this->policy_factory_.in ());
00196
00197 type = ::Security::SecDelegationDirectivePolicy;
00198 info->register_policy_factory (type, this->policy_factory_.in ());
00199
00200 type = ::Security::SecEstablishTrustPolicy;
00201 info->register_policy_factory (type, this->policy_factory_.in ());
00202
00203 type = SecurityLevel3::ContextEstablishmentPolicyType;
00204 info->register_policy_factory (type, this->policy_factory_.in ());
00205
00206 type = SecurityLevel3::ObjectCredentialsPolicyType;
00207 info->register_policy_factory (type, this->policy_factory_.in ());
00208
00209
00210 }
00211
00212 TAO_END_VERSIONED_NAMESPACE_DECL