OpenDDS  Snapshot(2023/04/28-20:55)
SecurityConfig.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 "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
9 #include "SecurityConfig.h"
10 
11 #include "Properties.h"
12 
13 #include <cstring>
14 
16 
17 namespace OpenDDS {
18 namespace Security {
19 
21 #ifdef OPENDDS_SECURITY
22  Authentication_var authentication_plugin,
23  AccessControl_var access_ctrl_plugin,
24  CryptoKeyExchange_var key_exchange_plugin,
25  CryptoKeyFactory_var key_factory_plugin,
26  CryptoTransform_var transform_plugin,
27  DCPS::RcHandle<Utility> utility_plugin,
28 #endif
29  const ConfigPropertyList& properties)
30  : name_(name)
31 #ifdef OPENDDS_SECURITY
32  , authentication_plugin_(authentication_plugin)
33  , access_control_plugin_(access_ctrl_plugin)
34  , key_exchange_plugin_(key_exchange_plugin)
35  , key_factory_plugin_(key_factory_plugin)
36  , transform_plugin_(transform_plugin)
37  , utility_plugin_(utility_plugin)
38 #endif
39  , properties_(properties)
40 {}
41 
43 {
44 #ifdef OPENDDS_SECURITY
45  if (DCPS::security_debug.bookkeeping) {
46  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) {bookkeeping} ")
47  ACE_TEXT("SecurityConfig::~SecurityConfig handle_registry_map_ %B\n"),
48  handle_registry_map_.size()));
49  }
50 #endif
51 }
52 
54 {
55  // The names on the internal attributes of the PropertyQosPolicy are
56  // strange, but value is a properties sequence
57 
58  // Allocate space and copy over the properties
59  // Presumably this will not be truncating the property count
60  out_properties.value.length(static_cast<CORBA::ULong>(properties_.size()));
61  CORBA::ULong index = 0;
62  for (ConfigPropertyList::const_iterator iProp = properties_.begin();
63  iProp != properties_.end();
64  ++iProp) {
65  DDS::Property_t& out_prop = out_properties.value[index++];
66  out_prop.name = iProp->first.c_str();
67  out_prop.value = iProp->second.c_str();
68  }
69 }
70 
72  const DDS::PropertySeq& properties = qos.property.value;
73  for (unsigned int idx = 0; idx != properties.length(); ++idx) {
74  const char* name = properties[idx].name.in();
75  if (std::strcmp(DDS::Security::Properties::AuthIdentityCA, name) == 0 ||
77  std::strcmp(DDS::Security::Properties::AuthPrivateKey, name) == 0 ||
78  std::strcmp(DDS::Security::Properties::AccessPermissionsCA, name) == 0 ||
79  std::strcmp(DDS::Security::Properties::AccessGovernance, name) == 0 ||
80  std::strcmp(DDS::Security::Properties::AccessPermissions, name) == 0) {
81  return true;
82  }
83  }
84  return false;
85 }
86 
87 }
88 }
89 
#define ACE_DEBUG(X)
const char AuthIdentityCA[]
Definition: Properties.h:20
const char AuthPrivateKey[]
Definition: Properties.h:23
HandleRegistryMap handle_registry_map_
#define OPENDDS_STRING
LM_DEBUG
ACE_CDR::ULong ULong
const char AccessGovernance[]
Definition: Properties.h:17
SecurityConfig(const OPENDDS_STRING &name, Authentication_var authentication_plugin, AccessControl_var access_ctrl_plugin, CryptoKeyExchange_var key_exchange_plugin, CryptoKeyFactory_var key_factory_plugin, CryptoTransform_var transform_plugin, DCPS::RcHandle< Utility > utility_plugin, const ConfigPropertyList &properties)
void get_properties(DDS::PropertyQosPolicy &properties) const
const char AccessPermissionsCA[]
Definition: Properties.h:19
bool qos_implies_security(const DDS::DomainParticipantQos &qos) const
DDS::PropertySeq PropertySeq
Definition: RtpsCore.idl:49
const char *const name
Definition: debug.cpp:60
ACE_TEXT("TCP_Factory")
const char AuthIdentityCertificate[]
Definition: Properties.h:21
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
const char AccessPermissions[]
Definition: Properties.h:18
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
OpenDDS_Dcps_Export SecurityDebug security_debug
Definition: debug.cpp:32
PropertyQosPolicy property
OPENDDS_STRING name() const