TAO::CSI_Utils Namespace Reference


Functions

void create_sas_service_context (const CSI::SASContextBody &sas_context, IOP::ServiceContext &sc)
 Populate given IOP::ServiceContext with given CSI::SASContextBody.

bool extract_sas_service_context (const IOP::ServiceContext &sc, CSI::SASContextBody &sas_context)
 Extract CSI::SASContextBody from given IOP::ServiceContext.


Function Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL void TAO::CSI_Utils::create_sas_service_context const CSI::SASContextBody &  sas_context,
IOP::ServiceContext sc
 

Populate given IOP::ServiceContext with given CSI::SASContextBody.

Definition at line 18 of file CSI_Utils.cpp.

References ACE_OutputCDR::begin(), ACE_Message_Block::cont(), IOP::ServiceContext::context_data, IOP::ServiceContext::context_id, TAO::unbounded_value_sequence< T >::get_buffer(), ACE_Message_Block::length(), TAO::unbounded_value_sequence< T >::length(), ACE_OS::memcpy(), ACE_Message_Block::rd_ptr(), TAO_ENCAP_BYTE_ORDER, and ACE_OutputCDR::total_length().

00021 {
00022   // Marshal CSI::SASContextBody union into an octet sequence suitable
00023   // for placement in an IOP::ServiceContext.
00024   // (TAO's compiled marshaling is used for performance reasons.)
00025 
00026   TAO_OutputCDR cdr;
00027   cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
00028 
00029   cdr << sas_context;
00030 
00031   sc.context_id = IOP::SecurityAttributeService;
00032 
00033   // TAO extension, replace the contents of the octet sequence with
00034   // the CDR stream.
00035   const CORBA::ULong len = cdr.total_length ();
00036   sc.context_data.length (len);
00037   CORBA::Octet * buf = sc.context_data.get_buffer ();
00038   for (const ACE_Message_Block * i = cdr.begin ();
00039        i != 0;
00040        i = i->cont ())
00041     {
00042       ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
00043       buf += i->length ();
00044     }
00045 }

bool TAO::CSI_Utils::extract_sas_service_context const IOP::ServiceContext sc,
CSI::SASContextBody &  sas_context
 

Extract CSI::SASContextBody from given IOP::ServiceContext.

Returns:
Success == true, Failure == false.

Definition at line 48 of file CSI_Utils.cpp.

References IOP::ServiceContext::context_data, TAO::unbounded_value_sequence< T >::get_buffer(), TAO::unbounded_value_sequence< T >::length(), and ACE_InputCDR::reset_byte_order().

00051 {
00052   // Demarshal CSI::SASContextBody union from ServiceContext.
00053   // (TAO's compiled marshaling is used for performance reasons.)
00054 
00055   TAO_InputCDR cdr (reinterpret_cast<const char*> (
00056                       sc.context_data.get_buffer ()),
00057                     sc.context_data.length ());
00058 
00059   ACE_CDR::Boolean byte_order;
00060 
00061   if (!(cdr >> ACE_InputCDR::to_boolean (byte_order)))
00062     return false;
00063 
00064   cdr.reset_byte_order (static_cast<int> (byte_order));
00065 
00066   return (cdr >> sas_context);
00067 }


Generated on Thu Nov 9 13:52:27 2006 for TAO_Security by doxygen 1.3.6