blob: e40d3c5b07ca37cc318e6b698c2c3ea5ed666fe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// $Id$
#include "CSI_Utils.h"
#include "orbsvcs/orbsvcs/CSIC.h"
#include "tao/CDR.h"
#include "ace/OS_NS_string.h"
ACE_RCSID (Security,
CSI_Utils,
"$Id$")
void
TAO::CSI_Utils::create_sas_service_context (
const CSI::SASContextBody & sas_context,
IOP::ServiceContext & sc)
{
// Marshal CSI::SASContextBody union into an octet sequence suitable
// for placement in an IOP::ServiceContext.
// (TAO's compiled marshaling is used for performance reasons.)
TAO_OutputCDR cdr;
cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
cdr << sas_context;
sc.context_id = IOP::SecurityAttributeService;
// TAO extension, replace the contents of the octet sequence with
// the CDR stream.
const CORBA::ULong len = cdr.total_length ();
sc.context_data.length (len);
CORBA::Octet * buf = sc.context_data.get_buffer ();
for (const ACE_Message_Block * i = cdr.begin ();
i != 0;
i = i->cont ())
{
ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
buf += i->length ();
}
}
bool
TAO::CSI_Utils::extract_sas_service_context (
const IOP::ServiceContext & sc,
CSI::SASContextBody & sas_context)
{
// Demarshal CSI::SASContextBody union from ServiceContext.
// (TAO's compiled marshaling is used for performance reasons.)
TAO_InputCDR cdr (reinterpret_cast<const char*> (
sc.context_data.get_buffer ()),
sc.context_data.length ());
CORBA::Boolean byte_order;
if (!(cdr >> ACE_InputCDR::to_boolean (byte_order)))
return false;
cdr.reset_byte_order (static_cast<int> (byte_order));
if (!(cdr >> sas_context))
return false;
return true;
}
|