SSLIOP_Invocation_Interceptor.cpp

Go to the documentation of this file.
00001 #include "orbsvcs/SSLIOP/SSLIOP_Invocation_Interceptor.h"
00002 
00003 #include "orbsvcs/SecurityLevel2C.h"
00004 
00005 #include "tao/ORB_Constants.h"
00006 #include "tao/PortableServer/PS_CurrentC.h"
00007 #include "tao/debug.h"
00008 
00009 #if defined(SSLIOP_DEBUG_PEER_CERTIFICATE)
00010 #include <openssl/x509.h>   // @@ For debugging code below
00011 #endif /* DEBUG_PEER_CERTIFICATES */
00012 
00013 ACE_RCSID (SSLIOP,
00014            SSLIOP_Invocation_Interceptor,
00015            "SSLIOP_Invocation_Interceptor.cpp,v 1.14 2006/03/14 06:14:35 jtc Exp")
00016 
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 TAO::SSLIOP::Server_Invocation_Interceptor::Server_Invocation_Interceptor (
00021    ::SSLIOP::Current_ptr current,
00022    ::Security::QOP qop)
00023   : ssliop_current_ (::SSLIOP::Current::_duplicate (current)),
00024     qop_ (qop)
00025 {
00026 }
00027 
00028 TAO::SSLIOP::Server_Invocation_Interceptor::~Server_Invocation_Interceptor (
00029   void)
00030 {
00031 }
00032 
00033 char *
00034 TAO::SSLIOP::Server_Invocation_Interceptor::name (
00035     ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00036   ACE_THROW_SPEC ((CORBA::SystemException))
00037 {
00038   return CORBA::string_dup ("TAO::SSLIOP::Server_Invocation_Interceptor");
00039 }
00040 
00041 void
00042 TAO::SSLIOP::Server_Invocation_Interceptor::destroy (
00043     ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00044   ACE_THROW_SPEC ((CORBA::SystemException))
00045 {
00046 }
00047 
00048 
00049 void
00050 TAO::SSLIOP::Server_Invocation_Interceptor::receive_request_service_contexts (
00051                                               PortableInterceptor::ServerRequestInfo_ptr /*ri*/
00052     ACE_ENV_ARG_DECL)
00053   ACE_THROW_SPEC ((CORBA::SystemException,
00054                    PortableInterceptor::ForwardRequest))
00055 {
00056   // The current upcall is not being performed through an SSL
00057   // connection.  If server is configured to disallow insecure
00058   // invocations then throw a CORBA::NO_PERMISSION exception.
00059   // @@ TODO: Once the SecurityManager is implemented, query it
00060   //          for the current object's
00061   //          SecureInvocationPolicy of type
00062   //          SecTargetSecureInvocationPolicy so that we can
00063   //          accept or reject requests on a per-object basis
00064   //          instead on a per-endpoint basis.
00065   CORBA::Boolean const no_ssl =
00066     this->ssliop_current_->no_context (ACE_ENV_SINGLE_ARG_PARAMETER);
00067   ACE_CHECK;
00068 
00069   if (TAO_debug_level >= 3)
00070     ACE_DEBUG ((LM_DEBUG, "SSLIOP (%P|%t) Interceptor (context), ssl=%d\n", !(no_ssl)));
00071 
00072   if (no_ssl && this->qop_ != ::Security::SecQOPNoProtection)
00073     ACE_THROW (CORBA::NO_PERMISSION ());
00074 
00075 #if defined(DEBUG_PEER_CERTIFICATES)
00076   ACE_TRY
00077     {
00078       // If the request was not made through an SSL connection, then
00079       // this method will throw the SSLIOP::Current::NoContext
00080       // exception.  Otherwise, it will return a DER encoded X509
00081       // certificate.
00082       ::SSLIOP::ASN_1_Cert_var cert =
00083         this->ssliop_current_->get_peer_certificate (
00084           ACE_ENV_SINGLE_ARG_PARAMETER);
00085       ACE_TRY_CHECK;
00086 
00087       // @@ The following debugging code works but I don't think that
00088       //    we should include it since it dumps alot of information,
00089       //    i.e. prints two lines of information per request.
00090       if (TAO_debug_level > 1)
00091         {
00092           CORBA::Octet *der_cert = cert->get_buffer ();
00093 
00094           X509 *peer = ::d2i_X509 (0, &der_cert, cert->length ());
00095           if (peer != 0)
00096             {
00097               char buf[BUFSIZ] = { 0 };
00098 
00099               ::X509_NAME_oneline (::X509_get_subject_name (peer),
00100                                    buf,
00101                                    BUFSIZ);
00102 
00103               ACE_DEBUG ((LM_DEBUG,
00104                           "(%P|%t) Certificate subject: %s\n",
00105                           buf));
00106 
00107               ::X509_NAME_oneline (::X509_get_issuer_name (peer),
00108                                    buf,
00109                                    BUFSIZ);
00110 
00111               ACE_DEBUG ((LM_DEBUG,
00112                           "(%P|%t) Certificate issuer: %s\n",
00113                           buf));
00114 
00115 
00116               ::X509_free (peer);
00117             }
00118         }
00119     }
00120   ACE_CATCH (::SSLIOP::Current::NoContext, exc)
00121     {
00122       // The current upcall is not being performed through an SSL
00123       // connection.  If server is configured to disallow insecure
00124       // invocations then throw a CORBA::NO_PERMISSION exception.
00125       // @@ TODO: Once the SecurityManager is implemented, query it
00126       //          for the current object's
00127       //          SecureInvocationPolicy of type
00128       //          SecTargetSecureInvocationPolicy so that we can
00129       //          accept or reject requests on a per-object basis
00130       //          instead on a per-endpoint basis.
00131       if (this->qop_ != ::Security::SecQOPNoProtection)
00132         ACE_THROW (CORBA::NO_PERMISSION ());
00133     }
00134   ACE_ENDTRY;
00135   ACE_CHECK;
00136 #endif /* DEBUG_PEER_CERTIFICATES */
00137 }
00138 
00139 
00140 void
00141 TAO::SSLIOP::Server_Invocation_Interceptor::receive_request (
00142     PortableInterceptor::ServerRequestInfo_ptr /* ri */
00143     ACE_ENV_ARG_DECL_NOT_USED)
00144   ACE_THROW_SPEC ((CORBA::SystemException,
00145                    PortableInterceptor::ForwardRequest))
00146 {
00147 }
00148 
00149 void
00150 TAO::SSLIOP::Server_Invocation_Interceptor::send_reply (
00151     PortableInterceptor::ServerRequestInfo_ptr /* ri */
00152     ACE_ENV_ARG_DECL_NOT_USED)
00153   ACE_THROW_SPEC ((CORBA::SystemException))
00154 {
00155 }
00156 
00157 void
00158 TAO::SSLIOP::Server_Invocation_Interceptor::send_exception (
00159     PortableInterceptor::ServerRequestInfo_ptr /* ri */
00160     ACE_ENV_ARG_DECL_NOT_USED)
00161   ACE_THROW_SPEC ((CORBA::SystemException,
00162                    PortableInterceptor::ForwardRequest))
00163 {
00164 }
00165 
00166 void
00167 TAO::SSLIOP::Server_Invocation_Interceptor::send_other (
00168     PortableInterceptor::ServerRequestInfo_ptr /* ri */
00169     ACE_ENV_ARG_DECL_NOT_USED)
00170   ACE_THROW_SPEC ((CORBA::SystemException,
00171                    PortableInterceptor::ForwardRequest))
00172 {
00173 }
00174 
00175 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:54:14 2006 for TAO_SSLIOP by doxygen 1.3.6