SSLIOP_Current.cpp

Go to the documentation of this file.
00001 #include "orbsvcs/SSLIOP/SSLIOP_Current.h"
00002 #include "tao/debug.h"
00003 
00004 
00005 ACE_RCSID (SSLIOP,
00006            SSLIOP_Current,
00007            "SSLIOP_Current.cpp,v 1.19 2006/03/14 06:14:35 jtc Exp")
00008 
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "orbsvcs/SSLIOP/SSLIOP_Current.inl"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 TAO::SSLIOP::Current::Current (TAO_ORB_Core *orb_core)
00017   : tss_slot_ (0),
00018     orb_core_ (orb_core)
00019 {
00020 }
00021 
00022 TAO::SSLIOP::Current::~Current (void)
00023 {
00024 }
00025 
00026 ::SSLIOP::ASN_1_Cert *
00027 TAO::SSLIOP::Current::get_peer_certificate (
00028     ACE_ENV_SINGLE_ARG_DECL)
00029   ACE_THROW_SPEC ((CORBA::SystemException,
00030                    SSLIOP::Current::NoContext))
00031 {
00032   TAO::SSLIOP::Current_Impl *impl = this->implementation ();
00033 
00034   // If the implementation pointer returned from TSS is zero, then
00035   // we're not in the middle of a request or an upcall.  Throw an
00036   // exception to indicate that.
00037   if (impl == 0)
00038     ACE_THROW_RETURN (::SSLIOP::Current::NoContext (), 0);
00039 
00040   // A valid value must always be returned, so instantiate a sequence
00041   // regardless of whether or not it is populated with certificates.
00042   ::SSLIOP::ASN_1_Cert *c = 0;
00043   ACE_NEW_THROW_EX (c,
00044                     ::SSLIOP::ASN_1_Cert,
00045                     CORBA::NO_MEMORY (
00046                       CORBA::SystemException::_tao_minor_code (
00047                         TAO::VMCID,
00048                         ENOMEM),
00049                       CORBA::COMPLETED_NO));
00050   ACE_CHECK_RETURN (0);
00051 
00052   ::SSLIOP::ASN_1_Cert_var certificate = c;
00053 
00054   // Populate the sequence with the DER encoded certificate.
00055   impl->get_peer_certificate (c);
00056 
00057   return certificate._retn ();
00058 }
00059 
00060 SSLIOP::SSL_Cert *
00061 TAO::SSLIOP::Current::get_peer_certificate_chain (
00062     ACE_ENV_SINGLE_ARG_DECL)
00063   ACE_THROW_SPEC ((CORBA::SystemException,
00064                    SSLIOP::Current::NoContext))
00065 {
00066   TAO::SSLIOP::Current_Impl *impl = this->implementation ();
00067 
00068   // If the implementation pointer returned from TSS is zero, then
00069   // we're not in the middle of a request or an upcall.  Throw an
00070   // exception to indicate that.
00071   if (impl == 0)
00072     ACE_THROW_RETURN (SSLIOP::Current::NoContext (), 0);
00073 
00074   // A valid value must always be returned, so instantiate a sequence
00075   // regardless of whether or not it is populated with certificates.
00076   ::SSLIOP::SSL_Cert *c = 0;
00077   ACE_NEW_THROW_EX (c,
00078                     ::SSLIOP::SSL_Cert,
00079                     CORBA::NO_MEMORY (
00080                       CORBA::SystemException::_tao_minor_code (
00081                         TAO::VMCID,
00082                         ENOMEM),
00083                       CORBA::COMPLETED_NO));
00084   ACE_CHECK_RETURN (0);
00085 
00086   ::SSLIOP::SSL_Cert_var cert_chain = c;
00087 
00088   // Populate the sequence with the chain of DER encoded certificates.
00089   impl->get_peer_certificate_chain (c);
00090 
00091   return cert_chain._retn ();
00092 }
00093 
00094 CORBA::Boolean
00095 TAO::SSLIOP::Current::no_context (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00096   ACE_THROW_SPEC ((CORBA::SystemException))
00097 {
00098   return (this->implementation () == 0 ? 1 : 0);
00099 }
00100 
00101 void
00102 TAO::SSLIOP::Current::setup (TAO::SSLIOP::Current_Impl *&prev_impl,
00103                              TAO::SSLIOP::Current_Impl *new_impl,
00104                              bool &setup_done)
00105 {
00106   // Set the current context and remember the old one.
00107 
00108   prev_impl = this->implementation ();
00109 
00110   (void) this->implementation (new_impl);  // Check for error?
00111 
00112   // Setup is complete.
00113   setup_done = true;
00114 }
00115 
00116 void
00117 TAO::SSLIOP::Current::teardown (TAO::SSLIOP::Current_Impl *prev_impl,
00118                                 bool &setup_done)
00119 {
00120   if (setup_done)
00121     {
00122       // Reset the old context.
00123       (void) this->implementation (prev_impl);
00124       setup_done = false;
00125     }
00126 }
00127 
00128 TAO::SSLIOP::Current_ptr
00129 TAO::SSLIOP::Current::_narrow (
00130   CORBA::Object_ptr obj
00131   ACE_ENV_ARG_DECL_NOT_USED)
00132 {
00133   return  TAO::SSLIOP::Current::_duplicate (
00134               dynamic_cast<TAO::SSLIOP::Current *> (obj));
00135 }
00136 
00137 TAO::SSLIOP::Current_ptr
00138 TAO::SSLIOP::Current::_duplicate (TAO::SSLIOP::Current_ptr obj)
00139 {
00140   if (!CORBA::is_nil (obj))
00141     obj->_add_ref ();
00142 
00143   return obj;
00144 }
00145 
00146 const char *
00147 TAO::SSLIOP::Current::_interface_repository_id (void) const
00148 {
00149   return "IDL:TAO/SSLIOP/Current:1.0";
00150 }
00151 
00152 // ----------------------------------------------------------------
00153 
00154 TAO::SSLIOP::Current_ptr
00155 tao_TAO_SSLIOP_Current_duplicate (
00156     TAO::SSLIOP::Current_ptr p
00157   )
00158 {
00159   return TAO::SSLIOP::Current::_duplicate (p);
00160 }
00161 
00162 void
00163 tao_TAO_SSLIOP_Current_release (
00164     TAO::SSLIOP::Current_ptr p
00165   )
00166 {
00167   CORBA::release (p);
00168 }
00169 
00170 TAO::SSLIOP::Current_ptr
00171 tao_TAO_SSLIOP_Current_nil (
00172     void
00173   )
00174 {
00175   return TAO::SSLIOP::Current::_nil ();
00176 }
00177 
00178 TAO::SSLIOP::Current_ptr
00179 tao_TAO_SSLIOP_Current_narrow (
00180     CORBA::Object *p
00181     ACE_ENV_ARG_DECL
00182   )
00183 {
00184   return TAO::SSLIOP::Current::_narrow (p ACE_ENV_ARG_PARAMETER);
00185 }
00186 
00187 CORBA::Object *
00188 tao_TAO_SSLIOP_Current_upcast (
00189     void *src
00190   )
00191 {
00192   TAO::SSLIOP::Current **tmp =
00193     static_cast<TAO::SSLIOP::Current **> (src);
00194   return *tmp;
00195 }
00196 
00197 TAO_END_VERSIONED_NAMESPACE_DECL

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