OpenDDS  Snapshot(2023/04/28-20:55)
SecurityConfig.h
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 #ifndef OPENDDS_DCPS_SECURITY_FRAMEWORK_SECURITYCONFIG_H
9 #define OPENDDS_DCPS_SECURITY_FRAMEWORK_SECURITYCONFIG_H
10 
12 #ifdef OPENDDS_SECURITY
13 # include "HandleRegistry.h"
14 #endif
15 
16 #include <dds/DCPS/dcps_export.h>
17 
18 #include <dds/DCPS/debug.h>
19 #include <dds/DCPS/RcObject.h>
20 #include <dds/DCPS/GuidUtils.h>
21 #ifdef OPENDDS_SECURITY
23 #endif
24 
25 #ifdef OPENDDS_SECURITY
26 # include <dds/DdsSecurityCoreC.h>
27 #endif
28 #include <dds/DdsDcpsCoreC.h>
29 
30 #include <ace/config.h>
31 #if !defined (ACE_LACKS_PRAGMA_ONCE)
32 # pragma once
33 #endif
34 #include <ace/Synch_Traits.h>
35 #include <ace/Thread_Mutex.h>
36 
38 
39 namespace OpenDDS {
40 namespace Security {
41 
42 #ifdef OPENDDS_SECURITY
43 using DDS::Security::Authentication_var;
44 using DDS::Security::AccessControl_var;
45 using DDS::Security::CryptoKeyExchange_var;
46 using DDS::Security::CryptoKeyFactory_var;
47 using DDS::Security::CryptoTransform_var;
48 #endif
49 
51  public:
52 
54  {
55  return name_;
56  }
57 
58 #ifdef OPENDDS_SECURITY
59  // Get the plugins associated with this configuration
60  Authentication_var get_authentication() const
61  {
62  return authentication_plugin_;
63  }
64 
65  AccessControl_var get_access_control() const
66  {
67  return access_control_plugin_;
68  }
69 
70  CryptoKeyExchange_var get_crypto_key_exchange() const
71  {
72  return key_exchange_plugin_;
73  }
74 
75  CryptoKeyFactory_var get_crypto_key_factory() const
76  {
77  return key_factory_plugin_;
78  }
79 
80  CryptoTransform_var get_crypto_transform() const
81  {
82  return transform_plugin_;
83  }
84 
86  {
87  return utility_plugin_;
88  }
89 
91  {
92  HandleRegistry_rch handle_registry;
93 
94  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex_, handle_registry);
95 
96  HandleRegistryMap::const_iterator pos = handle_registry_map_.find(participant_id);
97  if (pos != handle_registry_map_.end()) {
98  handle_registry = pos->second;
99  } else {
100  handle_registry = DCPS::make_rch<HandleRegistry>();
101  handle_registry_map_[participant_id] = handle_registry;
102 
103  if (DCPS::security_debug.bookkeeping) {
104  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) {bookkeeping} ")
105  ACE_TEXT("SecurityConfig::get_handle_registry handle_registry_map_ (total %B)\n"),
106  handle_registry_map_.size()));
107  }
108  }
109 
110  return handle_registry;
111  }
112 
113  void erase_handle_registry(const DCPS::GUID_t& participant_id)
114  {
115  ACE_GUARD(ACE_Thread_Mutex, g, mutex_);
116  handle_registry_map_.erase(participant_id);
117 
118  if (DCPS::security_debug.bookkeeping) {
119  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) {bookkeeping} ")
120  ACE_TEXT("SecurityConfig::erase_handle_registry handle_registry_map_ (total %B)\n"),
121  handle_registry_map_.size()));
122  }
123  }
124 
125 #endif
126 
127  void get_properties(DDS::PropertyQosPolicy& properties) const;
128 
129  bool qos_implies_security(const DDS::DomainParticipantQos& qos) const;
130 
132 #ifdef OPENDDS_SECURITY
133  Authentication_var authentication_plugin,
134  AccessControl_var access_ctrl_plugin,
135  CryptoKeyExchange_var key_exchange_plugin,
136  CryptoKeyFactory_var key_factory_plugin,
137  CryptoTransform_var transform_plugin,
138  DCPS::RcHandle<Utility> utility_plugin,
139 #endif
140  const ConfigPropertyList& properties);
141 
142  private:
143  friend class SecurityRegistry;
144 
145  template <typename T, typename U>
146  friend DCPS::RcHandle<T> DCPS::make_rch(U const&);
147 
148  ~SecurityConfig();
149 
151 
152 #ifdef OPENDDS_SECURITY
153  Authentication_var authentication_plugin_;
154  AccessControl_var access_control_plugin_;
155  CryptoKeyExchange_var key_exchange_plugin_;
156  CryptoKeyFactory_var key_factory_plugin_;
157  CryptoTransform_var transform_plugin_;
160  HandleRegistryMap handle_registry_map_;
162 #endif
163 
164  ConfigPropertyList properties_;
165 };
166 
167 }
168 }
169 
171 
172 #endif /* OPENDDS_DCPS_SECURTIY_CONFIG_H */
DCPS::RcHandle< Utility > get_utility() const
#define ACE_DEBUG(X)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
RcHandle< T > make_rch()
Definition: RcHandle_T.h:256
CryptoKeyExchange_var key_exchange_plugin_
HandleRegistryMap handle_registry_map_
DCPS::RcHandle< Utility > utility_plugin_
#define OPENDDS_STRING
CryptoKeyFactory_var key_factory_plugin_
LM_DEBUG
CryptoTransform_var transform_plugin_
CryptoKeyExchange_var get_crypto_key_exchange() const
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
#define OPENDDS_MAP_CMP(K, V, C)
HandleRegistry_rch get_handle_registry(const DCPS::GUID_t &participant_id)
Authentication_var authentication_plugin_
AccessControl_var get_access_control() const
const char *const name
Definition: debug.cpp:60
CryptoTransform_var get_crypto_transform() const
ACE_TEXT("TCP_Factory")
Authentication_var get_authentication() const
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
CryptoKeyFactory_var get_crypto_key_factory() const
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
AccessControl_var access_control_plugin_
OpenDDS_Dcps_Export SecurityDebug security_debug
Definition: debug.cpp:32
OPENDDS_STRING name() const
void erase_handle_registry(const DCPS::GUID_t &participant_id)