Loading src/Configuration.h +25 −12 Original line number Diff line number Diff line #ifndef CONFIGURATION_H #define CONFIGURATION_H #include <map> #include <string> #include <vector> #include <boost/shared_ptr.hpp> namespace MetadataExporter_ns Loading @@ -13,9 +17,14 @@ public: // [Public] Shared pointer typedef //------------------------------------------------------------------------------ typedef boost::shared_ptr<Configuration> SP; typedef std::vector< SP > SPVector; private: //------------------------------------------------------------------------------ // [Public] Map typedef //------------------------------------------------------------------------------ typedef const std::multimap<const std::string, const std::string> ExportedTablesMap; typedef const std::map<const std::string, const std::string> AuthorisedUsersMap; protected: //------------------------------------------------------------------------------ // [Private] Constructor destructor deleter //------------------------------------------------------------------------------ Loading @@ -23,12 +32,15 @@ private: std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) : std::string databaseUsername, std::string databasePassword, ExportedTablesMap exportedTablesMap, AuthorisedUsersMap authorisedUsersMap) : m_certificateFile(certificateFile), m_privateKeyFile(privateKeyFile), m_dHTempFile(dHTempFile), m_localHost(localHost), m_localPort(localPort), m_workerNumber(workerNumber), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword) {} m_databaseUsername(databaseUsername), m_databasePassword(databasePassword), m_exportedTablesMap(exportedTablesMap), m_authorisedUsersMap(authorisedUsersMap) {} virtual ~Configuration() {} class Deleter; Loading @@ -48,12 +60,13 @@ public: std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) std::string databasePassword, ExportedTablesMap exportedTablesMap, AuthorisedUsersMap authorisedUsersMap) { Configuration::SP c_sp(new Configuration(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword), Configuration::Deleter()); databasePort, databaseUsername, databasePassword, exportedTablesMap, authorisedUsersMap), Configuration::Deleter()); return c_sp; } Loading @@ -69,7 +82,7 @@ public: std::string getDatabaseUsername() const { return m_databaseUsername; }; std::string getDatabasePassword() const { return m_databasePassword; }; private: protected: //------------------------------------------------------------------------------ // [Private] class variables //------------------------------------------------------------------------------ Loading Loading @@ -103,11 +116,11 @@ private: //Metadata database login password const std::string m_databasePassword; //TODO: Tables exporter from database: one table per row std::vector<std::string> m_exportedTables; //Exported tables multi map [schema table] ExportedTablesMap m_exportedTablesMap; //TODO: Authorised user list: one user per row std::vector<std::string> m_authorisedUsers; //Authorised users map [user password] AuthorisedUsersMap m_authorisedUsersMap; }; Loading src/MetadataExporter.cpp +57 −6 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <Configuration.h> #include <PlainServer.h> #include <SSLServer.h> #include <bits/c++config.h> /*----- PROTECTED REGION END -----*/ // MetadataExporter.cpp Loading Loading @@ -152,10 +153,6 @@ void MetadataExporter::init_device() if(get_state() != Tango::FAULT) { Configuration::SP configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword); try { if(enableSSL) Loading Loading @@ -190,8 +187,11 @@ void MetadataExporter::get_device_property() { /*----- PROTECTED REGION ID(MetadataExporter::get_device_property_before) ENABLED START -----*/ // Initialize property data members //Exported tables multi map [schema table] std::multimap<const std::string, const std::string> exportedTablesMap; //Authorised user map [user password] std::map<const std::string, const std::string> authorisedUsersMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::get_device_property_before Loading Loading @@ -409,8 +409,59 @@ void MetadataExporter::get_device_property() if(exportedTables.empty()) throw(invalid_argument("ExportedTables property is empty or not defined")); for(unsigned int i=0; i<exportedTables.size(); ++i) { std::size_t found; if((found=exportedTables.at(i).find(' '))==std::string::npos) { std::stringstream errorStream; errorStream << "ExportedTables property has invalid key at " << i << " position" << std::endl; throw(errorStream.str()); } std::string schema = exportedTables.at(i).substr(0, found); std::string table = exportedTables.at(i).substr(found+1, std::string::npos); #ifdef VERBOSE_DEBUG INFO_STREAM << "SCHEMA: " << schema << " TABLE: " << table << endl; INFO_STREAM << "-------------------------------------------------" << endl; #endif exportedTablesMap.insert(std::pair<const std::string, const std::string> (schema, table)); } if(authorisedUsers.empty()) throw(invalid_argument("AuthorisedUsers property is empty or not defined")); for(unsigned int i=0; i<authorisedUsers.size(); ++i) { std::size_t found; if((found=authorisedUsers.at(i).find(' '))==std::string::npos) { std::stringstream errorStream; errorStream << "AuthorisedUsers property has invalid key at " << i << " position" << std::endl; throw(errorStream.str()); } std::string user = authorisedUsers.at(i).substr(0, found); std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos); #ifdef VERBOSE_DEBUG INFO_STREAM << "USER: " << user << " PASSWORD: " << password << endl; INFO_STREAM << "-------------------------------------------------" << endl; #endif authorisedUsersMap.insert(std::pair<const std::string, const std::string>(user, password)); } configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword, exportedTablesMap, authorisedUsersMap); } catch(invalid_argument& ex) { Loading @@ -431,7 +482,7 @@ void MetadataExporter::get_device_property() //-------------------------------------------------------- void MetadataExporter::always_executed_hook() { INFO_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(MetadataExporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading src/MetadataExporter.h +3 −6 Original line number Diff line number Diff line Loading @@ -67,6 +67,9 @@ class MetadataExporter : public TANGO_BASE_CLASS //------------------------------------------------------------------------------ // [Private] Class variables //------------------------------------------------------------------------------ //Configuration class shared pointer Configuration::SP configuration_sp; //Server base class shared pointer Server::SP m_server_sp; Loading @@ -79,12 +82,6 @@ class MetadataExporter : public TANGO_BASE_CLASS //Max database port number allowed value static const unsigned int MAX_DB_PORT = 65535; //Exported tables map std::map<std::string, std::string> m_exportedTableMap; //Authorised user password map std::map<std::string, std::string> m_authorisedUserMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::Data Members // Device property data members Loading Loading
src/Configuration.h +25 −12 Original line number Diff line number Diff line #ifndef CONFIGURATION_H #define CONFIGURATION_H #include <map> #include <string> #include <vector> #include <boost/shared_ptr.hpp> namespace MetadataExporter_ns Loading @@ -13,9 +17,14 @@ public: // [Public] Shared pointer typedef //------------------------------------------------------------------------------ typedef boost::shared_ptr<Configuration> SP; typedef std::vector< SP > SPVector; private: //------------------------------------------------------------------------------ // [Public] Map typedef //------------------------------------------------------------------------------ typedef const std::multimap<const std::string, const std::string> ExportedTablesMap; typedef const std::map<const std::string, const std::string> AuthorisedUsersMap; protected: //------------------------------------------------------------------------------ // [Private] Constructor destructor deleter //------------------------------------------------------------------------------ Loading @@ -23,12 +32,15 @@ private: std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) : std::string databaseUsername, std::string databasePassword, ExportedTablesMap exportedTablesMap, AuthorisedUsersMap authorisedUsersMap) : m_certificateFile(certificateFile), m_privateKeyFile(privateKeyFile), m_dHTempFile(dHTempFile), m_localHost(localHost), m_localPort(localPort), m_workerNumber(workerNumber), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword) {} m_databaseUsername(databaseUsername), m_databasePassword(databasePassword), m_exportedTablesMap(exportedTablesMap), m_authorisedUsersMap(authorisedUsersMap) {} virtual ~Configuration() {} class Deleter; Loading @@ -48,12 +60,13 @@ public: std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) std::string databasePassword, ExportedTablesMap exportedTablesMap, AuthorisedUsersMap authorisedUsersMap) { Configuration::SP c_sp(new Configuration(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword), Configuration::Deleter()); databasePort, databaseUsername, databasePassword, exportedTablesMap, authorisedUsersMap), Configuration::Deleter()); return c_sp; } Loading @@ -69,7 +82,7 @@ public: std::string getDatabaseUsername() const { return m_databaseUsername; }; std::string getDatabasePassword() const { return m_databasePassword; }; private: protected: //------------------------------------------------------------------------------ // [Private] class variables //------------------------------------------------------------------------------ Loading Loading @@ -103,11 +116,11 @@ private: //Metadata database login password const std::string m_databasePassword; //TODO: Tables exporter from database: one table per row std::vector<std::string> m_exportedTables; //Exported tables multi map [schema table] ExportedTablesMap m_exportedTablesMap; //TODO: Authorised user list: one user per row std::vector<std::string> m_authorisedUsers; //Authorised users map [user password] AuthorisedUsersMap m_authorisedUsersMap; }; Loading
src/MetadataExporter.cpp +57 −6 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <Configuration.h> #include <PlainServer.h> #include <SSLServer.h> #include <bits/c++config.h> /*----- PROTECTED REGION END -----*/ // MetadataExporter.cpp Loading Loading @@ -152,10 +153,6 @@ void MetadataExporter::init_device() if(get_state() != Tango::FAULT) { Configuration::SP configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword); try { if(enableSSL) Loading Loading @@ -190,8 +187,11 @@ void MetadataExporter::get_device_property() { /*----- PROTECTED REGION ID(MetadataExporter::get_device_property_before) ENABLED START -----*/ // Initialize property data members //Exported tables multi map [schema table] std::multimap<const std::string, const std::string> exportedTablesMap; //Authorised user map [user password] std::map<const std::string, const std::string> authorisedUsersMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::get_device_property_before Loading Loading @@ -409,8 +409,59 @@ void MetadataExporter::get_device_property() if(exportedTables.empty()) throw(invalid_argument("ExportedTables property is empty or not defined")); for(unsigned int i=0; i<exportedTables.size(); ++i) { std::size_t found; if((found=exportedTables.at(i).find(' '))==std::string::npos) { std::stringstream errorStream; errorStream << "ExportedTables property has invalid key at " << i << " position" << std::endl; throw(errorStream.str()); } std::string schema = exportedTables.at(i).substr(0, found); std::string table = exportedTables.at(i).substr(found+1, std::string::npos); #ifdef VERBOSE_DEBUG INFO_STREAM << "SCHEMA: " << schema << " TABLE: " << table << endl; INFO_STREAM << "-------------------------------------------------" << endl; #endif exportedTablesMap.insert(std::pair<const std::string, const std::string> (schema, table)); } if(authorisedUsers.empty()) throw(invalid_argument("AuthorisedUsers property is empty or not defined")); for(unsigned int i=0; i<authorisedUsers.size(); ++i) { std::size_t found; if((found=authorisedUsers.at(i).find(' '))==std::string::npos) { std::stringstream errorStream; errorStream << "AuthorisedUsers property has invalid key at " << i << " position" << std::endl; throw(errorStream.str()); } std::string user = authorisedUsers.at(i).substr(0, found); std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos); #ifdef VERBOSE_DEBUG INFO_STREAM << "USER: " << user << " PASSWORD: " << password << endl; INFO_STREAM << "-------------------------------------------------" << endl; #endif authorisedUsersMap.insert(std::pair<const std::string, const std::string>(user, password)); } configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword, exportedTablesMap, authorisedUsersMap); } catch(invalid_argument& ex) { Loading @@ -431,7 +482,7 @@ void MetadataExporter::get_device_property() //-------------------------------------------------------- void MetadataExporter::always_executed_hook() { INFO_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(MetadataExporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading
src/MetadataExporter.h +3 −6 Original line number Diff line number Diff line Loading @@ -67,6 +67,9 @@ class MetadataExporter : public TANGO_BASE_CLASS //------------------------------------------------------------------------------ // [Private] Class variables //------------------------------------------------------------------------------ //Configuration class shared pointer Configuration::SP configuration_sp; //Server base class shared pointer Server::SP m_server_sp; Loading @@ -79,12 +82,6 @@ class MetadataExporter : public TANGO_BASE_CLASS //Max database port number allowed value static const unsigned int MAX_DB_PORT = 65535; //Exported tables map std::map<std::string, std::string> m_exportedTableMap; //Authorised user password map std::map<std::string, std::string> m_authorisedUserMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::Data Members // Device property data members Loading