SSLIOP_Invocation_Interceptor.cpp

Go to the documentation of this file.
00001 #include "orbsvcs/SSLIOP/SSLIOP_Invocation_Interceptor.h"
00002 #include "orbsvcs/SSLIOP/SSLIOP_Current.h"
00003 
00004 #include "orbsvcs/SecurityLevel2C.h"
00005 
00006 #include "tao/ORB_Constants.h"
00007 #include "tao/PortableServer/PS_CurrentC.h"
00008 #include "tao/PortableServer/POAC.h"
00009 #include "tao/debug.h"
00010 
00011 #if defined (SSLIOP_DEBUG_PEER_CERTIFICATE)
00012 #include <openssl/x509.h>   // @@ For debugging code below
00013 #endif /* SSLIOP_DEBUG_PEER_CERTIFICATE */
00014 
00015 ACE_RCSID (SSLIOP,
00016            SSLIOP_Invocation_Interceptor,
00017            "$Id: SSLIOP_Invocation_Interceptor.cpp 80431 2008-01-15 19:06:41Z johnnyw $")
00018 
00019 
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 TAO::SSLIOP::Server_Invocation_Interceptor::Server_Invocation_Interceptor
00023 (
00024   PortableInterceptor::ORBInitInfo_ptr info,
00025   ::Security::QOP default_qop,
00026   size_t tss_slot
00027 )
00028 : qop_ (default_qop)
00029 {
00030   /*
00031    * Cache references to the "Current" objects that we'll need during
00032    * during invocations.
00033    */
00034 
00035   CORBA::Object_var obj =
00036     info->resolve_initial_references ("SSLIOPCurrent");
00037 
00038   this->ssliop_current_ = ::SSLIOP::Current::_narrow (obj.in ());
00039 
00040   if (!CORBA::is_nil (this->ssliop_current_.in ()))
00041     {
00042       TAO::SSLIOP::Current *tao_current =
00043         dynamic_cast<TAO::SSLIOP::Current *> (this->ssliop_current_.in ());
00044 
00045       if (tao_current != 0)
00046         {
00047           if (TAO_debug_level > 3)
00048             ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) SSLIOP_Invocation_Interceptor::CTOR--setting up SSLIOP Current with slot %d\n", tss_slot));
00049           tao_current->tss_slot (tss_slot);
00050         }
00051       else
00052         throw CORBA::INTERNAL ();
00053     }
00054 
00055   obj = info->resolve_initial_references ("SecurityLevel2:SecurityManager");
00056   this->sec2manager_ = SecurityLevel2::SecurityManager::_narrow (obj.in ());
00057 
00058   if (! CORBA::is_nil (this->sec2manager_.in ()))
00059     {
00060       // set the slot id?  things seem to work without doing this
00061     }
00062 
00063 #if 0
00064   // Don't need this now that we're not using access_allowed(), but
00065   // I'm leaving the code here just in case it would become convenient
00066   // for some other use.
00067   obj = info->resolve_initial_references ("POACurrent");
00068   this->poa_current_ = PortableServer::Current::_narrow (obj.in ());
00069 #endif
00070 }
00071 
00072 TAO::SSLIOP::Server_Invocation_Interceptor::~Server_Invocation_Interceptor (
00073   void)
00074 {
00075 }
00076 
00077 char *
00078 TAO::SSLIOP::Server_Invocation_Interceptor::name ()
00079 {
00080   return CORBA::string_dup ("TAO::SSLIOP::Server_Invocation_Interceptor");
00081 }
00082 
00083 void
00084 TAO::SSLIOP::Server_Invocation_Interceptor::destroy ()
00085 {
00086 }
00087 
00088 void
00089 TAO::SSLIOP::Server_Invocation_Interceptor::receive_request_service_contexts (
00090                                               PortableInterceptor::ServerRequestInfo_ptr /*ri*/)
00091 {
00092 }
00093 
00094 
00095 void
00096 TAO::SSLIOP::Server_Invocation_Interceptor::receive_request (
00097     PortableInterceptor::ServerRequestInfo_ptr ri )
00098 {
00099   SecurityLevel2::AccessDecision_var ad_tmp =
00100     this->sec2manager_->access_decision ();
00101   TAO::SL2::AccessDecision_var ad =
00102     TAO::SL2::AccessDecision::_narrow (ad_tmp.in ());
00103 
00104   CORBA::Boolean const no_ssl =
00105     this->ssliop_current_->no_context ();
00106 
00107   if (TAO_debug_level >= 3)
00108     ACE_DEBUG ((LM_DEBUG, "SSLIOP (%P|%t) Interceptor (context), ssl=%d\n", !(no_ssl)));
00109 
00110   // if
00111   // (1) no SSL session state is available (which means that the
00112   //     invocation is received across a non-SSL transport)
00113   // AND
00114   // (2) the required Quality of Protection is something other
00115   //     than SecQOPNoProtection (set via -SSLNoProtection)
00116   if (no_ssl && this->qop_ != ::Security::SecQOPNoProtection)
00117     {
00118       /*
00119        * Set up all the arguments needed by the call
00120        * to AccessDecision::access_allowed()
00121        */
00122 
00123       /* Get the credentials from SSLIOP */
00124       SecurityLevel2::CredentialsList cred_list; // initial empty?
00125 #if 0
00126       try {
00127         SecurityLevel2::ReceivedCredentials_var rcvd_creds =
00128           this->sec2_current_->received_credentials ();
00129         // this gets the credentials received from the other side.  We
00130         // should be able to put this into a CredentialsList with no
00131         // problem.
00132         //
00133         // Do I really need to implement a sec2_current, or can I hack
00134         // the conversion at this level?  I probably ought to do it as
00135         // a real sec2_current with the conversion from sec3->sec2
00136         // happening at a lower level.
00137 
00138     cred_list.length(1);
00139     cred_list[0] = rcvd_creds.in ();
00140     /*
00141       So, in looking for how we can do this, I find that the
00142       SL3_SecurityCurrent::client_credentials() delegates to SL3_SecurityCurrent_Impl::client_credentials(), which is pure virtual.
00143     */
00144       }
00145       catch (...) {
00146       }
00147 #endif
00148 
00149       /* Gather the elements that uniquely identify the target object */
00150       CORBA::ORBid_var orb_id = ri->orb_id ();
00151       CORBA::OctetSeq_var adapter_id = ri->adapter_id ();
00152       CORBA::OctetSeq_var object_id = ri->object_id ();
00153       CORBA::String_var operation_name = ri->operation ();
00154 
00155       CORBA::Boolean it_should_happen = false;
00156       it_should_happen = ad->access_allowed_ex (orb_id.in (),
00157                         adapter_id.in (),
00158                         object_id.in (),
00159                         cred_list,
00160                         operation_name.in());
00161       if (TAO_debug_level >= 3)
00162         {
00163           ACE_DEBUG ((LM_DEBUG,
00164             "TAO (%P|%t) SL2::access_allowed_ex returned %s\n",
00165             it_should_happen ? "true" : "false"));
00166         }
00167 
00168       if (! it_should_happen)
00169         throw CORBA::NO_PERMISSION ();
00170     }
00171 }
00172 
00173 void
00174 TAO::SSLIOP::Server_Invocation_Interceptor::send_reply (
00175     PortableInterceptor::ServerRequestInfo_ptr /* ri */)
00176 {
00177 }
00178 
00179 void
00180 TAO::SSLIOP::Server_Invocation_Interceptor::send_exception (
00181     PortableInterceptor::ServerRequestInfo_ptr /* ri */)
00182 {
00183 }
00184 
00185 void
00186 TAO::SSLIOP::Server_Invocation_Interceptor::send_other (
00187     PortableInterceptor::ServerRequestInfo_ptr /* ri */)
00188 {
00189 }
00190 
00191 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:48:44 2010 for TAO_SSLIOP by  doxygen 1.4.7