00001 #ifndef COND_XMLAUTHENTITACTIONSERVICE_H 00002 #define COND_XMLAUTHENTITACTIONSERVICE_H 00003 00004 #include "RelationalAccess/IAuthenticationService.h" 00005 #include "CoralKernel/Service.h" 00006 00007 #include <map> 00008 #include <set> 00009 #include <string> 00010 #include <boost/thread.hpp> 00011 00012 namespace coral { 00013 00014 class AuthenticationCredentials; 00015 //class IAuthenticationCredentials; 00016 } 00017 00018 namespace cond { 00019 00020 namespace XMLAuthenticationService { 00021 00027 class DataSourceEntry 00028 { 00029 public: 00031 DataSourceEntry( const std::string& serviceName, 00032 const std::string& connectionName ); 00033 00035 ~DataSourceEntry(); 00036 00040 void appendCredentialItem( const std::string& item, 00041 const std::string& value ); 00042 00046 void appendCredentialItemForRole( const std::string& item, 00047 const std::string& value, 00048 const std::string& role ); 00049 00053 const coral::IAuthenticationCredentials& credentials() const; 00054 00059 const coral::IAuthenticationCredentials& credentials( const std::string& role ) const; 00060 00061 private: 00063 std::string m_serviceName; 00064 00066 std::string m_connectionName; 00067 00069 coral::AuthenticationCredentials* m_default; 00070 00072 std::map< std::string, coral::AuthenticationCredentials* > m_data; 00073 00074 private: 00075 DataSourceEntry(); 00076 DataSourceEntry( const DataSourceEntry& ); 00077 DataSourceEntry& operator=( const DataSourceEntry& ); 00078 }; 00079 00085 class XMLAuthenticationService : public coral::Service, 00086 virtual public coral::IAuthenticationService 00087 { 00088 00089 public: 00091 explicit XMLAuthenticationService( const std::string& name ); 00092 00094 virtual ~XMLAuthenticationService(); 00095 00096 public: 00101 const coral::IAuthenticationCredentials& credentials( const std::string& connectionString ) const; 00102 00108 const coral::IAuthenticationCredentials& credentials( const std::string& connectionString, 00109 const std::string& role ) const; 00110 00111 public: 00113 void setInputFileName( const std::string& inputFileName ); 00114 00115 private: 00117 bool initialize(); 00118 00120 void reset(); 00121 00123 bool processFile( const std::string& inputFileName ); 00124 00126 std::set< std::string > verifyFileName(); 00127 00129 bool m_isInitialized; 00130 00132 std::string m_inputFileName; 00133 00135 std::map< std::string, DataSourceEntry* > m_data; 00136 00138 mutable boost::mutex m_mutexLock; 00139 00140 coral::Property::CallbackID m_callbackID; 00141 }; 00142 00143 } 00144 00145 } 00146 00147 #endif