OpenDDS  Snapshot(2023/04/28-20:55)
TokenReader.cpp
Go to the documentation of this file.
1 /*
2 *
3 *
4 * Distributed under the OpenDDS License.
5 * See: http://www.OpenDDS.org/license.html
6 */
7 
8 #include "TokenReader.h"
10 #include <algorithm>
11 
13 using namespace OpenDDS::DCPS;
14 
15 namespace OpenDDS {
16 namespace Security {
17 
18 template<typename PropType>
20 {
21  has_property(const std::string& name) : name_(name) {}
22 
23  bool operator() (const PropType& property)
24  {
25  return (0 == name_.compare(property.name));
26  }
27 
28 private:
29  const std::string& name_;
30 };
31 
32 TokenReader::TokenReader(const DDS::Security::Token& token_ref)
33 : token_ref_(token_ref)
34 , _empty_seq_()
35 {
36 }
37 
39 {
40 }
41 
42 const char* TokenReader::get_property_value(const std::string& property_name) const
43 {
46 
49 
50  iter_t result = std::find_if(begin, end, has_property(property_name));
51 
52  if (result != end) {
53  return result->value;
54  }
55 
56  return 0;
57 }
58 
59 const DDS::OctetSeq& TokenReader::get_bin_property_value(const std::string& property_name) const
60 {
63 
66 
67  iter_t result = std::find_if(begin, end, has_property(property_name));
68 
69  if (result != end) {
70  return result->value;
71  }
72 
73  return _empty_seq_;
74 }
75 
76 } // namespace Security
77 } // namespace OpenDDS
78 
BinaryPropertySeq binary_properties
const DDS::Security::Token & token_ref_
Definition: TokenReader.h:54
const DDS::OctetSeq _empty_seq_
Definition: TokenReader.h:55
ConstSequenceIterator< Sequence > const_sequence_begin(Sequence &seq)
sequence< octet > OctetSeq
Definition: DdsDcpsCore.idl:64
const char * get_property_value(const std::string &property_name) const
Definition: TokenReader.cpp:42
has_property(const std::string &name)
Definition: TokenReader.cpp:21
const char *const name
Definition: debug.cpp:60
const DDS::OctetSeq & get_bin_property_value(const std::string &property_name) const
Definition: TokenReader.cpp:59
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
ConstSequenceIterator< Sequence > const_sequence_end(Sequence &seq)