OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Attributes | List of all members
OpenDDS::Security::TokenWriter Class Reference

Implements some simple wrapper functions to provide a non-const API around the Token data structure as specified in the DDS security specification. More...

#include <TokenWriter.h>

Collaboration diagram for OpenDDS::Security::TokenWriter:
Collaboration graph
[legend]

Public Member Functions

 TokenWriter (DDS::Security::Token &token_ref)
 
 TokenWriter (DDS::Security::Token &token_ref, const std::string &class_id)
 
virtual ~TokenWriter ()
 
const TokenReaderget_reader ()
 
void set_class_id (const std::string &class_name)
 
void add_property (const char *prop_name, const char *prop_value, bool propagate=true)
 
void add_property (const char *prop_name, const DDS::OctetSeq &prop_value, bool propagate=true)
 
void add_bin_property (const char *prop_name, const DDS::OctetSeq &prop_value, bool propagate=true)
 
void add_bin_property (const char *prop_name, const std::string &prop_value, bool propagate=true)
 

Private Attributes

DCPS::SequenceBackInsertIterator< DDS::BinaryPropertySeq > binary_property_inserter_
 
DCPS::SequenceBackInsertIterator< DDS::PropertySeqproperty_inserter_
 
DDS::Security::Tokentoken_ref_
 
OpenDDS::Security::TokenReader reader_
 

Detailed Description

Implements some simple wrapper functions to provide a non-const API around the Token data structure as specified in the DDS security specification.

See the DDS security specification, OMG formal/17-09-20, for a description of the interface this class is implementing.

Definition at line 43 of file TokenWriter.h.

Constructor & Destructor Documentation

◆ TokenWriter() [1/2]

OpenDDS::Security::TokenWriter::TokenWriter ( DDS::Security::Token token_ref)
explicit

Definition at line 16 of file TokenWriter.cpp.

18 , property_inserter_(token_ref.properties)
19 , token_ref_(token_ref)
20 , reader_(token_ref)
21 {
22 
23 }
BinaryPropertySeq binary_properties
DCPS::SequenceBackInsertIterator< DDS::BinaryPropertySeq > binary_property_inserter_
Definition: TokenWriter.h:61
DCPS::SequenceBackInsertIterator< DDS::PropertySeq > property_inserter_
Definition: TokenWriter.h:62
OpenDDS::Security::TokenReader reader_
Definition: TokenWriter.h:64
DDS::Security::Token & token_ref_
Definition: TokenWriter.h:63

◆ TokenWriter() [2/2]

OpenDDS::Security::TokenWriter::TokenWriter ( DDS::Security::Token token_ref,
const std::string &  class_id 
)

Definition at line 25 of file TokenWriter.cpp.

References DDS::Security::DataHolder::class_id.

27 , property_inserter_(token_ref.properties)
28 , token_ref_(token_ref)
29 , reader_(token_ref)
30 {
31  token_ref.class_id = class_id.c_str();
32 }
BinaryPropertySeq binary_properties
DCPS::SequenceBackInsertIterator< DDS::BinaryPropertySeq > binary_property_inserter_
Definition: TokenWriter.h:61
DCPS::SequenceBackInsertIterator< DDS::PropertySeq > property_inserter_
Definition: TokenWriter.h:62
OpenDDS::Security::TokenReader reader_
Definition: TokenWriter.h:64
DDS::Security::Token & token_ref_
Definition: TokenWriter.h:63

◆ ~TokenWriter()

OpenDDS::Security::TokenWriter::~TokenWriter ( )
virtual

Definition at line 34 of file TokenWriter.cpp.

35 {
36 }

Member Function Documentation

◆ add_bin_property() [1/2]

void OpenDDS::Security::TokenWriter::add_bin_property ( const char *  prop_name,
const DDS::OctetSeq prop_value,
bool  propagate = true 
)

◆ add_bin_property() [2/2]

void OpenDDS::Security::TokenWriter::add_bin_property ( const char *  prop_name,
const std::string &  prop_value,
bool  propagate = true 
)

Definition at line 68 of file TokenWriter.cpp.

References binary_property_inserter_, DDS::BinaryProperty_t::name, OPENDDS_END_VERSIONED_NAMESPACE_DECL, DDS::BinaryProperty_t::propagate, and DDS::BinaryProperty_t::value.

69 {
71  p.name = prop_name;
72  p.propagate = propagate;
73  p.value.length(static_cast<unsigned int>(prop_value.size() + 1 /* For null */));
74  std::memcpy(p.value.get_buffer(),
75  prop_value.c_str(),
76  p.value.length());
78 }
DCPS::SequenceBackInsertIterator< DDS::BinaryPropertySeq > binary_property_inserter_
Definition: TokenWriter.h:61

◆ add_property() [1/2]

void OpenDDS::Security::TokenWriter::add_property ( const char *  prop_name,
const char *  prop_value,
bool  propagate = true 
)

Definition at line 38 of file TokenWriter.cpp.

References DDS::Property_t::name, DDS::Property_t::propagate, property_inserter_, and DDS::Property_t::value.

Referenced by OpenDDS::Security::AuthenticationBuiltInImpl::get_identity_token(), and OpenDDS::Security::AccessControlBuiltInImpl::validate_local_permissions().

39 {
41  p.name = prop_name;
42  p.value = prop_value;
43  p.propagate = propagate;
44  *property_inserter_ = p;
45 }
DCPS::SequenceBackInsertIterator< DDS::PropertySeq > property_inserter_
Definition: TokenWriter.h:62

◆ add_property() [2/2]

void OpenDDS::Security::TokenWriter::add_property ( const char *  prop_name,
const DDS::OctetSeq prop_value,
bool  propagate = true 
)

Definition at line 47 of file TokenWriter.cpp.

References DDS::Property_t::name, DDS::Property_t::propagate, property_inserter_, and DDS::Property_t::value.

48 {
49  std::ostringstream out;
50  out.write(reinterpret_cast<const char*>(prop_value.get_buffer()), prop_value.length());
51 
53  p.name = prop_name;
54  p.value = out.str().c_str();
55  p.propagate = propagate;
56  *property_inserter_ = p;
57 }
DCPS::SequenceBackInsertIterator< DDS::PropertySeq > property_inserter_
Definition: TokenWriter.h:62

◆ get_reader()

const TokenReader & OpenDDS::Security::TokenWriter::get_reader ( )
inline

Definition at line 67 of file TokenWriter.h.

68 {
69  return reader_;
70 }
OpenDDS::Security::TokenReader reader_
Definition: TokenWriter.h:64

◆ set_class_id()

void OpenDDS::Security::TokenWriter::set_class_id ( const std::string &  class_name)
inline

Definition at line 72 of file TokenWriter.h.

References OPENDDS_END_VERSIONED_NAMESPACE_DECL.

73 {
74  token_ref_.class_id = class_id.c_str();
75 }
DDS::Security::Token & token_ref_
Definition: TokenWriter.h:63

Member Data Documentation

◆ binary_property_inserter_

DCPS::SequenceBackInsertIterator<DDS::BinaryPropertySeq> OpenDDS::Security::TokenWriter::binary_property_inserter_
private

Definition at line 61 of file TokenWriter.h.

Referenced by add_bin_property().

◆ property_inserter_

DCPS::SequenceBackInsertIterator<DDS::PropertySeq> OpenDDS::Security::TokenWriter::property_inserter_
private

Definition at line 62 of file TokenWriter.h.

Referenced by add_property().

◆ reader_

OpenDDS::Security::TokenReader OpenDDS::Security::TokenWriter::reader_
private

Definition at line 64 of file TokenWriter.h.

◆ token_ref_

DDS::Security::Token& OpenDDS::Security::TokenWriter::token_ref_
private

Definition at line 63 of file TokenWriter.h.


The documentation for this class was generated from the following files: