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            "$Id: SSLIOP_Current.cpp 78308 2007-05-11 14:30:45Z johnnyw $")
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 {
00029   TAO::SSLIOP::Current_Impl *impl = this->implementation ();
00030 
00031   // If the implementation pointer returned from TSS is zero, then
00032   // we're not in the middle of a request or an upcall.  Throw an
00033   // exception to indicate that.
00034   if (impl == 0)
00035     throw ::SSLIOP::Current::NoContext ();
00036 
00037   // A valid value must always be returned, so instantiate a sequence
00038   // regardless of whether or not it is populated with certificates.
00039   ::SSLIOP::ASN_1_Cert *c = 0;
00040   ACE_NEW_THROW_EX (c,
00041                     ::SSLIOP::ASN_1_Cert,
00042                     CORBA::NO_MEMORY (
00043                       CORBA::SystemException::_tao_minor_code (
00044                         TAO::VMCID,
00045                         ENOMEM),
00046                       CORBA::COMPLETED_NO));
00047 
00048   ::SSLIOP::ASN_1_Cert_var certificate = c;
00049 
00050   // Populate the sequence with the DER encoded certificate.
00051   impl->get_peer_certificate (c);
00052 
00053   return certificate._retn ();
00054 }
00055 
00056 SSLIOP::SSL_Cert *
00057 TAO::SSLIOP::Current::get_peer_certificate_chain ()
00058 {
00059   TAO::SSLIOP::Current_Impl *impl = this->implementation ();
00060 
00061   // If the implementation pointer returned from TSS is zero, then
00062   // we're not in the middle of a request or an upcall.  Throw an
00063   // exception to indicate that.
00064   if (impl == 0)
00065     throw SSLIOP::Current::NoContext ();
00066 
00067   // A valid value must always be returned, so instantiate a sequence
00068   // regardless of whether or not it is populated with certificates.
00069   ::SSLIOP::SSL_Cert *c = 0;
00070   ACE_NEW_THROW_EX (c,
00071                     ::SSLIOP::SSL_Cert,
00072                     CORBA::NO_MEMORY (
00073                       CORBA::SystemException::_tao_minor_code (
00074                         TAO::VMCID,
00075                         ENOMEM),
00076                       CORBA::COMPLETED_NO));
00077 
00078   ::SSLIOP::SSL_Cert_var cert_chain = c;
00079 
00080   // Populate the sequence with the chain of DER encoded certificates.
00081   impl->get_peer_certificate_chain (c);
00082 
00083   return cert_chain._retn ();
00084 }
00085 
00086 CORBA::Boolean
00087 TAO::SSLIOP::Current::no_context (void)
00088 {
00089   return (this->implementation () == 0 ? true : false);
00090 }
00091 
00092 void
00093 TAO::SSLIOP::Current::setup (TAO::SSLIOP::Current_Impl *&prev_impl,
00094                              TAO::SSLIOP::Current_Impl *new_impl,
00095                              bool &setup_done)
00096 {
00097   // Set the current context and remember the old one.
00098 
00099   prev_impl = this->implementation ();
00100 
00101   (void) this->implementation (new_impl);  // Check for error?
00102 
00103   // Setup is complete.
00104   setup_done = true;
00105 }
00106 
00107 void
00108 TAO::SSLIOP::Current::teardown (TAO::SSLIOP::Current_Impl *prev_impl,
00109                                 bool &setup_done)
00110 {
00111   if (setup_done)
00112     {
00113       // Reset the old context.
00114       (void) this->implementation (prev_impl);
00115       setup_done = false;
00116     }
00117 }
00118 
00119 TAO::SSLIOP::Current_ptr
00120 TAO::SSLIOP::Current::_narrow (CORBA::Object_ptr obj)
00121 {
00122   return  TAO::SSLIOP::Current::_duplicate (
00123               dynamic_cast<TAO::SSLIOP::Current *> (obj));
00124 }
00125 
00126 TAO::SSLIOP::Current_ptr
00127 TAO::SSLIOP::Current::_duplicate (TAO::SSLIOP::Current_ptr obj)
00128 {
00129   if (!CORBA::is_nil (obj))
00130     obj->_add_ref ();
00131 
00132   return obj;
00133 }
00134 
00135 const char *
00136 TAO::SSLIOP::Current::_interface_repository_id (void) const
00137 {
00138   return "IDL:TAO/SSLIOP/Current:1.0";
00139 }
00140 
00141 // ----------------------------------------------------------------
00142 
00143 TAO::SSLIOP::Current_ptr
00144 tao_TAO_SSLIOP_Current_duplicate (TAO::SSLIOP::Current_ptr p)
00145 {
00146   return TAO::SSLIOP::Current::_duplicate (p);
00147 }
00148 
00149 void
00150 tao_TAO_SSLIOP_Current_release (TAO::SSLIOP::Current_ptr p)
00151 {
00152   CORBA::release (p);
00153 }
00154 
00155 TAO::SSLIOP::Current_ptr
00156 tao_TAO_SSLIOP_Current_nil (void)
00157 {
00158   return TAO::SSLIOP::Current::_nil ();
00159 }
00160 
00161 TAO::SSLIOP::Current_ptr
00162 tao_TAO_SSLIOP_Current_narrow (CORBA::Object *p)
00163 {
00164   return TAO::SSLIOP::Current::_narrow (p);
00165 }
00166 
00167 CORBA::Object *
00168 tao_TAO_SSLIOP_Current_upcast (void *src)
00169 {
00170   TAO::SSLIOP::Current **tmp =
00171     static_cast<TAO::SSLIOP::Current **> (src);
00172   return *tmp;
00173 }
00174 
00175 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 16:12:24 2008 for TAO_SSLIOP by doxygen 1.3.6