LCOV - code coverage report
Current view: top level - DCPS/security/framework - SecurityRegistry.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 4 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 4 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_SECURITYREGISTRY_H
       9             : #define OPENDDS_DCPS_SECURITY_FRAMEWORK_SECURITYREGISTRY_H
      10             : 
      11             : #include "SecurityPluginInst_rch.h"
      12             : #include "SecurityConfig_rch.h"
      13             : #include "SecurityConfigPropertyList.h"
      14             : 
      15             : #include <dds/DCPS/dcps_export.h>
      16             : #include <dds/DCPS/PoolAllocator.h>
      17             : #include <dds/DdsDcpsDomainC.h>
      18             : 
      19             : ACE_BEGIN_VERSIONED_NAMESPACE_DECL
      20             : class ACE_Configuration_Heap;
      21             : ACE_END_VERSIONED_NAMESPACE_DECL
      22             : 
      23             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      24             : 
      25             : #define TheSecurityRegistry OpenDDS::Security::SecurityRegistry::instance()
      26             : 
      27             : namespace OpenDDS {
      28             : namespace Security {
      29             : 
      30             : /**
      31             :  * The TheSecurityRegistry is a singleton object which provides a mechanism to
      32             :  * the application code to configure OpenDDS's security plugins.
      33             :  */
      34             : class OpenDDS_Dcps_Export SecurityRegistry {
      35             : public:
      36             : 
      37             :   /// Return a singleton instance of this class.
      38             :   static SecurityRegistry* instance();
      39             : 
      40             :   /// Close the singleton instance of this class.
      41             :   static void close();
      42             : 
      43             :   static const char* DEFAULT_CONFIG_NAME;
      44             :   static const char* BUILTIN_CONFIG_NAME;
      45             : 
      46             :   /// This will shutdown all Security plugin objects.
      47             :   ///
      48             :   /// Client Application calls this method to tear down the security framework.
      49             :   void release();
      50             : 
      51             :   /**
      52             :    * If the plugin is registered then return it. If it's not and attempt_fix is
      53             :    * true, then try to load and return the plugin, otherwise return a nil rch.
      54             :    */
      55             :   SecurityPluginInst_rch get_plugin_inst(
      56             :     const OPENDDS_STRING& plugin_name, bool attempt_fix = true);
      57             : 
      58             :   // Called by plugins to register their factory interface
      59             :   void register_plugin(const OPENDDS_STRING& plugin_name,
      60             :                        SecurityPluginInst_rch plugin);
      61             : 
      62             :   // Create or get an existing SecurityConfig object based off the name
      63             :   // in the configuration file
      64             :   SecurityConfig_rch create_config(const OPENDDS_STRING& config_name);
      65             : 
      66             :   SecurityConfig_rch create_config(const OPENDDS_STRING& config_name,
      67             :                                    SecurityPluginInst_rch plugin);
      68             : 
      69             :   bool has_no_configs() const;
      70             : 
      71             :   SecurityConfig_rch get_config(const OPENDDS_STRING& config_name) const;
      72             : 
      73             :   SecurityConfig_rch default_config() const;
      74             :   void default_config(const SecurityConfig_rch& cfg);
      75             : 
      76             :   SecurityConfig_rch builtin_config() const;
      77             :   void builtin_config(const SecurityConfig_rch& cfg);
      78             : 
      79             :   /// For internal use by OpenDDS DCPS layer:
      80             :   /// Transfer the configuration in ACE_Configuration_Heap object to
      81             :   /// the SecurityRegistry.  This is called by the Service_Participant
      82             :   /// at initialization time. This function iterates each section in
      83             :   /// the configuration file, and creates SecurityConfigEntry
      84             :   /// objects and adds them to the registry.
      85             :   int load_security_configuration(ACE_Configuration_Heap& cf);
      86             : 
      87             : private:
      88             :   friend class ACE_Singleton<SecurityRegistry, ACE_Recursive_Thread_Mutex>;
      89             : 
      90             :   static const char* DEFAULT_INST_PREFIX;
      91             :   static const char* DEFAULT_PLUGIN_NAME;
      92             :   static const char* SECURITY_SECTION_NAME;
      93             :   static const char* ACCESS_CTRL_PLUGIN_NAME;
      94             :   static const char* AUTHENTICATION_PLUGIN_NAME;
      95             :   static const char* CRYPTO_PLUGIN_NAME;
      96             : 
      97             :   // Internal class used to store configuration information
      98             :   class SecurityConfigEntry : public DCPS::RcObject
      99             :   {
     100             :   public:
     101             : 
     102             :     SecurityConfigEntry(const OPENDDS_STRING& entryNamee);
     103             :     ~SecurityConfigEntry();
     104             : 
     105             :     void add_property(const OPENDDS_STRING& name, const OPENDDS_STRING& value);
     106             : 
     107             :     const OPENDDS_STRING& get_entry_name() const { return entry_name_; }
     108           0 :     const OPENDDS_STRING& get_auth_name() const { return auth_name_; }
     109           0 :     const OPENDDS_STRING& get_access_control_name() const { return access_ctrl_name_; }
     110           0 :     const OPENDDS_STRING& get_crypto_name() const { return crypto_name_; }
     111             : 
     112           0 :     const ConfigPropertyList& get_properties() const { return properties_; }
     113             : 
     114             :   private:
     115             :     const OPENDDS_STRING entry_name_;
     116             : 
     117             :     OPENDDS_STRING auth_name_;
     118             :     OPENDDS_STRING access_ctrl_name_;
     119             :     OPENDDS_STRING crypto_name_;
     120             :     ConfigPropertyList properties_;
     121             :   };
     122             : 
     123             :   typedef DCPS::RcHandle<SecurityConfigEntry> SecurityConfigEntry_rch;
     124             :   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityConfig_rch) ConfigMap;
     125             :   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityPluginInst_rch) InstMap;
     126             :   typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) LibDirectiveMap;
     127             :   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityConfigEntry_rch) ConfigEntryMap;
     128             : 
     129             :   SecurityRegistry();
     130             :   ~SecurityRegistry();
     131             : 
     132             :   int load_security_sections(ACE_Configuration_Heap& cf, ConfigEntryMap& entries);
     133             : 
     134             :   /// For internal use by OpenDDS DCPS layer:
     135             :   /// Dynamically load the library for the supplied security plugin type.
     136             :   void load_security_plugin_lib(const OPENDDS_STRING& security_plugin_type);
     137             : 
     138             :   bool find_config(const OPENDDS_STRING& name, SecurityConfig_rch& config);
     139             :   bool add_config(const OPENDDS_STRING& name, SecurityConfig_rch& config);
     140             : 
     141             :   typedef ACE_SYNCH_MUTEX LockType;
     142             :   typedef ACE_Guard<LockType> GuardType;
     143             : 
     144             :   ConfigEntryMap config_entries_;
     145             :   ConfigMap config_map_;
     146             :   InstMap registered_plugins_;
     147             :   LibDirectiveMap lib_directive_map_;
     148             :   mutable SecurityConfig_rch default_config_;
     149             :   mutable SecurityConfig_rch builtin_config_;
     150             : 
     151             :   mutable LockType lock_;
     152             :   mutable LockType default_load_lock_;
     153             : };
     154             : 
     155             : } // namespace Security
     156             : } // namespace OpenDDS
     157             : 
     158             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     159             : 
     160             : #endif  /* OPENDDS_DCPS_SECURITYREGISTRY_H */

Generated by: LCOV version 1.16