LCOV - code coverage report
Current view: top level - DCPS/security/framework - SecurityConfig.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 20 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 5 0.0 %

          Line data    Source code
       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             : 
      11             : #include "SecurityConfigPropertyList.h"
      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
      22             : #  include <dds/DCPS/security/Utility.h>
      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             : 
      37             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      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             : 
      50             : class OpenDDS_Dcps_Export SecurityConfig : public DCPS::RcObject {
      51             :  public:
      52             : 
      53             :   OPENDDS_STRING name() const
      54             :   {
      55             :     return name_;
      56             :   }
      57             : 
      58             : #ifdef OPENDDS_SECURITY
      59             :   // Get the plugins associated with this configuration
      60           0 :   Authentication_var get_authentication() const
      61             :   {
      62           0 :     return authentication_plugin_;
      63             :   }
      64             : 
      65           0 :   AccessControl_var get_access_control() const
      66             :   {
      67           0 :     return access_control_plugin_;
      68             :   }
      69             : 
      70             :   CryptoKeyExchange_var get_crypto_key_exchange() const
      71             :   {
      72             :     return key_exchange_plugin_;
      73             :   }
      74             : 
      75           0 :   CryptoKeyFactory_var get_crypto_key_factory() const
      76             :   {
      77           0 :     return key_factory_plugin_;
      78             :   }
      79             : 
      80           0 :   CryptoTransform_var get_crypto_transform() const
      81             :   {
      82           0 :     return transform_plugin_;
      83             :   }
      84             : 
      85             :   DCPS::RcHandle<Utility> get_utility() const
      86             :   {
      87             :     return utility_plugin_;
      88             :   }
      89             : 
      90           0 :   HandleRegistry_rch get_handle_registry(const DCPS::GUID_t& participant_id)
      91             :   {
      92           0 :     HandleRegistry_rch handle_registry;
      93             : 
      94           0 :     ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex_, handle_registry);
      95             : 
      96           0 :     HandleRegistryMap::const_iterator pos = handle_registry_map_.find(participant_id);
      97           0 :     if (pos != handle_registry_map_.end()) {
      98           0 :       handle_registry = pos->second;
      99             :     } else {
     100           0 :       handle_registry = DCPS::make_rch<HandleRegistry>();
     101           0 :       handle_registry_map_[participant_id] = handle_registry;
     102             : 
     103           0 :       if (DCPS::security_debug.bookkeeping) {
     104           0 :         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           0 :     return handle_registry;
     111           0 :   }
     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             : 
     131             :   SecurityConfig(const OPENDDS_STRING& name,
     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             : 
     150             :   const OPENDDS_STRING name_;
     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_;
     158             :   DCPS::RcHandle<Utility> utility_plugin_;
     159             :   typedef OPENDDS_MAP_CMP(DCPS::GUID_t, HandleRegistry_rch, DCPS::GUID_tKeyLessThan) HandleRegistryMap;
     160             :   HandleRegistryMap handle_registry_map_;
     161             :   mutable ACE_Thread_Mutex mutex_;
     162             : #endif
     163             : 
     164             :   ConfigPropertyList properties_;
     165             : };
     166             : 
     167             : }
     168             : }
     169             : 
     170             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     171             : 
     172             : #endif /* OPENDDS_DCPS_SECURTIY_CONFIG_H */

Generated by: LCOV version 1.16