SecurityRegistry.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_SECURITYREGISTRY_H
00009 #define OPENDDS_DCPS_SECURITYREGISTRY_H
00010 
00011 #include "dds/DCPS/dcps_export.h"
00012 
00013 #include "dds/DdsDcpsDomainC.h"
00014 #include "dds/DdsSecurityCoreC.h"
00015 
00016 #include "dds/DCPS/PoolAllocator.h"
00017 
00018 #include "dds/DCPS/security/framework/SecurityPluginInst_rch.h"
00019 #include "dds/DCPS/security/framework/SecurityConfig_rch.h"
00020 #include "dds/DCPS/security/framework/SecurityConfigPropertyList.h"
00021 
00022 
00023 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00024 class ACE_Configuration_Heap;
00025 ACE_END_VERSIONED_NAMESPACE_DECL
00026 
00027 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 #define TheSecurityRegistry OpenDDS::Security::SecurityRegistry::instance()
00030 
00031 namespace OpenDDS {
00032 namespace Security {
00033 
00034 /**
00035  * The TheSecurityRegistry is a singleton object which provides a mechanism to
00036  * the application code to configure OpenDDS's security plugins.
00037  */
00038 class OpenDDS_Dcps_Export SecurityRegistry {
00039 public:
00040 
00041   /// Return a singleton instance of this class.
00042   static SecurityRegistry* instance();
00043 
00044   /// Close the singleton instance of this class.
00045   static void close();
00046 
00047   static const OPENDDS_STRING DEFAULT_CONFIG_NAME;
00048 
00049   /// This will shutdown all Security plugin objects.
00050   ///
00051   /// Client Application calls this method to tear down the security framework.
00052   void release();
00053 
00054   // Called by plugins to register their factory interface
00055   void register_plugin(const OPENDDS_STRING& plugin_name,
00056                        SecurityPluginInst_rch plugin);
00057 
00058   // Create or get an existing SecurityConfig object based off the name
00059   // in the configuration file
00060   SecurityConfig_rch create_config(const OPENDDS_STRING& config_name);
00061 
00062   SecurityConfig_rch create_config(const OPENDDS_STRING& config_name,
00063                                    SecurityPluginInst_rch plugin);
00064 
00065   SecurityConfig_rch get_config(const OPENDDS_STRING& config_name) const;
00066 
00067   SecurityConfig_rch default_config() const;
00068   void default_config(const SecurityConfig_rch& cfg);
00069 
00070   void bind_config(const OPENDDS_STRING& name,
00071                    DDS::DomainParticipant_ptr domain_participant);
00072   void bind_config(const SecurityConfig_rch& config,
00073                    DDS::DomainParticipant_ptr domain_participant);
00074 
00075   /// For internal use by OpenDDS DCPS layer:
00076   /// Transfer the configuration in ACE_Configuration_Heap object to
00077   /// the SecurityRegistry.  This is called by the Service_Participant
00078   /// at initialization time. This function iterates each section in
00079   /// the configuration file, and creates SecurityConfigEntry
00080   /// objects and adds them to the registry.
00081   int load_security_configuration(ACE_Configuration_Heap& cf);
00082 
00083   SecurityConfig_rch fix_empty_default();
00084 
00085 private:
00086   friend class ACE_Singleton<SecurityRegistry, ACE_Recursive_Thread_Mutex>;
00087 
00088   static const OPENDDS_STRING DEFAULT_INST_PREFIX;
00089   static const OPENDDS_STRING DEFAULT_PLUGIN_NAME;
00090   static const OPENDDS_STRING SECURITY_SECTION_NAME;
00091   static const OPENDDS_STRING ACCESS_CTRL_PLUGIN_NAME;
00092   static const OPENDDS_STRING AUTHENTICATION_PLUGIN_NAME;
00093   static const OPENDDS_STRING CRYPTO_PLUGIN_NAME;
00094 
00095   // Internal class used to store configuration information
00096   class SecurityConfigEntry : public DCPS::RcObject
00097   {
00098   public:
00099 
00100     SecurityConfigEntry(const OPENDDS_STRING& entryNamee);
00101     ~SecurityConfigEntry();
00102 
00103     void add_property(const OPENDDS_STRING& name, const OPENDDS_STRING& value);
00104 
00105     const OPENDDS_STRING& get_entry_name() const { return entry_name_; }
00106     const OPENDDS_STRING& get_auth_name() const { return auth_name_; }
00107     const OPENDDS_STRING& get_access_control_name() const { return access_ctrl_name_; }
00108     const OPENDDS_STRING& get_crypto_name() const { return crypto_name_; }
00109 
00110     const ConfigPropertyList& get_properties() const { return properties_; }
00111 
00112   private:
00113     const OPENDDS_STRING entry_name_;
00114 
00115     OPENDDS_STRING auth_name_;
00116     OPENDDS_STRING access_ctrl_name_;
00117     OPENDDS_STRING crypto_name_;
00118     ConfigPropertyList properties_;
00119   };
00120 
00121   typedef DCPS::RcHandle<SecurityConfigEntry> SecurityConfigEntry_rch;
00122   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityConfig_rch) ConfigMap;
00123   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityPluginInst_rch) InstMap;
00124   typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) LibDirectiveMap;
00125   typedef OPENDDS_MAP(OPENDDS_STRING, SecurityConfigEntry_rch) ConfigEntryMap;
00126 
00127   SecurityRegistry();
00128   ~SecurityRegistry();
00129 
00130   int load_security_sections(ACE_Configuration_Heap& cf, ConfigEntryMap& entries);
00131 
00132   /// For internal use by OpenDDS DCPS layer:
00133   /// Dynamically load the library for the supplied security plugin type.
00134   void load_security_plugin_lib(const OPENDDS_STRING& security_plugin_type);
00135 
00136   SecurityPluginInst_rch get_plugin_inst(const OPENDDS_STRING& plugin_name);
00137   bool find_config(const OPENDDS_STRING& name, SecurityConfig_rch& config);
00138   bool add_config(const OPENDDS_STRING& name, SecurityConfig_rch& config);
00139 
00140   typedef ACE_SYNCH_MUTEX LockType;
00141   typedef ACE_Guard<LockType> GuardType;
00142 
00143   ConfigEntryMap config_entries_;
00144   ConfigMap config_map_;
00145   InstMap registered_plugins_;
00146   LibDirectiveMap lib_directive_map_;
00147   mutable SecurityConfig_rch default_config_;
00148 
00149   mutable LockType lock_;
00150 };
00151 
00152 } // namespace Security
00153 } // namespace OpenDDS
00154 
00155 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00156 
00157 #endif  /* OPENDDS_DCPS_SECURITYREGISTRY_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1